listShards

On this page本页内容

Definition定义

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 }

Example示例

The following operation runs listShards against the mongos admin database:以下操作针对mongosadmin数据库运行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)
}

Output输出

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:每个文档可能包含以下字段:

    Field字段Description描述
    _idThe name of the shard.分片的名称。
    hostThe hostname of the shard. 分片的主机名。If the shard is a replica set, host lists the hostname of each mongod instance in the replica set. 如果分片是副本集,host将列出副本集中每个mongod实例的主机名。
    drainingIf true, indicates that removeShard has been called for this shard and it is in the process of being drained. 如果为true,则表示已为此分片调用了removeShard,并且该分片正在被排出。
    tagsA list of zones to which the shard belongs.分片所属区域的列表。
    maxSizeThe configured maximum storage size of the shard in megabytes. 分片的配置最大存储大小(MB)。This includes all data files on the shard including the local and admin databases. 这包括分片上的所有数据文件,包括localadmin数据库。If exceeded, this shard will not receive any more chunks. 如果超过此值,此分片将不再接收任何块。
    stateAn internal field used during the addShard sequence to ensure that all steps and configuration necessary to add the shard to the cluster are completed. addShard序列期间使用的一个内部字段,用于确保完成将分片添加到集群所需的所有步骤和配置。
  • The ok status field, the operationTime field, and the $clusterTime field for the operation. 操作的ok状态字段、operationTime字段和$clusterTime字段。For details on these fields, see Response.有关这些字段的详细信息,请参阅响应
←  isdbgridmedianKey →