Adjust Priority for Replica Set Member
On this page
priority settings of replica set members affect both the timing
and the outcome of elections for
primary. Higher-priority members are more likely to call elections, and
are more likely to win. Use this setting to ensure that some members are
more likely to become primary and that others can never become primary.
The value of the member's
priority setting determines the
priority in elections. The higher the number,
the higher the priority.
To modify priorities, you update the
array in the replica configuration object. The array index begins with
0. Do not confuse this index value with the value of the replica
members[n]._id field in the
The value of
priority can be any
floating point (i.e. decimal) number between
default value for the
priority field is
To block a member from seeking election as primary, assign it a priority
0. Hidden members and
delayed members have
priority set to
Arbiters have priority
Adjust priority settings during a scheduled maintenance window. Reconfiguring priority can force the current primary to step down, leading to an election. Before an election, the primary closes all open client connections.
Priority and Votes
have the following relationship:
0) members must have
As such, increasing a non-voting member's
1 and increases
the number of voting replica set members. Before increasing the
priority of a non-voting member, consider the following:
MongoDB replica sets can have no more than 7 voting members. If the replica set already has 7 voting members, you cannot modify the priority of any remaining members in the replica set to be greater than
Starting in MongoDB 4.4, replica reconfiguration can add or remove no more than one voting member at a time. To change multiple non-voting members to have a priority greater than
0, 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.
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.
Change each member's priority value.
Change each member's
value, as configured in the
cfg.members.priority = 0.5 cfg.members.priority = 2 cfg.members.priority = 2
This sequence of operations modifies the value of
cfg to set the
priority for the first three members defined in the
Assign the replica set the new configuration.
rs.reconfig() to apply the new configuration.
This operation updates the configuration of the replica set using
the configuration defined by the value of