对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

balancerStatus(数据库命令)

balancerStatus

返回包含负载均衡器状态信息的文档。

You can only issue the balancerStatus against the admin database.

提示

In mongosh, this command can also be run through the sh.isBalancerRunning() helper method.

Helper methods are convenient for mongosh users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

该命令具有以下语法:

db.adminCommand(
{
balancerStatus: 1
}
)

以下是该命令返回的文档示例:

{
"mode" : "full",
"inBalancerRound" : false,
"numBalancerRounds" : Long(86),
"ok" : 1
}
字段
说明

"mode"

一个字符串,用于指定负载均衡器线程是正在运行还是已停止。 可能的值为:

  • "full"
    负载均衡器线程正在运行,但不一定处于均衡轮次中。
  • “关闭”
    负载均衡器线程已停止。 在此模式下不会发生数据块均衡。

"inBalancerRound"

一个布尔值,指定负载均衡器是否处于均衡轮次中。 如果为inBalancerRound=true ,则现在正在分发数据段。

inBalancerRound 当 时,可以为truemode=off 。如果您在负载均衡器处于负载均衡轮次时关闭负载均衡器,服务器会让它完成而不是中断它。

"numBalancerRounds"

自配置服务器启动以来发生的负载均衡器回合数。 此值不会持久存在,并会在配置服务器重新启动时重置为 0。

连接到mongos实例并发出以下命令:

db.adminCommand( { balancerStatus: 1 } )
给本页内容打分