- Reference >
- Database Commands >
- Sharding Commands >
- removeShard
removeShard¶
-
removeShard
¶ Starts the process of removing a shard from a cluster. This is a multi-stage process. Begin by issuing the following command:
The balancer will then migrate chunks from the shard specified by
[shardName]
. This process happens slowly to avoid placing undue load on the overall cluster.The command returns immediately, with the following message:
If you run the command again, you’ll see the following progress output:
The
remaining
document specifies how many chunks and databases remain on the shard. Usedb.printShardingStatus()
to list the databases that you must move from the shard.Each database in a sharded cluster has a primary shard. If the shard you want to remove is also the primary of one of the cluster’s databases, then you must manually move the database to a new shard. This can be only after the shard is empty. See the
movePrimary
command for details.After removing all chunks and databases from the shard, you may issue the command again, to return: