On this page本页内容
moveChunk
Internal administrative command. Moves chunks between shards. 内部管理命令。在分片之间移动块。Issue the 使用moveChunk
command via a mongos
instance while using the admin database. admin
数据库时,通过mongos
实例发出moveChunk
命令。Use the following forms:使用以下表格:
db.adminCommand( { moveChunk : <namespace> , find : <query> , to : <string>, forceJumbo: <boolean>, // Starting in MongoDB 4.4 _secondaryThrottle : <boolean>, writeConcern: <document>, _waitForDelete : <boolean> } )
Alternatively:或者:
db.adminCommand( { moveChunk : <namespace> , bounds : <array> , to : <string>, forceJumbo: <boolean>, // Starting in MongoDB 4.4 _secondaryThrottle : <boolean>, writeConcern: <document>, _waitForDelete : <boolean> } )
The moveChunk
command has the following fields:moveChunk
命令具有以下字段:
moveChunk | string | |
find | document | bounds field or the find field but not both. bounds 字段或find 字段,但不能同时指定两者。find field to select chunks in collections that use a hashed shard key. find 字段来选择集合中使用哈希分片键的块。 |
bounds | array | bounds field or the find field but not both. bounds 字段或find 字段,但不能同时指定两者。bounds to select chunks in collections that use a hashed shard key. bounds 选择集合中使用哈希分片键的块。 |
to | string | |
forceJumbo | boolean |
|
_secondaryThrottle | boolean |
|
writeConcern | document |
|
_waitForDelete | boolean | false . false 。true , the delete phase of a moveChunk operation blocks. true ,moveChunk 操作的删除阶段将停止。 |
The value of bounds
takes the form:bounds
值的形式为:
[ { hashedField : <minValue> } , { hashedField : <maxValue> } ]
The chunk migration section describes how chunks move between shards on MongoDB.块迁移部分描述了块如何在MongoDB上的分片之间移动。
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. moveChunk
,例如准备分片化集群以进行初始数据摄取或大规模导入操作。In most cases allow the balancer to create and balance chunks in sharded clusters. 在大多数情况下,允许平衡器在分片集群中创建和平衡块。See Create Chunks in a Sharded Cluster for more information.有关详细信息,请参阅在分片集群中创建块。
moveChunk
requires that all indexes exist on the target (i.e. 要求在迁移之前目标(即to
) shard before migration and returns an error if a required index does not exist.to
)分片上存在所有索引,如果不存在所需索引,则返回错误。
如果moveChunk
returns the following error message if another metadata operation is in progress on the chunks
collection:chunks
集合上正在进行另一个元数据操作,moveChunk
将返回以下错误消息:
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. moveChunk
运行时更改元数据,则可能会看到此错误。You may retry the 您可以在没有副作用的情况下重试moveChunk
operation without side effects.moveChunk
操作。
maxCatchUpPercentageBeforeBlockingWrites
Starting in MongoDB 5.0 (and 4.4.7, 4.2.15, 4.0.26), you can set the 从MongoDB 5.0(和4.4.7、4.2.15、4.0.26)开始,您可以设置maxCatchUpPercentageBeforeBlockingWrites
to specify the maximum allowed percentage of data not yet migrated during a moveChunk
operation when compared to the total size (in MBs) of the chunk being transferred.maxCatchUpPercentageBeforeBlockingWrites
,以指定在moveChunk
操作期间未迁移的数据的最大允许百分比,与正在传输的区块的总大小(以MB为单位)相比较。