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操作。
maxCatchUpPercentageBeforeBlockingWritesStarting 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为单位)相比较。