balancerStart
定义
balancerStart
Starts the balancer thread. The command does not wait for a balancing round to start.
提示
在
mongosh
中,该命令也可通过sh.startBalancer()
辅助方法运行。辅助方法对
mongosh
用户来说很方便,但它们返回的信息级别可能与数据库命令不同。如果不追求方便或需要额外的返回字段,请使用数据库命令。从 MongoDB 6.0.3 开始,不再执行自动数据块分割。这是因为均衡策略的改进。自动分割命令仍然存在,但不执行操作。
In MongoDB versions earlier than 6.1, the command enables auto-splitting for the sharded cluster. To disable auto-splitting when the balancer is enabled, you can use
sh.disableAutoSplit()
.
兼容性
此命令可用于以下环境中托管的部署:
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 毫秒。 |
例子
To start the balancer thread, connect to a mongos
instance
and issue the following command:
db.adminCommand( { balancerStart: 1 } )
另请参阅: