Configure Non-Voting Replica Set Member¶
Non-voting members allow you to add additional members for read distribution beyond the maximum seven voting members.
The following example configures the fourth, fifth, and sixth replica set members to be non-voting members.
cfg = rs.conf();
The returned document contains a
membersfield which contains an zero-indexed array of member configuration documents, one document for each member of the replica set.
cfg.members.votes = 0; cfg.members.priority = 0; cfg.members.votes = 0 cfg.members.priority = 0; cfg.members.votes = 0 cfg.members.priority = 0;
rs.reconfig()method to reconfigure the replica set with the updated replica set configuration document.
Place voting members so that your designated primary or primaries can reach a majority of votes in the event of a network partition.
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
rs.reconfig()shell method can force the current primary to step down, which causes an election. When the primary steps down, the
mongodcloses 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.
In general and when possible, all members should have only 1 vote. This
prevents intermittent ties, deadlocks, or the wrong members from
becoming primary. Use
to control which members are more likely to become primary.