On this page本页内容
sh.
moveChunk
(namespace, query, destination)¶Moves the chunk that contains the document specified by the query
to the destination
shard. sh.moveChunk()
provides a wrapper around the moveChunk
database command.
Important
In most circumstances, allow the balancer to automatically migrate chunks, and avoid calling sh.moveChunk()
directly.
sh.moveChunk()
takes the following arguments:
namespace |
string | The namespace of the sharded collection that contains the chunk to migrate. |
query |
document | An equality match on the shard key that selects the chunk to move. |
destination |
string | The name of the shard to move. |
By default, MongoDB cannot move a chunk if the number of documents in the chunk is greater than 1.3 times the result of dividing the configured chunk size by the average document size. Starting in MongoDB 4.4, the moveChunk
command can specify a new option forceJumbo to allow for the manual migration of chunks too large to move, with or without the jumbo label. See moveChunk command for details.
See also参阅
moveChunk
, sh.splitAt()
, sh.splitFind()
, Sharding, and chunk migration.
Given the people
collection in the records
database, the following operation finds the chunk that contains the documents with the zipcode
field set to 53187
and then moves that chunk to the shard named shard0019
: