sh.moveChunk()
Definition
sh.
moveChunk
(namespace, query, destination)- Moves the chunk that contains the document specified by the
query
to thedestination
shard.sh.moveChunk()
provides a wrapper around themoveChunk
databasecommand and takes the following arguments:
ParameterTypeDescriptionnamespace
stringThe namespace of the sharded collection that contains thechunk to migrate.query
documentAn equality match on the shard key that selects the chunk to move.destination
stringThe name of the shard to move.
Important
In most circumstances, allow the balancer toautomatically migrate chunks, and avoid callingsh.moveChunk()
directly.
See also
moveChunk
, sh.splitAt()
,sh.splitFind()
, Sharding, and chunkmigration.
Example
Given the people
collection in the records
database, thefollowing operation finds the chunk that contains the documents with thezipcode
field set to 53187
and then moves that chunk to theshard named shard0019
:
- sh.moveChunk("records.people", { zipcode: "53187" }, "shard0019")