cleanupOrphaned
重要
Starting in MongoDB 6.0.3, you should run an aggregation using the
$shardedDataDistribution
stage to confirm no orphaned
documents remain. For details,
see 确认无孤立文档.
定义
cleanupOrphaned
自版本 8.0 起已弃用。
Use this command to wait for orphaned documents in a chunk range from a shard key's
MinKey
to itsMaxKey
for a specified namespace to be cleaned up from a majority of a shard's members.To run, issue
cleanupOrphaned
in theadmin
database directly on themongod
instance that is the primary replica set member of the shard. You do not need to disable the balancer before runningcleanupOrphaned
.注意
Do not run
cleanupOrphaned
on amongos
instance.
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0、M2、M5 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.runCommand( { cleanupOrphaned: "<database>.<collection>", startingFromKey: <minimumShardKeyValue>, // deprecated secondaryThrottle: <boolean>, // deprecated writeConcern: <document> // deprecated } )
命令字段
cleanupOrphaned
具有以下字段:
字段 | 类型 | 说明 |
---|---|---|
| 字符串 | The namespace, i.e. both the database and the collection name, of the sharded collection for which to wait for cleanup of the orphaned data. |
行为
Determine Range
The value of this field is not used to determine the bounds of the cleanup
range. 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
.
必需的访问权限
On systems running with authorization
, you must have
clusterAdmin
privileges to run cleanupOrphaned
.
输出
returnDocument
Each cleanupOrphaned
command returns a document containing
a subset of the following fields: