sh.checkMetadataConsistency()
定义
sh.checkMetadataConsistency(options)
Performs a series of consistency checks on sharding metadata for the cluster. This method returns a cursor with either all or a batch of the inconsistency results found.
重要
mongosh 方法
本页面提供
mongosh
方法的相关信息。这不是数据库命令或特定语言驱动程序(例如 Node.js)的相关文档。有关数据库命令,请参阅
checkMetadataConsistency
命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
Run this method after major maintenance operations, such as upgrades and downgrades, or to check if the cluster metadata is inconsistent or corrupted due to bugs in previous releases of MongoDB.
By default, the method does not check indexes for consistency across the shards. Index checks can return false positive inconsistencies if they run concurrent with operations that create, delete, or modify indexes. To check indexes with this method, set the
checkIndexes
option.For more information on the inconsistencies this method checks for, see 不一致类型.
返回: This method returns a cursor with a documents
array, which contains a document for each inconsistency found in the sharding metadata.
兼容性
此方法可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0、M2、M5 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
注意
The checkMetadataConsistency
helper is executable only when connecting to
mongos
. mongod
does not support this method.
语法
sh.checkMetadataConsistency()
方法使用的语法如下:
sh.checkMetadataConsistency( { <options> } )
The options
document can take the following fields and values:
字段 | 类型 | 说明 |
---|---|---|
| 布尔 | 设置该命令是否还检查分片元数据中的索引。 By default, this operation is disabled, because if it can return false positives inconsistencies when run concurrent with operations that create, delete, or modify indexes. Only check indexes at times when you know these operations are unlikely to occur. |
| 文档 | 配置返回游标。 |
| 整型 | Maximum number of sharding metadata inconsistency documents to include in each batch. |
例子
sh.checkMetadataConsistency()
{ cursorHasMore: false, documents: [ { type: "MisplacedCollection", description: "Unsharded collection found on shard different from database primary shard", details: { namespace: "test.authors", shard: "shard02", localUUID: new UUID("1ad56770-61e2-48e9-83c6-8ecefe73cfc4") } } ], }