- Reference >
mongoShell Methods >- Sharding Methods >
- sh.moveChunk()
sh.moveChunk()¶
On this page
Definition¶
-
sh.moveChunk(namespace, query, destination)¶ Moves the chunk that contains the document specified by the
queryto thedestinationshard.sh.moveChunk()provides a wrapper around themoveChunkdatabase command and takes the following arguments:Parameter Type Description namespacestring The namespace of the sharded collection that contains the chunk to migrate. querydocument An equality match on the shard key that selects the chunk to move. destinationstring The name of the shard to move. Important
In most circumstances, allow the balancer to automatically migrate chunks, and avoid calling
sh.moveChunk()directly.
See also
moveChunk, sh.splitAt(),
sh.splitFind(), Sharding, and chunk
migration.
Example¶
Given the people collection in the records database, the
following operation finds the chunk that contains the documents with the
zipcode field set to 53187 and then moves that chunk to the
shard named shard0019: