cleanupOrphaned
MongoDB5.0 已于 10 月2024 结束生命周期。不再支持此版本的文档。要升级5.0 部署,请参阅 MongoDB6 。0 升级程序。
定义
cleanupOrphaned
使用此命令等待从分分片键的
MinKey
到其MaxKey
的数据范围的数据块文档,以从大多数分片成员中清除指定命名空间。要运行,请在
cleanupOrphaned
admin
数据库中直接对作为分片的主节点 (primary node in the replica set)副本集成员的 实例发出mongod
。在运行cleanupOrphaned
之前,您无需禁用负载均衡器。注意
不要在 实例上运行
cleanupOrphaned
mongos
。
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M 0 、M 2和 M 5集群不支持此命令。 有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.runCommand( { cleanupOrphaned: "<database>.<collection>", startingFromKey: <minimumShardKeyValue>, // deprecated secondaryThrottle: <boolean>, // deprecated writeConcern: <document> // deprecated } )
命令字段
cleanupOrphaned
有以下字段:
字段 | 类型 | 说明 |
---|---|---|
| 字符串 | 等待清理孤立数据的分片集合的命名空间,即数据库名称和集合名称。 |
行为
确定范围
该字段的值不用于确定清理范围的边界。 无论startingFromKey
是否存在或值如何, cleanupOrphaned
命令都会等到命名空间中所有范围内的所有孤立文档都从分分片清除后再完成。
必需的访问权限
在使用authorization
运行的系统上,您必须具有clusterAdmin
特权才能运行cleanupOrphaned
。
输出
returnDocument
每个cleanupOrphaned
命令都会返回一个包含以下字段子集的文档: