On this page本页内容
sh.balancerCollectionStatus(namespace)
New in version 4.4.在版本4.4中新增。
Returns a document that contains information about whether the chunks of a sharded collection are balanced (i.e. do not need to be moved) as of the time the command is run or need to be moved because of draining shards, zone violation or imbalance of chunks across shards.返回一个文档,其中包含有关在运行命令时分片集合的块是否平衡(即不需要移动)的信息,或者由于分片之间的分片排出、区域冲突或块不平衡而需要移动的信息。
The mongosh
method sh.balancerCollectionStatus()
wraps the balancerCollectionStatus
command.mongosh
方法sh.balancerCollectionStatus()
包装了balancerCollectionStatus
命令。
The sh.balancerCollectionStatus()
has the following form:sh.balancerCollectionStatus()
具有以下形式:
sh.balancerCollectionStatus( <namespace> )
The sh.balancerCollectionStatus()
method takes the following parameter:sh.balancerCollectionStatus()
方法采用以下参数:
namespace | String |
|
When running with access control, the user must have the 在使用访问控制运行时,用户必须对数据库和/或集合具有enableSharding
privilege actions on database and/or collection to run the method. enableSharding
权限操作才能运行该方法。That is, a user must have a role that grants the following privilege:也就是说,用户必须具有授予以下权限的角色:
{ resource: { db: <database>, collection: <collection> }, actions: [ "enableSharding" ] }
The built-in 内置的clusterManager
role provides the appropriate privileges.clusterManager
角色提供适当的权限。
To check whether the chunks of a sharded collection 要检查分片集合test.contacts
is currently in balance, connect to a mongos
instance and issue the following:test.contacts
的块当前是否平衡,请连接到mongos
实例并发出以下命令:
sh.balancerCollectionStatus("test.contacts")
If the chunks for the collection do not need to be moved, the method returns an output similar to the following:如果不需要移动集合的块,该方法将返回类似于以下内容的输出:
{ "balancerCompliant" : true, "ok" : 1, "operationTime" : Timestamp(1583193238, 1), "$clusterTime" : { "clusterTime" : Timestamp(1583193238, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
For the description of the output, see balancerCollectionStatus Output.有关输出的描述,请参阅balancerCollectionStatus
输出。