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. 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. 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.
In MongoDB 4.2 and earlier, cleanupOrphaned
initiated the cleanup process for orphaned documents in a specified namespace and shard key range.
To run, issue cleanupOrphaned
in the admin
database directly on the mongod
instance that is the primary replica set member of the shard. You do not need to disable the balancer before running cleanupOrphaned
.
Note
Do not run cleanupOrphaned
on a mongos
instance.
cleanupOrphaned
has the following syntax:语法如下所示:
cleanupOrphaned
has the following fields:
cleanupOrphaned |
string | 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. |
startingFromKey |
document | Deprecated. Starting in MongoDB 4.4, the value of this field is not used to determine the bounds of the cleanup range. The Note The |
secondaryThrottle |
boolean | |
writeConcern |
document | { writeConcern: { w: "majority" } } )
before the cleanupOrphaned command returns a response. |
Starting in MongoDB 4.4, 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
.
Each cleanupOrphaned
command returns a document containing a subset of the following fields:
cleanupOrphaned.
ok
¶Equal to 1
on success.
A value of 1
indicates that either:
cleanupOrphaned
namespace on the shard, orcleanupOrphaned
namespace is not sharded.A value of 0
indicates that an error has occurred.