listShards

On this page本页内容

Definition定义

listShards

The listShards command returns a list of the configured shards in a sharded cluster. listShards is only available on mongos instances and must be issued against the admin database.

The command takes the following form:

{ listShards: 1 }

Example示例

The following operation runs listShards against the mongos admin database:

db.adminCommand({ listShards: 1 })

The following document is an example of the output from a listShards command:

{
  "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: