Typically, you should use a shard balancing window to specify when the balancer runs instead of manually starting and stopping defragmentation.通常,您应该使用分片平衡窗口来指定平衡器何时运行,而不是手动启动和停止分片整理。
To manually stop defragmenting a sharded collection, use the 要手动停止对分片集合进行分片整理,请使用configureCollectionBalancing command with the defragmentCollection option set to false.configureCollectionBalancing命令,并将defragmentCollection选项设置为false。
About this Task关于此任务
The procedure in this task uses an example sharded collection named 此任务中的过程在名为ordersShardedCollection in a database named test.test的数据库中使用名为ordersShardedCollection的示例分片集合。
You can use your own sharded collection and database in the procedure.您可以在过程中使用自己的分片集合和数据库。
If you stop defragmenting a collection before defragmentation is complete, the collection is in a partially defragmented state and operates as usual. To resume defragmentation, restart the process.如果在分片整理完成之前停止对集合进行分片整理,则该集合处于部分分片整理状态,并照常运行。要恢复分片整理,请重新启动该进程。
Before you Begin开始之前
Start defragmenting a sharded collection. For details, see Start Defragmenting a Sharded Collection.开始对分片集合进行分片整理。有关详细信息,请参阅开始对分片集合进行分片整理。Connect to连接到mongos.mongos。
Procedure过程
Stop defragmenting the collection停止对集合进行分片整理
Run:运行:
db.adminCommand(
{
configureCollectionBalancing: "test.ordersShardedCollection",
defragmentCollection: false
}
)Ensure defragmentation stopped确保分片整理已停止
When defragmentation stops, the command output returns 当分片整理停止时,命令输出返回ok: 1:ok: 1:
{
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1678834337, i: 1 }),
signature: {
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
keyId: Long("0")
}
},
operationTime: Timestamp({ t: 1678834337, i: 1 })
}Next Steps后续步骤
You can start defragmentation again at any time. For details, see Start Defragmenting a Sharded Collection.您可以随时重新开始分片整理。有关详细信息,请参阅开始对分片集合进行分片整理。
Learn More了解更多
Start defragmenting a sharded collection开始对分片集合进行分片整理Monitor defragmentation of a sharded collection监视分片集合的分片整理
Print shard status, see打印分片状态,请参阅db.printShardingStatus()Retrieve shard status details, see检索分片状态详细信息,请参阅sh.status()View shard status collection fields, see查看分片状态集合字段,请参阅Sharded Collection分片集合See active mongos instances, see Active查看活动mongosInstancesmongos实例,查看活动mongos实例Monitor shards using MongoDB Atlas, see Review Sharded Clusters使用MongoDB Atlas监控分片,请参阅查看分片集群