- Reference >
- Database Commands >
- Sharding Commands >
- moveChunk
moveChunk¶
On this page
Definition¶
-
moveChunk
¶ Internal administrative command. Moves chunks between shards. Issue the
moveChunk
command via amongos
instance while using the admin database. Use the following forms:Alternately:
The
moveChunk
command has the following fields:Field Type Description moveChunk
string The namespace of the collection where the chunk exists. Specify the collection’s full namespace, including the database name. find
document An equality match on the shard key that specifies the shard-key value of the chunk to move. Specify either the bounds
field or thefind
field but not both. Do not use thefind
field to select chunks in collections that use a hashed shard key.bounds
array The bounds of a specific chunk to move. The array must consist of two documents that specify the lower and upper shard key values of a chunk to move. Specify either the bounds
field or thefind
field but not both. Usebounds
to select chunks in collections that use a hashed shard key.to
string The name of the destination shard for the chunk. _secondaryThrottle
Boolean Optional. Defaults to false
. Whentrue
, the balancer waits for replication to secondaries when it copies and deletes data during chunk migrations. For details, see Change Replication Behavior for Chunk Migration (Secondary Throttle)._waitForDelete
Boolean Optional. Internal option for testing purposes. The default is false
. If set totrue
, the delete phase of amoveChunk
operation blocks.The value of
bounds
takes the form:The chunk migration section describes how chunks move between shards on MongoDB.
See also
Return Messages¶
moveChunk
returns the following error message if another
metadata operation is in progress on the chunks
collection:
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 in a Sharded Cluster for more information.