缺失的分片键索引
描述
格式
{ type: "MissingShardKeyIndex", description: "<string>", details: { namespace: "<string>", shard: "<string>", shardKey: { <document> } } }
MissingShardKeyIndex
不一致性文档包含以下字段
字段 | 类型 | 描述 |
---|---|---|
类型 | 字符串 | 不一致性文档的类型。对于此不一致性类型,返回值为 |
description | 字符串 | 描述在元数据中找到的不一致性。 |
details | document | 包含有关不一致性存在于数据库和分片集群中的额外信息的文档。 |
details.namespace | 字符串 | 指示不一致性存在的数据库和集合。 |
details.shard | 字符串 | 不一致性存在的分片。 |
details.shardKey | document | 需要索引的分片键。 |
示例
使用db.adminCommand()
方法调用 checkMetadataConsistency
命令
db.adminCommand( { checkMetadataConsistency: 1 } )
此方法返回一个游标,包含一批文档,显示在分片元数据中找到的不一致性。以下示例显示了一个包含 MissingShardKeyIndex
不一致性文档的游标
{ cursor: { id: Long("0"), ns: "test.$cmd.aggregate", firstBatch: [ { type: "MissingShardKeyIndex", description: "Found sharded collection without a shard key index", details: { namespace: "test.authors", shard: "shard-rs0", shardKey: { skey: 1 } } } ], }, ok: 1 }