0

我正在尝试使集群的健康状况变为绿色。根据以下弹性搜索文档:When you add more nodes to a cluster, it automatically allocates replica shards. When all primary and replica shards are active, the cluster state changes to green.

来源:https ://www.elastic.co/guide/en/elasticsearch/reference/current/add-elasticsearch-nodes.html

因此,我使用以下配置文件创建了 2 个 elasticsearch 实例:

# Config File 1
cluster.name : PL
node.name : "Node-1"
node.master : true
node.data : true
network.host : "127.0.0.1"
http.port : 9200
discovery.zen.ping.unicast.hosts : ["127.0.0.1:9200", "127.0.0.1:9201"]
discovery.zen.minimum_master_nodes : 2

# Config File 2
cluster.name : PL
node.name : "Node-2"
node.master : true
node.data : true
network.host : "127.0.0.1"
http.port : 9201
discovery.zen.ping.unicast.hosts : ["127.0.0.1:9200", "127.0.0.1:9201"]
discovery.zen.minimum_master_nodes : 2

通过运行以下 curl 命令:curl -GETX localhost:9200/_cluster/health?pretty=true我应该根据 elasticsearch 文档(见下面的链接)在我的集群上有 2 个节点。但是,我的节点数仍为 1。

来源:https ://www.elastic.co/guide/en/elasticsearch/guide/current/_add_failover.html

4

1 回答 1

1

首先,您在discovery.zen.ping.unicast.hosts设置中使用的端口不正确,应该是 TCP 端口,而不是 HTTP 端口。

但是,由于您在 ES7 上运行,因此现在正在使用新的发现协议discovery.zen.ping.unicast.hosts,它会忽略该设置。

由于您在同一台机器上运行两个节点,因此您不需要任何特殊配置即可让两个节点组成一个集群,它们应该自动发现自己(前提是您删除discovery.*设置。

如果您在两台不同的机器上运行这两个节点,那么您需要改用以下设置

discovery.seed_hosts:
   - 127.0.0.1:9300
   - 127.0.0.1:9301
cluster.initial_master_nodes:
   - 127.0.0.1:9300
   - 127.0.0.1:9301
于 2019-05-03T06:39:19.770 回答