Allow secondary to recover. Wait for the member to recover to SECONDARY state before upgrading the next sec- ondary. 

To check the member’s state, use the rs.status() method in the mongo shell. 

Step 2: Step down the primary. Use rs.stepDown() in the mongo shell to step down the primary and force the normal failover (page 580) procedure. 

rs.stepDown() 

rs.stepDown() expedites the failover procedure and is preferable to shutting down the primary directly. 

Step 3: Replace and restart former primary mongod . When rs.status() shows that the primary has stepped down and another member has assumed PRIMARY state, shut down the previous primary and replace the mongod binary with the 2.4 binary and start the new instance. 

Replica set failover is not instant but will render the set unavailable to writes and interrupt reads until the failover pro- cess completes. Typically this takes 10 seconds or more. You may wish to plan the downgrade during a predetermined maintenance window. 

## Downgrade a 2.6 Sharded Cluster 

Requirements While the downgrade is in progress, you cannot make changes to the collection meta-data. For example, during the downgrade, do not do any of the following: 

• sh.enableSharding() 

• sh.shardCollection() 

• sh.addShard() 

• db.createCollection() 

• db.collection.drop() 

• db.dropDatabase() 

• any operation that creates a database 

• any other operation that modifies the cluster meta-data in any way. See Sharding Reference (page 736) for a com- plete list of sharding commands. Note, however, that not all commands on the Sharding Reference (page 736) page modifies the cluster meta-data. 

Procedure The downgrade procedure for a sharded cluster reverses the order of the upgrade procedure. 

1. Turn off the balancer (page 684) in the sharded cluster, as described in Disable the Balancer (page 717). 

2. Downgrade each shard, one at a time. For each shard, 

(a) Downgrade the mongod secondaries before downgrading the primary. 

(b) To downgrade the primary, run replSetStepDown and downgrade. 

3. Downgrade all 3 mongod config server instances, leaving the first system in the mongos --configdb argument to downgrade last . 

4. Downgrade and restart each mongos , one at a time. The downgrade process is a binary drop-in replacement. 

5. Turn on the balancer, as described in Enable the Balancer (page 718). 

