Definition定义
balancerStartStarts the balancer thread. The command does not wait for a balancing round to start.启动平衡器线程。该命令不会等待平衡回合开始。Tip
In在mongosh, this command can also be run through thesh.startBalancer()helper method.mongosh中,此命令也可以通过sh.startBalancer()辅助方法运行。Helper methods are convenient for助手方法对mongoshusers, but they may not return the same level of information as database commands.mongosh用户来说很方便,但它们可能不会返回与数据库命令相同级别的信息。In cases where the convenience is not needed or the additional return fields are required, use the database command.如果不需要便利性或需要额外的返回字段,请使用database命令。Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation.从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在早于6.1的MongoDB版本中,该命令启用了分片集群的自动拆分。要在启用平衡器时禁用自动拆分,可以使用sh.disableAutoSplit().sh.disableAutoSplit()。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Syntax语法
You can only issue the 您只能对balancerStart against the admin database on a mongos instance.mongos实例上的admin数据库发出balancerStart。
The command has the following syntax:
db.adminCommand(
{
balancerStart: 1,
maxTimeMS: <number>
}
)
Command Fields命令字段
balancerStart | ||
maxTimeMS |
|
Example示例
To start the balancer thread, connect to a 要启动平衡器线程,请连接到mongos instance and issue the following command:mongos实例并发出以下命令:
db.adminCommand( { balancerStart: 1 } )