0
votes

So, I have two elasticsearch servers (version 7 of elasticsearch) and wanted to form a cluster with master and data node, but I'm facing some difficulties in connecting them in a same cluster, these are my .yml files and the things I've tried so far, any help would be appreciated:

xxx.235 yml: #data node

cluster.name: monitoring
node.name: "es-data-node-2"
node.master: false
node.data: true

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

network.host: xxx.235
network.publish_host: xxx.52
http.port: 9200

discovery.seed_hosts: ["xxx.52", "xxx.235"] #tried this instead as well discovery.zen.ping.unicast.hosts: 2
discovery.zen.minimum_master_nodes: 2 #tried with 1 also
cluster.initial_master_nodes: ["xxx.52"]

xxx.52 yml: #master node

cluster.name: monitoring
node.name: "es-master"
node.master: true
node.data: false

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

network.host: xxx.52
http.port: 9200

discovery.seed_hosts: ["xxx.52", "xxx.235"] #tried this instead as well discovery.zen.ping.unicast.hosts: 2
discovery.zen.minimum_master_nodes: 2 #tried with 1 also
cluster.initial_master_nodes: ["xxx.52"]

Things I tried but didn't help: Enabling 9200 and 9300 ports and testing them via telnet and connection is good and ports are open. Adding the line publish_host on both servers. Switching between seed_hosts and zen.ping.unicast.hosts.

Until I added the line node.master: false on the data node, it just got up but didn't connect to the right cluster, both nodes we're on their own separate clusters

1
Which version of elasticsearch are you running? The way to form a cluster is different in versions 6 and 7. Why did you set network.publish_host in your data node to the IP of your master node? Does your data node machine have another IP that ends in .52? Also, if those IPs are not public, you can share them in your question without problem.leandrojmp
Oh yeah, i forgot to mention that im using Elasticsearch 7. And network.publish_host was one of the answers I found online so gave it a try, as I mentioned below, but without any success.Pavle Ilic

1 Answers

0
votes

You are mixing configurations from version 6 and version 7, the discovery.zen.minimum_master_nodes option is ignored on version 7.

To form a cluster you need only the discovery.seed_hosts and cluster.initial_master_nodes.

The config for your master node should be:

cluster.name: monitoring
node.name: "es-master"
node.master: true
node.data: false

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

network.host: xxx.52
http.port: 9200

discovery.seed_hosts: ["xxx.52"]
cluster.initial_master_nodes: ["xxx.52"]

And for your data node:

cluster.name: monitoring
node.name: "es-data-node-2"
node.master: false
node.data: true

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

network.host: xxx.235
http.port: 9200

discovery.seed_hosts: ["xxx.52"]
cluster.initial_master_nodes: ["xxx.52"]

The discovery.seed_hosts is a list of master-eligible nodes, you only have one master-eligible node.

The cluster.initial_master_nodes is a list used only when you start the cluster in the first time, this determine the nodes whose votes will be counted in the virst election, also, you only have one master.

With these configurations your data node should join the cluster.