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.mongos
实例上运行时,会打印一份格式化的分片配置报告和关于分片集群中现有块的信息。The default behavior suppresses the detailed chunk information if the total number of chunks is greater than or equal to 20.如果块的总数大于或等于20,则默认行为抑制详细的块信息。Thesh.status()
method has the following parameter:sh.status()
方法具有以下参数:Parameter参数Type类型Description描述verbose
boolean Optional.可选的。Determines the level of verbosity.确定详细程度。
If如果为true
, the method displays:true
,则该方法显示: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.即使你有20个或20个以上的区块,区块在分片之间分布的完整细节,以及每个分片上的区块数量。Details of active mongos instances.活动mongos
实例的详细信息。
If如果为false
, the method displays:false
,则该方法显示:Full details of the chunk distribution across shards only if you have less than 20 chunks.只有当你拥有少于20个区块时,区块在分片之间分布的完整细节。If you have 20 or more chunks, the method instead returns a如果你有20个或更多的块,该方法会返回too many chunks to print ...
message, showing only the number of chunks on each shard.too many chunks to print ...
消息,只显示每个分片上的块数。Only the version and number of active mongos instances.仅活动mongos
实例的版本和数量。
The default verbose value is默认的详细值为false
.false
。TipSee also:另请参阅:
Output Examples输出示例
The Sharding Version section displays information on the config database:分片版本部分显示有关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
显示有关是否启用自动拆分的信息:
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). 数据库部分列出了有关数据库的信息。It displays the database name and the primary shard for each 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). 分片集合部分提供了有关分片集合的分片详细信息。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> }
...
Output Fields输出字段
Sharding Version分片版本
sh.status.sharding-version.minCompatibleVersion
-
TheminCompatibleVersion
is the minimum compatible version of the config server.minCompatibleVersion
是配置服务器的最低兼容版本。In MongoDB versions earlier than 6.2, this field is included in the在低于6.2的MongoDB版本中,此字段包含在config.version
collection, but inmongosh
2.0.0 and later, the field is not returned in thesh.status()
output.config.version
集合中,但在mongosh
2.0.0及更高版本中,该字段不会在sh.status()
输出中返回。Starting in MongoDB 6.2, this field is removed and not returned in any从MongoDB 6.2开始,该字段将被删除,并且不会在任何mongosh
version or other client application.mongosh
版本或其他客户端应用程序中返回。Instead, to obtain version information, see the feature compatibility version (fcv).相反,要获取版本信息,请参阅功能兼容性版本(fcv)。
sh.status.sharding-version.currentVersion
-
ThecurrentVersion
is the current version of the config server.currentVersion
是配置服务器的当前版本。In MongoDB versions earlier than 6.2, this field is included in the在6.2之前的MongoDB版本中,该字段包含在config.version
collection, but inmongosh
2.0.0 and later, the field is not returned in thesh.status()
output.config.version
集合中,但在mongosh
2.0.0及更高版本中,sh.status()
输出中不会返回该字段。Starting in MongoDB 6.2, this field is removed and not returned in any从MongoDB 6.2开始,该字段将被删除,并且不会在任何mongosh
version or other client application. Instead, to obtain version information, see the feature compatibility version (fcv).mongosh
版本或其他客户端应用程序中返回。相反,要获取版本信息,请参阅功能兼容性版本(fcv)。
sh.status.sharding-version.clusterId
-
TheclusterId
is the identification for the sharded cluster.clusterId
是分片集群的标识。
Active mongos
Instances活动mongos
实例
mongos
Instancessh.status.active-mongoses
-
If如果verbose
isfalse
,sh.status.active-mongoses
lists the version and count of the activemongos
instances.verbose
为false
,sh.status.active-mongoses
将列出活动mongos
实例的版本和计数。Active活动的mongos
instances aremongos
instances that have been pinged within the last 60 seconds.mongos
实例是在过去60秒内被ping到的mongo
实例。If如果verbose
istrue
,sh.status.active-mongoses
returns a document for each activemongos
instance containing the following fields:verbose
为true
,sh.status.active-mongoses
将为每个活动的mongos
实例返回一个包含以下字段的文档:Field字段Data Type Description描述_id
String The hostname and port where themongos
is running. The_id
is formatted as<hostname>:<port>
.mongos
运行的主机名和端口。_id
的格式为<hostname>:<port>
。advisoryHostFQDNs
Array of strings Array of themongos
's fully qualified domain names (FQDNs).mongos
的完全限定域名(FQDN)的数组。created
Date When the当mongos
was started.mongos
启动时。
New in version 5.2.5.2版新增。mongoVersion
String Version of MongoDB that themongos
is running.mongos
正在运行的MongoDB版本。ping
Date mongos
instances send pings to the config server every 30 seconds.mongos
实例每30秒向配置服务器发送一次ping。This field indicates the last ping time.此字段指示最后一次ping时间。up
NumberLong Number of seconds the截至上次ping,mongos
has been up as of the last ping.mongos
已上升的秒数。waiting
Boolean As of MongoDB 3.4, this field is always从MongoDB 3.4开始,该字段始终为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>
}
...
Autosplit自动拆分
sh.status.autosplit
-
sh.status.autosplit
indicates whether autosplit is currently enabled.指示当前是否启用了自动拆分。
Starting in MongoDB 6.1, automatic chunk splitting is not performed. 从MongoDB 6.1开始,不执行自动区块分割。This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation. 这是因为平衡政策的改进。自动拆分命令仍然存在,但不执行操作。For details, see Balancing Policy Changes.有关详细信息,请参阅平衡策略更改。
In MongoDB versions earlier than 6.1:在6.1之前的MongoDB版本中:
ThebalancerStart
command and themongo
shell helper methodssh.startBalancer()
andsh.setBalancerState(true)
also enable auto-splitting for the sharded cluster.balancerStart
命令和mongo
-shell辅助方法sh.startBalancer()
和sh.setBalancerState(true)
也为分片集群启用了自动拆分。
To disable auto-splitting when the balancer is enabled, you can use要在启用平衡器时禁用自动拆分,可以使用sh.disableAutoSplit()
.sh.disableAutoSplit()
。ThebalancerStop
command and themongo
shell helper methodssh.stopBalancer()
andsh.setBalancerState(false)
also disable auto-splitting for the sharded cluster.balancerStop
命令和mongoshell助手方法sh.stopBalancer()
和sh.setBalancerState(false)
也禁用了分片集群的自动拆分。
To enable auto-splitting when the balancer is disabled, you can use要在禁用平衡器时启用自动拆分,可以使用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)
对自动拆分没有影响。
Shards分片
sh.status.shards.tags
-
Thetags
displays all the tags for the shard. The field only displays if the shard has tags.tags
将显示分片的所有标记。该字段仅在分片具有标记时显示。
sh.status.shards.state
-
如果分片不具有分片意识,则为0
if the shard is not shard aware.0
。如果分片是分片感知的,则为1
if the shard is shard aware.1
。
Balancer平衡器
Starting in MongoDB 6.1, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation. 从MongoDB 6.1开始,不执行自动区块分割。这是因为平衡政策的改进。自动拆分命令仍然存在,但不执行操作。For details, see Balancing Policy Changes.有关详细信息,请参阅平衡策略更改。
In MongoDB versions earlier than 6.1:在6.1之前的MongoDB版本中:
ThebalancerStart
command and themongo
shell helper methodssh.startBalancer()
andsh.setBalancerState(true)
also enable auto-splitting for the sharded cluster.balancerStart
命令和mongo-shell辅助方法sh.startBalancer()
和sh.setBalancerState(true)
也为分片集群启用了自动拆分。
To disable auto-splitting when the balancer is enabled, you can use要在启用平衡器时禁用自动拆分,可以使用sh.disableAutoSplit()
.sh.disableAutoSplit()
。ThebalancerStop
command and themongo
shell helper methodssh.stopBalancer()
andsh.setBalancerState(false)
also disable auto-splitting for the sharded cluster.balancerStop
命令和mongoshell助手方法sh.stopBalancer()
和sh.setBalancerState(false)
也禁用了分片集群的自动拆分。
To enable auto-splitting when the balancer is disabled, you can use要在禁用平衡器时启用自动拆分,可以使用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
displaysNo recent migrations
.migration-results-for-the-last-24-hours
显示no recent migration
。migration-results-for-the-last-24-hours
includes all migrations, including those not initiated by the balancer.包括所有迁移,包括未由平衡器启动的迁移。
Databases数据库
sh.status.databases._id
-
The
_id
displays the name of the database.显示数据库的名称。
sh.status.databases.partitioned
-
Starting in MongoDB 6.0 and feature compatibility version (fCV) 6.0, the从MongoDB 6.0和功能兼容性版本(fCV)6.0开始,分区标志只与以前的版本保持向后兼容性。默认情况下,无论partitioned
flag only maintains backward compatibility with previous versions. By default, all databases are enabled for sharding regardless of thepartitioned
value.partitioned
如何,所有数据库都会启用分片。
sh.status.databases.primary
-
Theprimary
displays the primary shard for the database.primary
显示数据库的主分片。
sh.status.databases.version
-
Theversion
displays the version information for the database:version
显示数据库的版本信息:{ "uuid" : UUID("cc250b66-8638-49f7-a2e8-c6f1220b9d7a"), "lastMod" : 1 }
where:其中:uuid
is the database identifier.是数据库标识符。lastMod
is the database version.是数据库版本。
Sharded Collection分片集合
sh.status.databases.<collection>.shard-key
-
Theshard-key
displays the shard key specification document.shard-key
显示分片键规范文档。
sh.status.databases.<collection>.unique
-
Theunique
displays whether MongoDB enforces uniqueness on the shard key values (i.e. whether the underlying shard key index is unique).unique
显示MongoDB是否对分片键值强制执行唯一性(即底层分片键索引是否唯一)。
sh.status.databases.<collection>.balancing
-
Thebalancing
displays whether balancing is enabled (true
) or disabled (false
) for the collection.balancing
显示集合的平衡是启用(true
)还是禁用(false
)。
sh.status.databases.<collection>.chunks
-
Thechunks
lists all the shards and the number of chunks that reside on each shard.chunks
列出了所有分片以及每个分片上的块数。
sh.status.databases.<collection>.chunk-details
-
Thechunk-details
lists the details of the chunks [1]:chunk-details
列出了区块的详细信息[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
-
Thetag
lists the details of the tags associated with a range of shard key values.tag
列出了与一系列分片键值相关联的标记的详细信息。
See also: 另请参阅:
[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) 。 |