Mongodb replicates elections when all nodes are set to next priority

What will be the priority in the mongodb replica selection process - priority or votes? I mean, if I have a consistent priority set across all member nodes of a replica-set, will it ever get stuck?

For example, if I have a mongodb replicator with 4 nodes and no arbiter. They all have a set of priorities, for example node01 has 25, node02 has 20, node03 has 15, and node04 has 10.

Is there a possibility of a deadlock in the electoral process in the above case?

+3


source to share


2 answers


In a given replica set with 4 nodes and their corresponding priority: => node1: 25, node2: 20, node3: 15, node4: 10. Let's say node1 (the primary, with the highest priority) is down, then elections will be initiated and node2 will be selected as the next primary (in order of priority), provided it receives votes from the majority of the replica set members. Even theoretically, there is no way to get to a dead end. Setting non-defaut priority values ​​for a replica set of a node can be useful when you want a node to be the preferred "master" node during elections / failover.



Note. Since v2.6 from mongoDB each valid node can only vote once.

+2


source


Voices and priority are two different things. The Mongon needs more than 50% of the votes to choose the primary, if we have less than 50% of the votes, then all the living nodes become secondary.

Prioritizing a replica set ensures that members with a higher priority become more primary than others with a lower priority.

Node1: 25> Node2: 20> Node3: 15> Node4: 10 is the sequence of your primaries.

Note:

  • you can set the priority between 0 and 1000.
  • you can only have 7 voting members in the replica cluster. Set the additional voices to 0.


And questions for you:

What will be the priority in the morgodb replicaset electoral process - priority or votes?

Ans: vote

I mean, if I have a consistent priority set across all member nodes of a replica-set, will it ever get stuck? Ans: Never.

0


source







All Articles