- Reference >
mongoShell Methods >- Sharding Methods >
- sh.status()
sh.status()¶
On this page
Definition¶
-
sh.status()¶ When run on a
mongosinstance, 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 verboseboolean Optional. If true, the method displays details of the document distribution across chunks when you have 20 or more chunks.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 mongos Version and Count section displays information on the
version and count of active mongos instances:
active mongoses:
<version> : <num>
The Autosplit displays information on whether autosplit is enabled:
autosplit:
Currently enabled: <yes|no>
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> ... ]
}
...
New in version 3.0.0: 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
Balancer lock taken at Fri Nov 11 2016 14:23:24 GMT-0500 (EST) by ConfigServer:Balancer
Collections with active migrations:
chat.messages started at Fri Nov 11 2016 14:24:12 GMT-0500 (EST)
Failed balancer rounds in last 5 attempts: 1
Last reported error: tag ranges not valid for: test.t2
Time of Reported error: Wed Dec 10 2014 12:00:33 GMT+1100 (AEDT)
Migration Results for the last 24 hours:
96 : Success
15 : Failed with error 'ns not found, should be impossible', from
shard01 to shard02
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> }
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¶
Sharding Version¶
-
sh.status.sharding-version._id¶ The
_idis an identifier for the version details.
-
sh.status.sharding-version.minCompatibleVersion¶ The
minCompatibleVersionis the minimum compatible version of the config server.
-
sh.status.sharding-version.currentVersion¶ The
currentVersionis the current version of the config server.
-
sh.status.sharding-version.clusterId¶ The
clusterIdis the identification for the sharded cluster.
mongos Version and Count¶
Autosplit¶
-
sh.status.active-mongoses¶ sh.status.active-mongosesindicates whether autosplit is currently enabled.
Shards¶
-
sh.status.shards._id¶ The
_iddisplays the name of the shard.
-
sh.status.shards.host¶ The
hostdisplays the host location of the shard.
The
tagsdisplays all the tags for the shard. The field only displays if the shard has tags.
Balancer¶
New in version 3.0.0: sh.status() added the balancer field.
-
sh.status.balancer.currently-enabled¶ currently-enabledindicates if the balancer is currently enabled on the sharded cluster.
-
sh.status.balancer.currently-running¶ currently-runningindicates whether the balancer is currently running, and therefore currently balancing the cluster.If the balancer is running,
currently-runningprints information on the"balancer"lock.Changed in version Starting: in 3.4
The primary of the CSRS config server holds the
"balancer"lock, using a process id named"ConfigServer", which is never released.
-
sh.status.balancer.collections-with-active-migrations¶ collections-with-active-migrationslists the names of any collections with active migrations, and specifies when the migration began. If there are no active migrations, this field will not appear in thesh.status()output.
-
sh.status.balancer.failed-balancer-rounds-in-last-5-attempts¶ failed-balancer-rounds-in-last-5-attemptsdisplays the number of balancer rounds that failed, from among the last five attempted rounds. A balancer round will fail when a chunk migration fails.
-
sh.status.balancer.last-reported-error¶ last-reported-errorlists the most recent balancer error message. If there have been no errors, this field will not appear in thesh.status()output.
-
sh.status.balancer.time-of-reported-error¶ time-of-reported-errorprovides the date and time of the most recently-reported error.
-
sh.status.balancer.migration-results-for-the-last-24-hours¶ migration-results-for-the-last-24-hoursdisplays the number of migrations in the last 24 hours, and the error messages from failed migrations . If there have been no recent migrations,migration-results-for-the-last-24-hoursdisplaysNo recent migrations.migration-results-for-the-last-24-hoursincludes all migrations, including those not initiated by the balancer.
Databases¶
-
sh.status.databases._id¶ The
_iddisplays the name of the database.
-
sh.status.databases.partitioned¶ The
partitioneddisplays whether the database has sharding enabled. Iftrue, the database has sharding enabled.
-
sh.status.databases.primary¶ The
primarydisplays the primary shard for the database.
Sharded Collection¶
-
sh.status.databases.<collection>.shard-key¶ The
shard-keydisplays the shard key specification document.
-
sh.status.databases.<collection>.unique¶ The
uniquedisplays whether MongoDB enforces uniqueness on the shard key values.
-
sh.status.databases.balancing¶ The
balancingdisplays whether balancing is enabled (true) or disabled (false) for the collection.
-
sh.status.databases.<collection>.chunks¶ The
chunkslists all the shards and the number of chunks that reside on each shard.
-
sh.status.databases.<collection>.chunk-details¶ The
chunk-detailslists 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.<collection>.tag¶ The
taglists 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). |