Force a Master Node to be the primary


(Luís Ricardo da Costa Carvalho) #1

Hi!

I would like to know if there is any way/configuration that forces a Master Node to be the primary, even when a secondary Master Node already was elected to be the Master of the cluster. A configuration that verifies when the primary Master Node is up again and elect him as the Master of the cluster.

Thanks,
Luís Carvalho


(Christoph) #2

Hi,

there seems to be some confusion of the concept of a shard and a node here. "Master" is a role a node can take. On the other hand, "primary" and "replica" are different types of a shard, which is a logical partitioning of the all the data in an index. There is always just one master node at each time, it manages the overall cluster state. The cluster can contain multiple indices, each having a number or shards which again can serve as "primary" or "replica".


(Christian Dahlqvist) #3

In Elasticsearch you should always aim to have 3 master eligible nodes (or in some scenarios more than 3). One of these will at any point be the master while the others are ready to step in and elect a new one should this fail as the remaining two nodes can determine that they are in majority. You can not control which one is master at any time. With only two master eligible nodes, both nodes are required in order to form a majority, and if the master goes down, a new master may not be elected until it comes back up.


(Luís Ricardo da Costa Carvalho) #4

Hi Christoph,

Sorry for my bad explanations, I know the concept of a shard and a node in Elasticsearch. What I have in my cluster, beyond Data Nodes, is 3 nodes with Master role. One of them only have the Master role, and the other 2 can be Master and Data.

What I pretend is when the node with only Master role comes back up after losing connectivity to the cluster, he become the new Master, making the current Master back to Data role.

Thanks for your help.


(Christoph) #5

Hi,

The only way to remove a master from it's position is to restart it. There is a recent discussion of this in this Github issue. Can you explain why you want the master to be the same node as before?


(Luís Ricardo da Costa Carvalho) #6

I want that because, as I said before unlike the other nodes that node only have the Master role. So if he isn't the Master of the cluster it is a node that does nothing on the Elasticsearch cluster.

Thank you for your help.


(Kimbro Staken) #7

Even if the node isn't the active master it is still there to participate in any master elections and potentially become the new master in the future. What you're doing is a little bit of an odd architecture. If all 3 nodes are the same you may as well put data on all of them or if that third master is a smaller node or something then just be happy with its role of filling out the quorum so you can keep an HA setup.

Kimbro


(system) #8