Non-voting members allow you to add additional members for read distribution beyond the maximum seven voting members.
To configure a member as non-voting, use the
replSetReconfig command or its
mongo shell helper
rs.reconfig() to set its
members[n].priority values to
0. Non-voting replica set members must have a
Starting in MongoDB 4.4, replica reconfiguration can add or remove no
more than one voting replica set member at a time. To modify the
votes of multiple members, issue a series of
rs.reconfig() operations to
modify one member at a time. See
Reconfiguration Can Add or Remove No More than One Voting Member at a Time for more information.
The following procedure converts configures a single secondary
replica set member to be non-voting. To convert the primary
member to be non-voting, you must first successfully step the primary
replSetStepDown or its shell helper
rs.stepDown() before performing this procedure.
- 1) Connect to the Replica Set Primary
mongo --host "<hostname>:<port>"
<port>with the hostname and port of the replica set primary. Include any other parameters required for your deployment.
- 2) Retrieve the Replica Configuration
rs.conf()method in the shell and assign the result to a variable
cfg = rs.conf();
- 3) Configure the Member to be Non-Voting
cfg.members[n].votes = 0; cfg.members[n].priority = 0;
nwith the array index position of the member to modify. The
membersarray is zero-indexed, where the first element in the array has an index position of
The array index position of a member in the
membersarray is distinct from the
members[n]._idof a specific member. Do not use the
_idto reference the array index position of any any member in
- 4) Reconfigure the Replica Set with the New Configuration
rs.reconfig()method to reconfigure the replica set with the updated replica set configuration document.
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.