2015-10-07 48 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的一些基本的东西。请阅读文档。