On this page
Configure Non-Voting Replica Set Member
On this page
Non-voting members allow you to add additional members for read distribution beyond the maximum seven voting members.
Important
To configure a member as non-voting, set both its votes and priority values to 0.
Example
The following example configures the fourth, fifth, and sixth replica set members to be non-voting members.
In a
mongoshell connected to a primary, run thers.conf()method and assign the result to a variable:cfg = rs.conf();The returned document contains a
membersfield which contains a zero-indexed array of member configuration documents, one document for each member of the replica set.To configure the fourth, fifth, and sixth replica set members to be non-voting, use the following command sequence to set both their
members[n].votesandmembers[n].priorityvalues to0.cfg.members[3].votes = 0; cfg.members[3].priority = 0; cfg.members[4].votes = 0 cfg.members[4].priority = 0; cfg.members[5].votes = 0 cfg.members[5].priority = 0;Use
rs.reconfig()method to reconfigure the replica set with the updated replica set configuration document.rs.reconfig(cfg);
Place voting members so that the mongod instance or instances that you wish to serve as primary can reach a majority of votes in the event of a network partition.
Use members[n].priority to control which members are more likely to become primary.
When updating the replica configuration object, access the replica set members in the members array with the array index. The array index begins with 0. Do not confuse this index value with the value of the members[n]._id field in each document in the members array.
Warning
- The
rs.reconfig()shell method can force the current primary to step down, which causes an election. When the primary steps down, themongodcloses all client connections. While this typically takes 10-20 seconds, try to make these changes during scheduled maintenance periods. - Avoid reconfiguring replica sets that contain members of different MongoDB versions as validation rules may differ across MongoDB versions.