On this page
sh.status()
On this page
Definition
sh.
status
( )-
When run on a
mongos
instance, 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. Determines the level of verbosity.
If
true
, the method displays:- Full details of the chunk distribution across shards even if you have 20 or more chunks, as well as the number of chunks on each shard.
- Details of active mongos instances.
If
false
, the method displays:- Full details of the chunk distribution across shards only if you have less than 20 chunks. If you have 20 or more chunks, the method instead returns a
too many chunks to print ...
message, showing only the number of chunks on each shard. - Only the version and number of active mongos instances.
The default verbose value is
false
.See also
Output Examples
The Sharding Version section displays information on the config database:
--- Sharding Status ---
sharding version: {
"_id" : <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> ... ], "state" : <num> }
{ "_id" : <shard name2>, "host" : <string>, "tags" : [ <string> ... ], "state" : <num> }
...
The Active mongos Instances section displays, by default, information on the version and count of mongos
instances that have been active within the last 60 seconds:
active mongoses:
<version> : <num>
If the method is run with the verbose
parameter to true, the Active mongos Instances section displays additional information:
active mongoses:
{ "_id" : "<hostname:port>", "advisoryHostFQDNs" : [ "<name>" ], "mongoVersion" : <string>, "ping" : <ISODate>, "up" : <long>, "waiting" : <boolean> }
The Autosplit displays information on whether autosplit is enabled:
autosplit:
Currently enabled: <yes|no>
The Balancer section lists information about the state of the balancer. This provides insight into current balancer operation and can be useful when troubleshooting an unbalanced sharded cluster.
balancer:
Currently enabled: yes
Currently running: yes
Collections with active migrations:
chat.messages started at Mon Nov 05 2018 15:16:45 GMT-0500 (EST)
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
1 : Success
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 chunks across shards [1], and the tag information, if any, for shard key range(s).
<dbname>.<collection>
shard key: { <shard key> : <1 or hashed> }
unique: <boolean>
balancing: <boolean>
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
Active mongos
Instances
New in version 3.2.
sh.status.
active-mongoses
-
If
verbose
isfalse
,sh.status.active-mongoses
lists the version and count of the activemongos
instances. Activemongos
instances aremongos
instances that have been ping’ed within the last 60 seconds.If
verbose
istrue
, returns for each activemongos
instance:- Its hostname and port.
- An array of the instance’s fully qualified domain names (FQDNs).
- Its MongoDB version.
- Its most recent ping date and time.
- Its uptime since the last ping.
- Its waiting status.
active mongoses: { "_id" : "<hostname:port>", "advisoryHostFQDNs" : [ "<name>" ], "mongoVersion" : <string>, "ping" : <ISODate>, "up" : <long>, "waiting" : <boolean> } ...
Autosplit
sh.status.
active-mongoses
-
sh.status.active-mongoses
indicates whether autosplit is currently enabled.
Balancer
New in version 3.0.0: sh.status()
added the balancer
field.
sh.status.balancer.
currently-enabled
-
currently-enabled
indicates if the balancer is currently enabled on the sharded cluster.
sh.status.balancer.