OPTIONS
翻译或纠错本页面

sh.status()

Definition

sh.status()

Prints a formatted report of the sharding configuration and the information regarding existing chunks in a sharded cluster. The default behavior suppresses the detailed chunk information if the total number of chunks is greater than or equal to 20.

The sh.status() method has the following parameter:

Parameter Type Description
verbose Boolean Optional. If true, the method displays details of the document distribution across chunks when you have 20 or more chunks.

Output Examples

The Sharding Version section displays information on the config database:

--- Sharding Status ---
  sharding version: {
   "_id" : <num>,
   "version" : <num>,
   "minCompatibleVersion" : <num>,
   "currentVersion" : <num>,
   "clusterId" : <ObjectId>
}

The Shards section lists information on the shard(s). For each shard, the section displays the name, host, and the associated tags, if any.

shards:
 {  "_id" : <shard name1>,
    "host" : <string>,
    "tags" : [ <string> ... ]
 }
 {  "_id" : <shard name2>,
    "host" : <string>,
    "tags" : [ <string> ... ]
 }
 ...

The Databases section lists information on the database(s). For each database, the section displays the name, whether the database has sharding enabled, and the primary shard for the database.

databases:
 {  "_id" : <dbname1>,
    "partitioned" : <boolean>,
    "primary" : <string>
 }
 {  "_id" : <dbname2>,
    "partitioned" : <boolean>,
    "primary" : <string>
 }
 ...

The Sharded Collection section provides information on the sharding details for sharded collection(s). For each sharded collection, the section displays the shard key, the number of chunks per shard(s), the distribution of documents across chunks [1], and the tag information, if any, for shard key range(s).

<dbname>.<collection>
   shard key: { <shard key> : <1 or hashed> }
   chunks:
      <shard name1> <number of chunks>
      <shard name2> <number of chunks>
      ...
   { <shard key>: <min range1> } -->> { <shard key> : <max range1> } on : <shard name> <last modified timestamp>
   { <shard key>: <min range2> } -->> { <shard key> : <max range2> } on : <shard name> <last modified timestamp>
   ...
   tag: <tag1>  { <shard key> : <min range1> } -->> { <shard key> : <max range1> }
   ...

Output Fields

Sharding Version

sh.status.sharding-version._id

The _id is an identifier for the version details.

sh.status.sharding-version.version

The version is the version of the config server for the sharded cluster.

sh.status.sharding-version.minCompatibleVersion

The minCompatibleVersion is the minimum compatible version of the config server.

sh.status.sharding-version.currentVersion

The currentVersion is the current version of the config server.

sh.status.sharding-version.clusterId

The clusterId is the identification for the sharded cluster.

Shards

sh.status.shards._id

The _id displays the name of the shard.

sh.status.shards.host

The host displays the host location of the shard.

sh.status.shards.tags

The tags displays all the tags for the shard. The field only displays if the shard has tags.

Databases

sh.status.databases._id

The _id displays the name of the database.

sh.status.databases.partitioned

The partitioned displays whether the database has sharding enabled. If true, the database has sharding enabled.

sh.status.databases.primary

The primary displays the primary shard for the database.

Sharded Collection

sh.status.databases.shard-key

The shard-key displays the shard key specification document.

sh.status.databases.chunks

The chunks lists all the shards and the number of chunks that reside on each shard.

sh.status.databases.chunk-details

The chunk-details lists the details of the chunks [1]:

  • The range of shard key values that define the chunk,
  • The shard where the chunk resides, and
  • The last modified timestamp for the chunk.
sh.status.databases.tag

The tag lists the details of the tags associated with a range of shard key values.

[1](1, 2) The sharded collection section, by default, displays the chunk information if the total number of chunks is less than 20. To display the information when you have 20 or more chunks, call the sh.status() methods with the verbose parameter set to true, i.e. sh.status(true).