文档菜单
文档首页
/
MongoDB 手册
/ / /

缺失的分片键索引

本页内容

  • 描述
  • 格式
  • 示例
MissingShardKeyIndex

存在一个没有与集合分片键兼容的索引的分片集合。

版本7.0.

{
type: "MissingShardKeyIndex",
description: "<string>",
details: {
namespace: "<string>",
shard: "<string>",
shardKey: { <document> }
}
}

MissingShardKeyIndex 不一致性文档包含以下字段

字段
类型
描述
类型
字符串

不一致性文档的类型。对于此不一致性类型,返回值为 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
}

返回

缺失的路由表

本页内容