Docs 菜单
Docs 主页
/
MongoDB Manual
/ / /

cleanupOrphaned

在此页面上

  • 定义
  • 语法
  • 行为
  • 必需的访问权限
  • 输出

重要

cleanupOrphaned

使用此命令可等待从分片键的MinKey到其MaxKey的数据块范围内的孤立文档,以便从大多数分片成员中清除指定命名空间。

要运行,请在cleanupOrphaned adminmongod数据库中直接对作为分片的主副本集成员的 实例发出 。在运行cleanupOrphaned 之前,您无需禁用负载均衡器。

注意

不要在 实例上运行cleanupOrphaned mongos

该命令具有以下语法:

db.runCommand(
{
cleanupOrphaned: "<database>.<collection>",
startingFromKey: <minimumShardKeyValue>, // deprecated
secondaryThrottle: <boolean>, // deprecated
writeConcern: <document> // deprecated
}
)

cleanupOrphaned 有以下字段:

字段
类型
说明
cleanupOrphaned
字符串
等待清理孤立数据的分片集合的命名空间,即数据库名称和集合名称。

此字段的值不用于确定清理范围的边界。无论startingFromKey是否存在或值如何, cleanupOrphaned命令都会等到命名空间中所有范围内的所有孤立文档都从分片中清除后再完成。

在使用authorization运行的系统上,您必须具有clusterAdmin特权才能运行cleanupOrphaned

每个cleanupOrphaned命令都会返回一个包含以下字段子集的文档:

cleanupOrphaned.ok

成功时等于1

值为1表示:

  • 分片上的cleanupOrphaned命名空间中不存在任何孤立文档,或者

  • cleanupOrphaned命名空间中引用的collection未分片。

值为0表示发生错误。

← clearJumboFlag