Cannot add node to cluster (elasticsearch)

淺唱寂寞╮ 提交于 2021-01-29 06:57:47

问题


I'm trying to make the health of my cluster green. According to the following elasticsearch documentation: 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.

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

So I created 2 elasticsearch instances with the following configuration files:

# 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

By running the following curl command : curl -GETX localhost:9200/_cluster/health?pretty=true I should according the elasticsearch documentation (see link below) have 2 nodes on my cluster. However, my number of nodes remains at 1.

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


回答1:


First of all, the port you're using in the discovery.zen.ping.unicast.hosts setting is not the correct one, it should be the TCP port, not the HTTP one.

However, since you're running on ES7, a new discovery protocol is now being used, which ignores the discovery.zen.ping.unicast.hosts setting.

Since you're running both nodes on the same machine, you don't need any special configuration to have both nodes form a cluster, they should auto-discover themselves (provided you remove the discovery.* settings.

If you're running the two nodes on two different machines, then you need to use the following settings instead:

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


来源:https://stackoverflow.com/questions/55964071/cannot-add-node-to-cluster-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!