- Reference >
- Database Commands >
- moveChunk
moveChunk¶
-
moveChunk¶ moveChunkis an internal administrative command that moves chunks between shards. You must issue themoveChunkcommand 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
falseby 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 themongoshell to migrate chunks manually.The chunk migration section describes how chunks move between shards on MongoDB.
moveChunkwill 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
moveChunkin 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.