弹性搜索处理主/从关机

时间:2015-10-07 08:57:46

标签: amazon-web-services elasticsearch configuration

我在AWS上部署了一个3节点弹性搜索集群。一个主节点和两个从节点。我的所有索引和搜索查询都指向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

2 个答案:

答案 0 :(得分:0)

我发现群集中只有1个符合条件的主节点。如果该节点出现故障,您的群集将关闭并将停止运行;讨论结束。我的建议是让所有3个节点都符合条件,即在所有节点上设置node.master以及node.datatrue。在这个时候,他们中只有一个会充当主人。如果该节点发生故障,则另一个节点将被提升为主节点。这样,即使两个节点关闭,您的群集仍将保持健康状态(可能会转到yellow状态)。使用此配置,您需要以循环方式将查询定向到所有节点。许多Elasticsearch客户端都支持此功能。

答案 1 :(得分:0)

您的群集存在一些错误:

  • 您只是将请求指向一个节点。 不要这样做!将请求循环到所有节点。将所有内容定向到单个节点将使该节点超载并可能将其关闭。这对你的主节点来说更危险。
  • 将所有三个节点设为masterdata,而不仅仅是一个节点
  • 如果所有三个都是主数据和数据,请使用minimum_master_nodes设置为avoid having a split-brain situation。任何节点都可以成为主节点,哪个节点无关紧要。同样,不会将所有请求发送到单个节点,使用client nodes并仅将请求发送到客户端节点或以循环方式将请求发送到所有节点在集群中。
discovery.zen.minimum_master_nodes: 2
  • 在所有节点配置文件中具有相同的设置
master上的

index.number_of_replicas: 2,但数据节点上的index.number_of_replicas: 1

另外,我建议阅读文档(这是非常好的btw),因为你缺少一些关于Elasticsearch的基本知识。请阅读文档。

相关问题