By now, you would have noticed the priority
keyword in the rs.status()
output. Replica set members with higher priorities are more likely to be elected as primaries. The value of a priority can range from 0
to 1000
, where 0
indicates a non-voting member. A non-voting member functions as a regular member of a replica set but cannot vote in elections nor get elected as a primary.
- Connect to the primary member of the replica set using the mongo shell:
mongo mongodb://192.168.200.200:27017
- Fetch the configuration:
conf = rs.conf()
- Change the priorities of all members:
conf['members'][0].priority = 5 conf['members'][1].priority = 2 conf['members'][2].priority = 2
- Reconfigure the replica set:
rs.reconfig(conf)
- Check the new configuration:
rs.conf()['members']