sh.stopBalancer()
定义
sh.stopBalancer(timeout, interval)
在版本 6.1 中更改。
Disables the balancer in a sharded cluster.
从 MongoDB 6.0.3 开始,不再执行自动数据块分割。这是因为均衡策略的改进。自动分割命令仍然存在,但不执行操作。
In MongoDB versions earlier than 6.0.3,
sh.stopBalancer()
also disables auto-splitting for the sharded cluster.重要
mongosh 方法
本页面提供
mongosh
方法的相关信息。这不是数据库命令或特定语言驱动程序(例如 Node.js)的相关文档。有关数据库命令,请参阅
balancerStop
命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
该方法可以采用以下选项:
Parameter类型说明timeout
整型
Time limit for disabling the balancer.
默认为 60000 毫秒。
interval
整型
The interval (in milliseconds) at which to check if the balancing round has stopped.
If you omit both options, MongoDB disables the balancer indefinitely.
重要
Leaving the balancer disabled for extended periods of time can lead to unbalanced shards, which degrade cluster performance. Only disable the balancer if necessary, and ensure that you re-enable the balancer when maintenance is complete.
您只能在 实例上运行
sh.stopBalancer()
mongos
。sh.stopBalancer()
如果在mongod
实例上运行,则会出现 错误。The
mongosh
shell method is a wrapper around thebalancerStop
command.
兼容性
此方法可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M 0 、M 2和 M 5集群不支持此命令。 有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
行为
If a balancing round is in progress, the operation waits for balancing to complete.