2015-10-07 53 views
0

我在AWS上部署了3節點彈性搜索集羣。一個主節點和2個從節點。我所有的索引和搜索查詢都是針對master_IP:9200。我的問題是關於處理主節點關閉時的情況。我如何知道新的主節點?彈性搜索處理主/從關機

以下是我的集羣中的yaml文件。

站長:

#################################### Node ##################################### 

# Node names are generated dynamically on startup, so you're relieved 
# from configuring them manually. You can tie this node to a specific name: 
# 
node.name: "Master_0" 
path.data: "/mntebs/elasticsearch" 
node.master: true 
node.data: true 

# Set the number of shards (splits) of an index (5 by default): 
# 
index.number_of_shards: 5 

# Set the number of replicas (additional copies) of an index (1 by default): 
# 
index.number_of_replicas: 2 

Slave_1:

#################################### Node ##################################### 

# Node names are generated dynamically on startup, so you're relieved 
# from configuring them manually. You can tie this node to a specific name: 
# 
node.name: "Slave_0" 
path.data: "/mntebs/elasticsearch" 
node.master: false 
node.data: true 

# Set the number of shards (splits) of an index (5 by default): 
# 
index.number_of_shards: 5 

# Set the number of replicas (additional copies) of an index (1 by default): 
# 
index.number_of_replicas: 1 

Slave_2:

#################################### Node ##################################### 

# Node names are generated dynamically on startup, so you're relieved 
# from configuring them manually. You can tie this node to a specific name: 
# 
node.name: "Slave_1" 
path.data: "/mntebs/elasticsearch" 
node.master: false 
node.data: true 

# Set the number of shards (splits) of an index (5 by default): 
# 
index.number_of_shards: 5 

# Set the number of replicas (additional copies) of an index (1 by default): 
# 
index.number_of_replicas: 1 

回答

0

我看你只需要在集羣中的1個主合格的節點。如果該節點停止運行,您的集羣將停止運行,並且將會停止運行;討論完畢。我的建議是讓所有3個節點都符合條件,即在所有節點上設置node.master以及node.datatrue。一次只有其中一人擔任主人。如果該節點關閉,另一個節點將被提升爲主節點。這樣,即使兩個節點關閉,您的羣集也將保持健康狀態(可能會變爲yellow狀態)。使用此配置,您需要以循環方式將查詢指向所有節點。許多Elasticsearch客戶端支持此功能。

+0

**請勿建議將請求發送到單個節點**,除非該節點是客戶端節點。該節點將會過載(CPU,內存,磁盤)。 –

+0

我知道。這就是爲什麼我建議使用一些通常圍繞着請求的客戶端。 – bittusarkar

+0

我在您的回覆中沒有看到此消息。相反,我看到「通過這種配置,您需要將您的查詢指向三個節點節點中的一個節點,並將其停止,並將其導向另一個節點。」 –

0

有一些錯誤的東西與你的集羣:

  • 你指揮你的要求只有一個節點。 不要這樣做!將請求循環到所有節點。將所有內容指向單個節點將使該節點過載並可能導致該節點關閉。這對你的主節點來說更危險。
  • 要讓所有的三個節點都masterdata,而不是隻在一個節點
  • 如果三者主機和數據,使用minimum_master_nodes設置avoid having a split-brain situation。任何節點都可以成爲主節點,哪個節點無關緊要。同樣,不會將所有請求發送到單個節點,請使用client nodes並將請求僅發送到客戶端節點,或者以循環方式將請求發送到羣集中的所有節點。
discovery.zen.minimum_master_nodes: 2 
  • 在所有節點配置文件

index.number_of_replicas: 2上的主人,但index.number_of_replicas: 1數據節點

另外,我建議您閱讀文檔,相同的設置(這是非常好的btw),因爲你缺乏關於Elasticsearch的一些基本的東西。請閱讀文檔。