cleanupOrphaned

On this page本页内容

Definition定义

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, cleanupOrphaned initiated the cleanup process for orphaned documents in a specified namespace and shard key range.在MongoDB 4.2和更早版本中,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数据库中发出cleanupOrphanedYou do not need to disable the balancer before running cleanupOrphaned.在运行cleanupOrphaned之前,不需要禁用平衡器。

Note注意

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:具有以下字段:

Field字段Type类型Description描述
cleanupOrphanedstringThe namespace, i.e. both the database and the collection name, of the sharded collection for which to wait for cleanup of the orphaned data. 要等待清理孤立数据的分片化集合的名称空间,即数据库和集合名称。
startingFromKeydocument

Deprecated. 已弃用。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 are cleaned up from the shard before completing, regardless of the presence of or the value of startingFromKey.cleanupOrphaned命令等待直到所有范围内的所有孤立文档在完成之前从分片中清除,而不管startingFromKey是否存在或值如何。

Note注意

The mongod continues to validate that the startingFromKey value matches the shard key pattern, even though it is not used to determine the bounds of the cleanup range.mongod继续验证startingFromKey值是否与分片键模式匹配,即使它不用于确定清理范围的边界。

secondaryThrottlebooleanDeprecated. 已弃用。Starting in MongoDB 4.4, this field has no effect.从MongoDB 4.4开始,此字段无效。
writeConcerndocumentDeprecated. 已弃用。Starting in MongoDB 4.4, this field has no effect. 从MongoDB 4.4开始,此字段无效。Orphaned documents are always cleaned up from a majority of a shard's members ({ writeConcern: { w: "majority" } }) before the cleanupOrphaned command returns a response. cleanupOrphaned命令返回响应之前,始终从分片的大多数成员({ writeConcern: { w: "majority" } })中清除孤立文档。

Behavior行为

Determine Range确定范围

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是否存在或值如何。

Required Access所需访问权限

On systems running with authorization, you must have clusterAdmin privileges to run cleanupOrphaned.authorization运行的系统上,您必须具有clusterAdmin权限才能运行cleanupOrphaned

Output输出

Return Document退货单据

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表示:

  • No orphaned documents remain in the cleanupOrphaned namespace on the shard, or分片上的cleanupOrphaned命名空间中没有保留孤立文档,或者
  • The collection referenced in the cleanupOrphaned namespace is not sharded.cleanupOrphaned命名空间中引用的集合未分片。

A value of 0 indicates that an error has occurred.0表示发生了错误。

←  clearJumboFlagcleanupReshardCollection →