定义
balancerStart启动负载均衡器线程。 该命令不会等待均衡轮次开始。
从MongoDB 7.0 开始,启动负载均衡器还会为分片集群启用 AutoMerger。
提示
In
mongosh, this command can also be run through thesh.startBalancer()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:用于云中 MongoDB 部署的完全托管服务
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
You can only issue the balancerStart against the admin database on a mongos instance.
该命令具有以下语法:
db.adminCommand( { balancerStart: 1, maxTimeMS: <number> } )
命令字段
字段 | 类型 | 说明 |
|---|---|---|
| any | 任何值。 |
| 整型 | 可选。 启用负载均衡器的时间限制。 默认为 60000 毫秒。 |
例子
要启动负载均衡器线程,请连接到mongos实例并发出以下命令:
db.adminCommand( { balancerStart: 1 } )