0

I am new to Elasticsearch and I want to set up a highly available Elasticsearch cluster on one machine to test and learn how to use Elasticsearch. I hope that when the master node fails, one of the other nodes will take over and become the master node. On my machine, I set up an Elasticsearch cluster consisting of 3 nodes, a master node and two data nodes, but when I stopped the master node, none of the other nodes took over and became the master node, here is my config for the three nodes (used version of elasticsearch is 7.9.2):

# master node config.

cluster.name:demo-cluster
node.name: "es-node-1"
node.master: true
node.data: false
discovery.zen.minimum_master_nodes: 2
#  data node 1 config.

cluster.name:demo-cluster
node.name: "es-node-2"
node.master: false
node.data: true
discovery.zen.minimum_master_nodes: 2
# data node 2 config.

cluster.name:demo-cluster
node.name: "es-node-3"
node.master: false
node.data: true
discovery.zen.minimum_master_nodes: 2

Does anyone have an idea please?

Ghiloufi
  • 311
  • 4
  • 10
  • If you want to try and explore elasticsearch for the first time I would suggest trying the hosted version of the company behind elasticsearch. Take the lowest machine type, in only one zone and the cost will be +/-€15 per month. This wil significantly ease out setting everything up. Furthermore you have the tools like Kibana available which are super easy to use to explore your cluster. https://www.elastic.co/pricing/ – Sam Mar 19 '21 at 13:23

1 Answers1

0

Only one of your nodes has the config node.master: true, so only this node is eligible to master, if this node fails you won't have another master and your cluster will not work.

You need to set all of your three nodes as node.master: true, this way if the master node fail the two remaining nodes in the cluster will choose who will be the new master.

Also, you are using version 7.X, in this version the discovery settings changed and discovery.zen.minimum_master_nodes is deprecated, you should use discovery.seed_hosts and cluster.initial_master_nodes, as described in the documentation.

discover.seed_hosts: ["es-node-1", "es-node-2", "es-node-3"]
cluster.initial_master_nodes: ["es-node-1", "es-node-2", "es-node-3"]

And for this to work all your nodes should have node.master: true in the config file. This will allow your cluster to work if you lose one node.

leandrojmp
  • 7,082
  • 2
  • 19
  • 24
  • What will happen if i lose two nodes because, I just checked if only one node keeps running my cluster will not be available anymore even though this node is both master and data. – Ghiloufi Mar 19 '21 at 15:18
  • That is right, if you have a three node cluster, you can only lose one node, if you lose another one your cluster will not be available. You need a minimun quorum of voting nodes to keep your cluster running, for a 3 nodes cluster, this number is 2. You can read more about the voting process in the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/modules-discovery-voting.html) – leandrojmp Mar 19 '21 at 15:49