Restore a Sharded Cluster with Database Dumps Changed in version 3.0: mongorestore requires a running MongoDB instances. Earlier versions of mongorestore did not require a running MongoDB instances and instead used the --dbpath option. For instructions specific to your version of mongorestore , refer to the appropriate version of the manual. 

The following procedure outlines the steps to restore a sharded cluster from the BSON database dumps created by mongodump . For information on using mongodump to backup sharded clusters, see Backup a Sharded Cluster with Database Dumps (page 258) 

The procedure deploys a new sharded cluster and restores data from database dumps. 

Step 1: Deploy a new replica set for each shard. For each shard, deploy a new replica set: 

1. Start a new mongod for each member of the replica set. Include any other configuration as appropriate. 

2. Connect a mongo to one of the mongod instances. In the mongo shell: 

For detailed instructions on deploying a replica set, see Deploy a Replica Set (page 603). 

(a) Run rs.initiate() . 

(b) Use rs.add() to add the other members of the replica set. 

Step 2: Deploy three new config servers. Start three mongod instances for the config servers (i.e. mongod --configsvr ). Include any other configuration as appropriate. 

For detailed instructions on setting up the config servers, see Start the Config Server Database Instances (page 691). 

Step 3: Start the mongos instances. Start the mongos instances, specifying the new config servers with --configdb . Include any other configuration as appropriate. 

For detailed instructions on starting the mongos instances for a sharded cluster, see Start the mongos Instances (page 692). 

Step 4: Add shards to the cluster. Connect a mongo shell to a mongos instance. Use sh.addShard() to add each replica sets as a shard. 

For detailed instructions in adding shards to the cluster, see Add Shards to the Cluster (page 692). 

Step 5: Shut down the mongos instances. Once the new sharded cluster is up, shut down all mongos instances. 

Step 6: Restore the shard data. For each shard, use mongorestore to restore the data dump to the primary’s data directory. Include the --drop option to drop the collections before restoring and, because the backup procedure (page 258) included the --oplog option, include the --oplogReplay option for mongorestore . 

For example, on the primary for ShardA, run the mongorestore . Specify any other configuration as appropriate. 

mongorestore --drop --oplogReplay /data/dump/shardA 

After you have finished restoring all the shards, shut down all shard instances. 

## 262 

## Chapter 5. Administration 

