On this page本页内容
cleanupOrphaned Changed in version 4.4.在版本4.4中更改。
Starting in MongoDB 4.4, chunk migrations and orphaned document cleanup are more resilient to failover. 从MongoDB 4.4开始,区块迁移和孤立文档清理对故障切换更有弹性。The cleanup process automatically resumes in the event of a failover. 发生故障切换时,清理过程将自动恢复。You no longer need to run the 您不再需要运行cleanupOrphaned command to clean up orphaned documents. cleanupOrphaned命令来清理孤立文档。Instead, use this command to wait for orphaned documents in a chunk range from a shard key's minKey to its maxKey for a specified namespace to be cleaned up from a majority of a shard's members.相反,使用此命令等待从分片键的minKey到其maxKey的块范围内的孤立文档,以便从分片的大多数成员中清除指定的命名空间。
In MongoDB 4.2 and earlier, 在MongoDB 4.2和更早版本中,cleanupOrphaned initiated the cleanup process for orphaned documents in a specified namespace and shard key range.cleanupOrphaned启动了指定命名空间和分片键范围内孤立文档的清理过程。
To run, issue 要运行,请直接在作为分片的主要副本集成员的cleanupOrphaned in the admin database directly on the mongod instance that is the primary replica set member of the shard. mongod实例上的admin数据库中发出cleanupOrphaned。You do not need to disable the balancer before running 在运行cleanupOrphaned.cleanupOrphaned之前,不需要禁用平衡器。
Do not run 不要在cleanupOrphaned on a mongos instance.mongos实例上运行cleanupOrphaned。
cleanupOrphaned has the following syntax:具有以下语法:
db.runCommand( {
cleanupOrphaned: "<database>.<collection>",
startingFromKey: <minimumShardKeyValue>, // deprecated
secondaryThrottle: <boolean>, // deprecated
writeConcern: <document> // deprecated
} )
cleanupOrphaned has the following fields:具有以下字段:
cleanupOrphaned | string | |
startingFromKey | document |
|
secondaryThrottle | boolean | |
writeConcern | document | { writeConcern: { w: "majority" } }) before the cleanupOrphaned command returns a response. cleanupOrphaned命令返回响应之前,始终从分片的大多数成员({ writeConcern: { w: "majority" } })中清除孤立文档。 |
Starting in MongoDB 4.4, the value of this field is not used to determine the bounds of the cleanup range. 从MongoDB 4.4开始,此字段的值不用于确定清理范围的边界。The cleanupOrphaned command waits until all orphaned documents in all ranges in the namespace are cleaned up from the shard before completing, regardless of the presence of or value of startingFromKey.cleanupOrphaned命令等待直到命名空间中所有范围内的所有孤立文档在完成之前从分片中清除,而不管startingFromKey是否存在或值如何。
On systems running with 在authorization, you must have clusterAdmin privileges to run cleanupOrphaned.authorization运行的系统上,您必须具有clusterAdmin权限才能运行cleanupOrphaned。
Each 每个cleanupOrphaned command returns a document containing a subset of the following fields:cleanupOrphaned命令都返回一个包含以下字段子集的文档:
cleanupOrphaned.ok Equal to 成功时等于1 on success.1。
A value of 值1 indicates that either:1表示:
cleanupOrphaned namespace on the shard, orcleanupOrphaned命名空间中没有保留孤立文档,或者cleanupOrphaned namespace is not sharded.cleanupOrphaned命名空间中引用的集合未分片。A value of 值0 indicates that an error has occurred.0表示发生了错误。