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. mongos实例上运行时,打印分片配置的格式化报告以及有关分片集群中现有块的信息。The default behavior suppresses the detailed chunk information if the total number of chunks is greater than or equal to 20.如果区块总数大于或等于20,则默认行为将禁止显示详细的区块信息。
The sh.status() method has the following parameter:sh.status()方法具有以下参数:
verbose | boolean |
|
The Sharding Version section displays information on the config database:Sharding Version部分显示有关config数据库的信息:
--- 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:mongos实例部分显示有关在过去60秒内处于活动状态的mongos实例的版本和计数的信息:
active mongoses: <version> : <num>
If the method is run with the 如果在verbose parameter to true, the Active mongos Instances section displays additional information:verbose参数为true的情况下运行该方法,则活动mongos实例部分将显示其他信息:
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:
config.system.sessions started at Fri May 15 2020 17:38:12 GMT-0400 (EDT)
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
416 : Success
1 : Failed with error 'aborted', from shardA to shardB
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>, "primary" : <string>, "partitioned" : <boolean>, "version": <document> }
{ "_id" : <dbname2>, "primary" : <string>, "partitioned" : <boolean>, "version": <document> }
...
The Sharded Collection section provides information on the sharding details for sharded collection(s). Sharded Collection部分提供了有关分片集合的分片详细信息。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).对于每个分片集合,该部分显示分片键、每个分片的块数、块在分片上的分布[1],以及分片键范围的标记信息(如果有)。
<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> }
...
sh.status.sharding-version._id
The _id is an identifier for the version details._id是版本详细信息的标识符。
sh.status.sharding-version.minCompatibleVersion
The minCompatibleVersion is the minimum compatible version of the config server.minCompatibleVersion是配置服务器的最低兼容版本。
sh.status.sharding-version.currentVersion
The currentVersion is the current version of the config server.currentVersion是配置服务器的当前版本。
mongos Instancesmongos实例sh.status.active-mongoses
If 如果verbose is false, sh.status.active-mongoses lists the version and count of the active mongos instances. verbose为false,sh.status.active-mongoses将列出活动mongos实例的版本和计数。Active 活动mongos instances are mongos instances that have been pinged within the last 60 seconds.mongos实例是在过去60秒内ping的mongos示例。
If 如果verbose is true, sh.status.active-mongoses returns a document for each active mongos instance containing the following fields:verbose为true,sh.status.active-mongoses将为每个活动mongos实例返回一个包含以下字段的文档:
| Data Type | ||
|---|---|---|
_id | String | mongos is running. mongos运行的主机名和端口。_id is formatted as <hostname>:<port>._id的格式为<hostname>:<port>。
|
advisoryHostFQDNs | Array of strings | mongos's fully qualified domain names (FQDNs).mongos的完全限定域名(FQDN)数组。
|
created | Date |
|
mongoVersion | String | mongos is running.mongos正在运行的MongoDB版本。 |
ping | Date | mongos instances send pings to the config server every 30 seconds. mongos实例每30秒向配置服务器发送一次ping。 |
up | NumberLong | mongos has been up as of the last ping.mongos已上升的秒数。
|
waiting | Boolean | true and is only present for backward compatibility.true,仅用于向后兼容。
|
active mongoses:
{
"_id" : "<hostname:port>",
"advisoryHostFQDNs" : [ "<name>" ],
"created" : <ISODate>,
"mongoVersion" : <string>,
"ping" : <ISODate>,
"up" : <long>,
"waiting" : <boolean>
}
...
sh.status.autosplit
sh.status.autosplit indicates whether autosplit is currently enabled.指示当前是否启用了自动拆分。
Starting in MongoDB 4.2:从MongoDB 4.2开始:
The balancerStart command and the mongo shell helper methods sh.startBalancer() and sh.setBalancerState(true) also enable auto-splitting for the sharded cluster.balancerStart命令和mongo shell助手方法sh.startBalancer()和sh.setBalancerState(true)也支持分片集群的自动拆分。
sh.disableAutoSplit().sh.disableAutoSplit()。The balancerStop command and the mongo shell helper methods sh.stopBalancer() and sh.setBalancerState(false) also disable auto-splitting for the sharded cluster.balancerStop命令和mongo shell助手方法sh.stopBalancer()和sh.setBalancerState(false)也禁用了分片集群的自动拆分。
sh.enableAutoSplit().sh.enableAutoSplit()。The mongo方法mongo methods sh.enableBalancing(namespace) and sh.disableBalancing(namespace) have no affect on the auto-splitting.sh.enableBalancing(namespace)和 sh.disableBalancing(namespace)对自动拆分没有影响。
sh.status.shards._id
The _id displays the name of the shard._id显示分片的名称。
sh.status.shards.host
The host displays the host location of the shard.host显示分片的主机位置。
sh.status.shards.tags
The tags displays all the tags for the shard. The field only displays if the shard has tags.tags显示分片的所有标记。该字段仅在分片具有标记时显示。
sh.status.shards.state
The state displays:state显示:
01Starting in MongoDB 4.2:从MongoDB 4.2开始:
The balancerStart command and the mongo shell helper methods sh.startBalancer() and sh.setBalancerState(true) also enable auto-splitting for the sharded cluster.balancerStart命令和mongo shell助手方法sh.startBalancer()和sh.setBalancerState(true)也支持分片集群的自动拆分。
sh.disableAutoSplit().sh.disableAutoSplit()。The balancerStop command and the mongo shell helper methods sh.stopBalancer() and sh.setBalancerState(false) also disable auto-splitting for the sharded cluster.balancerStop命令和mongo shell助手方法sh.stopBalancer()和sh.setBalancerState(false)也禁用了分片集群的自动拆分。
sh.enableAutoSplit().sh.enableAutoSplit()。The mongo方法mongo methods sh.enableBalancing(namespace) and sh.disableBalancing(namespace) have no affect on the auto-splitting.sh.enableBalancing(namespace)和sh.disableBalancing(namespace)对自动拆分没有影响。
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()输出中将不会显示此字段。
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()输出中。
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 . 显示最近24小时内的迁移数,以及失败迁移的错误消息。If there have been no recent migrations, 如果最近没有迁移,则最近24小时的迁移结果将显示migration-results-for-the-last-24-hours displays No recent migrations.No recent migrations。
migration-results-for-the-last-24-hours includes all migrations, including those not initiated by the balancer.包括所有迁移,包括那些不是由平衡器启动的迁移。
sh.status.databases._id
The _id displays the name of the database._id显示数据库的名称。
sh.status.databases.partitioned
The partitioned displays whether the database has sharding enabled. partitioned显示数据库是否启用了分片。If 如果为true, the database has sharding enabled.true,则数据库已启用分片。
sh.status.databases.primary
The primary displays the primary shard for the database.primary显示数据库的主分片。
sh.status.databases.version
New in version 4.0.在版本4.0中新增。 Only available for featureCompatibilityVersion仅适用于featureCompatibilityVersion4.0 or greater.4.0或更高版本。
The version displays the version information for the database:version显示数据库的版本信息:
{ "uuid" : UUID("cc250b66-8638-49f7-a2e8-c6f1220b9d7a"), "lastMod" : 1 }
where:
uuidlastModsh.status.databases.<collection>.shard-key
The shard-key displays the shard key specification document.shard-key显示分片键规范文档。
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).显示MongoDB是否强制分片键值的唯一性(即底层分片键值索引是否唯一)。
sh.status.databases.<collection>.balancing
The balancing displays whether balancing is enabled (true) or disabled (false) for the collection.balancing显示集合的平衡是启用(true)还是禁用(false)。
sh.status.databases.<collection>.chunks
The chunks lists all the shards and the number of chunks that reside on each shard.chunks列出了所有分片以及每个分片上的块数。
sh.status.databases.<collection>.chunk-details
The chunk-details lists the details of the chunks chunk-details列出了区块的详细信息[1]:
sh.status.databases.<collection>.tag
The tag lists the details of the tags associated with a range of shard key values.tag列出了与一系列shard键值关联的标记的详细信息。
| [1] | (1, 2) sh.status() methods with the verbose parameter set to true, i.e. sh.status(true).sh.status()方法,并将verbose参数设置为true,即sh.status(true)。 |