On this page本页内容
sh.setBalancerState(state) Enables or disables the balancer. 启用或禁用平衡器。Starting in MongoDB 4.2, the method also enables auto-splitting if enabling the balancer and disables auto-splitting if disabling the balancer.从MongoDB 4.2开始,如果启用平衡器,该方法还启用自动拆分,如果禁用平衡器,则禁用自动拆分。
Use 使用sh.getBalancerState() to determine if the balancer is currently enabled or disabled and sh.isBalancerRunning() to check its current state.sh.getBalancerState()确定平衡器当前是否已启用或禁用,使用sh.isBalancerRunning()检查其当前状态。
You can only run 只能在sh.setBalancerState() on a mongos instance. mongos实例上运行sh.setBalancerState()。如果在sh.setBalancerState() errors if run on mongod instance.mongod实例上运行,则sh.setBalancerState()会出错。
The sh.setBalancerState() method has the following parameter:sh.setBalancerState()方法具有以下参数:
state | boolean | true to enable the balancer and false to disable it.true以启用平衡器,将其设置为false以禁用平衡器。 |