Navigation
This version of the manual is no longer supported.

moveChunk

moveChunk

moveChunk is an internal administrative command that moves chunks between shards. You must issue the moveChunk command against the admin database in the form:

db.runCommand( { moveChunk : <namespace> ,
                 find : <query> ,
                 to : <destination>,
                 <options> } )
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 to true, 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 the mongo 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:

errmsg: "The collection's metadata lock is already taken."

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.