- 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 - 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:
The Shards section lists information on the shard(s). For each shard, the section displays the name, host, and the associated tags, if any.
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:
If the method is run with the verbose parameter to true, the
Active mongos Instances section displays additional information:
The Autosplit displays information on whether autosplit is enabled:
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.
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.
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).
Output Fields¶
Sharding Version¶
- 
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.
Active mongos Instances¶
New in version 3.2.
- 
sh.status.active-mongoses¶
- If - verboseis- false,- sh.status.active-mongoseslists the version and count of the active- mongosinstances. Active- mongosinstances are- mongosinstances that have been ping’ed within the last 60 seconds.- If - verboseis- true, returns for each active- mongosinstance:- 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.
 
Autosplit¶
- 
sh.status.active-mongoses¶
- sh.status.active-mongosesindicates whether autosplit is currently enabled.
Note
Starting in MongoDB 4.2:
- The - balancerStartcommand and the- mongoshell helper methods- sh.startBalancer()and- sh.setBalancerState(true)also enable auto-splitting for the sharded cluster.To disable auto-splitting when the balancer is enabled, you can use- sh.disableAutoSplit().
- The - balancerStopcommand and the- mongoshell helper methods- sh.stopBalancer()and- sh.setBalancerState(false)also disable auto-splitting for the sharded cluster.To enable auto-splitting when the balancer is disabled, you can use- sh.enableAutoSplit().
The mongo methods
sh.enableBalancing(namespace) and
sh.disableBalancing(namespace) have no affect on the
auto-splitting.
Shards¶
- The - tagsdisplays all the tags for the shard. The field only displays if the shard has tags.
Balancer¶
Note
Starting in MongoDB 4.2:
- The - balancerStartcommand and the- mongoshell helper methods- sh.startBalancer()and- sh.setBalancerState(true)also enable auto-splitting for the sharded cluster.To disable auto-splitting when the balancer is enabled, you can use- sh.disableAutoSplit().
- The - balancerStopcommand and the- mongoshell helper methods- sh.stopBalancer()and- sh.setBalancerState(false)also disable auto-splitting for the sharded cluster.To enable auto-splitting when the balancer is disabled, you can use- sh.enableAutoSplit().
The mongo methods
sh.enableBalancing(namespace) and
sh.disableBalancing(namespace) have no affect on the
auto-splitting.
- 
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.
- 
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 the- sh.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 the- sh.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-hoursdisplays- No recent migrations.- migration-results-for-the-last-24-hoursincludes all migrations, including those not initiated by the balancer.
Databases¶
- 
sh.status.databases.partitioned¶
- The - partitioneddisplays whether the database has sharding enabled. If- true, the database has sharding enabled.
- 
sh.status.databases.primary¶
- The - primarydisplays the primary shard for the database.
- 
sh.status.databases.version¶
- New in version 4.0: Only available for featureCompatibilityVersion - 4.0or greater.- The - versiondisplays the version information for the database:- where: - uuidis the database identifier.
- lastModis the database version.
 
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 (i.e. whether the underlying shard key index is unique).- New in version 3.2. 
- 
sh.status.databases.balancing¶
- The - balancingdisplays whether balancing is enabled (- true) or disabled (- false) for the collection.- New in version 3.2. 
- 
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.
See also
| [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 theverboseparameter
set totrue, i.e.sh.status(true). |