The value of the member’s priority setting determines the member’s priority in elections. The higher the number, the higher the priority. 

## Considerations 

To modify priorities, you update the members array in the replica configuration object. The array index begins with 0 . Do not confuse this index value with the value of the replica set member’s _id field in the array. 

The value of priority can be any floating point (i.e. decimal) number between 0 and 1000 . The default value for the priority field is 1 . 

To block a member from seeking election as primary, assign it a priority of 0 . Hidden members (page 569), delayed members (page 570), and arbiters (page ?? ) all have priority set to 0 . 

Adjust priority 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. 

## Procedure 

Step 1: Copy the replica set configuration to a variable. In the mongo shell, use rs.conf() to retrieve the replica set configuration and assign it to a variable. For example: 

cfg = rs.conf() 

Step 2: Change each member’s priority value. Change each member’s priority value, as configured in the members array. 

cfg.members[0].priority = 0.5 cfg.members[1].priority = 2 cfg.members[2].priority = 2 

This sequence of operations modifies the value of cfg to set the priority for the first three members defined in the members array. 

Step 3: Assign the replica set the new configuration. Use rs.reconfig() to apply the new configuration. 

rs.reconfig(cfg) 

This operation updates the configuration of the replica set using the configuration defined by the value of cfg . 

## Prevent Secondary from Becoming Primary 

## Overview 

In a replica set, by default all secondary members are eligible to become primary through the election process. You can use the priority to affect the outcome of these elections by making some members more likely to become primary and other members less likely or unable to become primary. 

Secondaries that cannot become primary are also unable to trigger elections. In all other respects these secondaries are identical to other secondaries. 

To prevent a secondary member from ever becoming a primary in a failover , assign the secondary a priority of 0 , as described here. For a detailed description of secondary-only members and their purposes, see Priority 0 Replica Set Members (page 567). 

