On this page本页内容
sh.moveChunk(namespace, query, destination)
Moves the chunk that contains the document specified by the 将包含query to the destination shard. query指定的文档的区块移动到destination分片。sh.moveChunk() provides a wrapper around the 提供了moveChunk database command.moveChunk数据库命令的包装。
In most circumstances, allow the balancer to automatically migrate chunks, and avoid calling 在大多数情况下,允许平衡器自动迁移块,并避免直接调用sh.moveChunk() directly.sh.moveChunk()。
sh.moveChunk() takes the following arguments:采用以下参数:
namespace | string | |
query | document | |
destination | string |
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. 默认情况下,如果区块中的文档数大于配置区块大小除以平均文档大小所得结果的1.3倍,则MongoDB无法移动区块。Starting in MongoDB 4.4, the 从MongoDB 4.4开始,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. moveChunk命令可以指定一个新选项forceJumbo,以允许手动迁移太大而无法移动的块,无论是否使用jumbo标签。See moveChunk command for details.有关详细信息,请参阅moveChunk命令。
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:records数据库中的people集合,以下操作将查找包含zipcode字段设置为53187的文档的区块,然后将该区块移动到名为shard0019的分片:
sh.moveChunk("records.people", { zipcode: "53187" }, "shard0019")