On this page本页内容
listShards The listShards command returns a list of the configured shards in a sharded cluster. listShards命令返回分片集群中已配置分片的列表。listShards is only available on 仅在mongos instances and must be issued against the admin database.mongos实例上可用,必须针对admin数据库发布。
The command takes the following form:该命令采用以下形式:
{ listShards: 1 }
The following operation runs 以下操作针对listShards against the mongos admin database:mongos的admin数据库运行listShards:
db.adminCommand({ listShards: 1 })
The following document is an example of the output from a 以下文档是listShards command:listShards命令的输出示例:
{
"shards": [
{
"_id": "shard01",
"host": "shard01/host1:27018,host2:27018,host3:27018",
"state": 1
},
{
"_id": "shard02",
"host": "shard02/host4:27018,host5:27018,host6:27018",
"tags": [ "NYC" ],
"state": 1
},
{
"_id": "shard03",
"host": "shard03/host7:27018,host8:27018,host9:27018",
"maxSize": NumberLong("1024"),
"state": 1
}
],
"ok": 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1510716515, 1),
"signature" : {
"hash" : BinData(0,"B2ViX7XLzFLS5Fl9XEuFXbwKIM4="),
"keyId" : NumberLong("6488045157173166092")
}
},
"operationTime" : Timestamp(1510716515, 1)
}
listShards returns a document that includes:返回包含以下内容的文档:
A 包含一组文档的shards field which contains an array of documents, each describing one shard. shards字段,每个文档描述一个分片。Each document may contain the following fields:每个文档可能包含以下字段:
_id | |
host | host lists the hostname of each mongod instance in the replica set. host将列出副本集中每个mongod实例的主机名。 |
draining | true,则表示已为此分片调用了removeShard,并且该分片正在被排出。 |
tags | |
maxSize | local and admin databases. local和admin数据库。 |
state | addShard序列期间使用的一个内部字段,用于确保完成将分片添加到集群所需的所有步骤和配置。 |
ok status field, the operationTime field, and the $clusterTime field for the operation. ok状态字段、operationTime字段和$clusterTime字段。