rs.add("mongodb1.example.net") rs.add("mongodb2.example.net") rs.add("mongodb3.example.net") 

When complete, you should have a fully functional replica set. The new replica set will elect a primary . 

Step 6: Add the arbiter. In the same shell session, issue the following command to add the arbiter (e.g. mongodb4.example.net ): 

rs.addArb("mongodb4.example.net") 

Step 7: Configure outside members as priority 0 members . Configure each member located outside of Site A (e.g. mongodb3.example.net ) as a priority 0 member (page 567). 

1. View the replica set configuration to determine the members array position for the member. Keep in mind the array position is not the same as the _id : 

rs.conf() 

2. Copy the replica set configuration object to a variable (to cfg in the example below). Then, in the variable, set the correct priority for the member. Then pass the variable to rs.reconfig() to update the replica set configuration. 

For example, to set priority for the third member in the array (i.e., the member at position 2), issue the following sequence of commands: 

cfg = rs.conf() cfg.members[2].priority = 0 rs.reconfig(cfg) 

Note: The rs.reconfig() shell method can force the current primary to step down, causing an election. When the primary steps down, all clients will disconnect. This is the intended behavior. While most elec- tions complete within a minute, always make sure any replica configuration changes occur during scheduled maintenance periods. 

After these commands return, you have a geographically redundant four-member replica set. 

Deploy a Geographically Redundant Set with More than Four Members The above procedures detail the steps necessary for deploying a geographically redundant replica set. Larger replica set deployments follow the same steps, but have additional considerations: 

• Never deploy more than seven voting members. 

• If you have an even number of members, use the procedure for a four-member set (page 611)). Ensure that a single facility, “Site A”, always has a majority of the members by deploying the arbiter in that site. For example, if a set has six members, deploy at least three voting members in addition to the arbiter in Site A, and the remaining members in alternate sites. 

• If you have an odd number of members, use the procedure for a three-member set (page 609). Ensure that a single facility, “Site A” always has a majority of the members of the set. For example, if a set has five members, deploy three members within Site A and two members in other facilities. 

• If you have a majority of the members of the set outside of Site A and the network partitions to prevent com- munication between sites, the current primary in Site A will step down, even if none of the members outside of Site A are eligible to become primary. 

