定义
balancerStop禁用分片集群中的负载均衡器。 如果正在进行均衡轮次,则操作会等待均衡完成。
You can only issue the
balancerStopcommand against theadmindatabase on amongosinstance.从MongoDB 7.0 开始,停止负载均衡器还会禁用分片集群的 AutoMerger。
提示
In
mongosh, this command can also be run through thesh.stopBalancer()helper method.Helper methods are convenient for
mongoshusers, 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: The fully managed service for MongoDB deployments in the cloud
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { balancerStop: 1, maxTimeMS: <number> } )
命令字段
字段 | 类型 | 说明 |
|---|---|---|
| any | 任何值。 |
| 整型 | 禁用负载均衡器的时间限制。 默认为 60000 毫秒。 |
例子
要停止负载均衡器线程,请连接到mongos实例并发出以下命令:
db.adminCommand( { balancerStop: 1 } )