moveChunk

moveChunk

moveChunk is an internal administrative command that moves chunks between shards. You must issue the moveChunk command via a mongos instance while using the admin database in the following form:

db.runCommand( { moveChunk : <namespace> ,
                 find : <query> ,
                 to : <destination>,
                 <options> } )
Parameters:
  • moveChunk (string) – The name of the collection where the chunk exists. Specify the collection’s full namespace, including the database name.
  • find (document) –

    A document that specifies an equality match on the shard key that will move the chunk that contains the specified shard-key value.

    You may specify either bounds or find but not both.

  • bounds (array) –

    Specify the bounds of a specific chunk to move. The array must consist of two documents specifying the lower and upper shard key values of a chunk to move.

    You may specify either bounds or find but not both.

    Use bounds to move chunks in collections partitioned using a hashed shard key.

  • to (string) – The name of the destination shard for the chunk.
  • _secondaryThrottle (boolean) – Optional; true by default. When 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).

The chunk migration section describes how chunks move between shards on MongoDB.

moveChunk returns the following message if another metadata operation is in progress chunks collection:

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

If another process, such as a balancer process, changes meta data while moveChunk is running, you may see this error. You may retry the moveChunk operation without side effects.

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. In most cases allow the balancer to create and balance chunks in sharded clusters. See Create Chunks (Pre-Splitting) for more information.

MongoDB Manual 2.4

Formats

About MongoDB

MongoDB Ecosystem

MongoDB Resources