On this page本页内容
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:
verbose |
boolean |
If
If
The default verbose value is |
See also参阅
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).
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.
mongos
Instances¶New in version 3.2.版本3.2中的新功能。
sh.status.
active-mongoses
¶If verbose
is false
, sh.status.active-mongoses
lists the version and count of the active mongos
instances. Active mongos
instances are mongos
instances that have been ping’ed within the last 60 seconds.
If verbose
is true
, returns for each active mongos
instance:
sh.status.
active-mongoses
¶sh.status.active-mongoses
indicates whether autosplit is currently enabled.
Note
Starting in MongoDB 4.2:
balancerStart
command and the mongo
shell helper methods sh.startBalancer()
and sh.setBalancerState(true)
also enable auto-splitting for the sharded cluster.
sh.disableAutoSplit()
.balancerStop
command and the mongo
shell helper methods sh.stopBalancer()
and sh.setBalancerState(false)
also disable auto-splitting for the sharded cluster.
sh.enableAutoSplit()
.The mongo
methods sh.enableBalancing(namespace)
and sh.disableBalancing(namespace)
have no affect on the auto-splitting.
The tags
displays all the tags for the shard. The field only displays if the shard has tags.
Note
Starting in MongoDB 4.2:
balancerStart
command and the mongo
shell helper methods sh.startBalancer()
and sh.setBalancerState(true)
also enable auto-splitting for the sharded cluster.
sh.disableAutoSplit()
.balancerStop
command and the mongo
shell helper methods sh.stopBalancer()
and sh.setBalancerState(false)
also disable auto-splitting for the sharded cluster.
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-enabled
indicates if the balancer is currently enabled on the sharded cluster.
sh.status.balancer.
currently-running
¶currently-running
indicates whether the balancer is currently running, and therefore currently balancing the cluster.
sh.status.balancer.
collections-with-active-migrations
¶collections-with-active-migrations
lists 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-attempts
displays 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-error
lists 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-error
provides 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-hours
displays 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-hours
displays No recent migrations
.
migration-results-for-the-last-24-hours
includes all migrations, including those not initiated by the balancer.
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.
sh.status.databases.
version
¶New in version 4.0:Only available for featureCompatibilityVersion 4.0
or greater.
The version
displays the version information for the database:
where:
uuid
is the database identifier.lastMod
is the database version.sh.status.databases.<collection>.
shard-key
¶The shard-key
displays the shard key specification document.
sh.status.databases.<collection>.
unique
¶The unique
displays whether MongoDB enforces uniqueness on the shard key values (i.e. whether the underlying shard key index is unique).
New in version 3.2.版本3.2中的新功能。
sh.status.databases.
balancing
¶The balancing
displays whether balancing is enabled (true
) or disabled (false
) for the collection.
New in version 3.2.版本3.2中的新功能。
sh.status.databases.<collection>.
chunks
¶The chunks
lists all the shards and the number of chunks that reside on each shard.
sh.status.databases.<collection>.
chunk-details
¶The chunk-details
lists the details of the chunks [1]:
sh.status.databases.<collection>.
tag
¶The tag
lists 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 the verbose parameter set to true , i.e. sh.status(true) . |