- Sharding >
- Restore Sharded Clusters
Restore Sharded Clusters¶
Overview¶
The procedure outlined in this document addresses how to restore an entire sharded cluster. For information on related backup procedures consider the following tutorials which describe backup procedures in greater detail:
- Create Backup of a Sharded Cluster with Filesystem Snapshots
- Create Backup of a Sharded Cluster with Database Dumps
The exact procedure used to restore a database depends on the method used to capture the backup. See the Backup Strategies for MongoDB Systems document for an overview of backups with MongoDB, as well as Sharded Cluster Backup Considerations which provides an overview of the high level concepts important for backing up sharded clusters.
Procedure¶
If shard hostnames have changed, you must manually update the
shards
collection in the Config Database Contents to use the new hostnames. Do the following:Start the three config servers by issuing commands similar to the following, using values appropriate to your configuration:
Restore the Config Database Contents on each config server.
Start one
mongos
instance.Update the Config Database Contents collection named
shards
to reflect the new hostnames.
Restore the following:
- Data files for each server in each shard. Because replica sets provide each production shard, restore all the members of the replica set or use the other standard approaches for restoring a replica set from backup. See the Restore a Snapshot and Restore a Database with mongorestore sections for details on these procedures.
- Data files for each config server, if you have not already done so in the previous step.
Restart all the
mongos
instances.Restart all the
mongod
instances.Connect to a
mongos
instance from amongo
shell and use thedb.printShardingStatus()
method to ensure that the cluster is operational, as follows: