MongoDB Documentation, Release 3.0.4 Move Unsharded Data If the shard is the primary shard for one or more databases in the cluster, then the shard will have unsharded data. If the shard is not the primary shard for any databases, skip to the next task, Finalize the Migration (page 721). In a cluster, a database with unsharded collections stores those collections only on a single shard. That shard becomes the primary shard for that database. (Different databases in a cluster can have different primary shards.) Warning: Do not perform this procedure until you have finished draining the shard. In the resulting document, the databases field lists each database and its primary shard. For example, the following database field shows that the products database uses mongodb0 as the primary shard: db.runCommand( { movePrimary: "products", to: "mongodb1" }) This command does not return until MongoDB completes moving all data, which may take a long time. The response from this command will resemble the following: { "primary" : "mongodb1", "ok" : 1 } To clean up all metadata information and finalize the removal, run removeShard again. For example, for a shard named mongodb0 , run: use admin db.runCommand( { removeShard: "mongodb0" } ) A success message appears at completion: Once the value of the state field is “completed”, you may safely stop the processes comprising the mongodb0 shard. { "msg" : "removeshard completed successfully", "state" : "completed", "shard" : "mongodb0", "ok" : 1 } See also: Finalize the Migration 2. To move a database to another shard, use the movePrimary command. For example, to migrate all remaining unsharded data from mongodb0 to mongodb1 , issue the following command: 1. To determine if the shard you are removing is the primary shard for any of the cluster’s databases, issue one of the following methods: • sh.status() • db.printShardingStatus() { "_id" : "products", "partitioned" : true , "primary" : "mongodb0" } Backup and Restore Sharded Clusters (page 254) 721 10.3. Sharded Cluster Tutorials