sh.setBalancerState()
Description
sh.
setBalancerState
(state)- Enables or disables the balancer. Starting in MongoDB 4.2,the method also enables auto-splitting if enabling the balancer anddisables auto-splitting if disabling the balancer.
Use sh.getBalancerState()
to determine if the balancer iscurrently enabled or disabled and sh.isBalancerRunning()
to check its current state.
Important
You can only run sh.setBalancerState()
on amongos
instance. sh.setBalancerState()
errors if run on mongod
instance.
The sh.setBalancerState()
method has the followingparameter:
ParameterTypeDescriptionstate
booleanSet this to true
to enable the balancer and false
to disable it.
See also