In some cases, for example if we have multiple data centers, we will want some of the members to never be able to become a primary server.
In a scenario with multiple data center replication, we may have our primary data center with one primary and one secondary based in the UK and a secondary server located in Russia. In this case, we don't want our Russia-based server to become primary as it would incur latency on our application servers based in the UK. In this case, we will set up our Russia-based server with priority 0.
Replica set members with priority 0 also can't trigger elections. In all other aspects they are identical to every other member in the replica set. To change the priority of a replica set member, we must first get the current replica set configuration by connecting via mongo shell to the primary server:
> cfg = rs.conf()
This will output the config document which contains configuration for every member in our replica set. In the members subdocument we can find the priority attribute which we have to set to 0:
> cfg.members[2].priority = 0
Finally, we need to reconfigure the replica set with the updated configuration:
rs.reconfig(cfg)