- Reference >
- Database Commands >
- moveChunk
moveChunk¶
-
moveChunk
¶ moveChunk
is an internal administrative command that moves chunks between shards. You must issue themoveChunk
command against the admin database in the form:Parameters: - moveChunk (namespace) – The name of the collection where the chunk exists. Specify the collection’s full namespace, including the database name.
- find (document) – A document including the shard key.
- to (host) – The identifier of the shard, that you want to migrate the chunk to.
- _secondaryThrottle (boolean) – Optional. Set to
false
by default. If set totrue
, the balancer waits for replication to secondaries while copying and deleting data during migrations. For details, see Require Replication before Chunk Migration (Secondary Throttle).
Use the
sh.moveChunk()
helper in themongo
shell to migrate chunks manually.The chunk migration section describes how chunks move between shards on MongoDB.
moveChunk
will return the following if another cursor is using the chunk you are moving:These errors usually occur when there are too many open cursors accessing the chunk you are migrating. You can either wait until the cursors complete their operation or close the cursors manually.
Note
Only use the
moveChunk
in special circumstances such as preparing your sharded cluster for an initial ingestion of data, or a large bulk import operation. See Create Chunks (Pre-Splitting) for more information.