In order to disable the balancer, especially before an operation that might impact sharding, you not only need to stop the balancer but you must also wait until it has stopped running before proceeding with the operation. Examples of where this is required would be prior to performing a backup, splitting a chunk, or manually migrating a chunk.
To disable the balancer, proceed as follows:
- Open a mongo shell onto a mongos instance with sufficient cluster administration rights.
- Issue the sh.stopBalancer() command to stop the balancer. You can supply an optional argument string representing the database and collection if you wish to disable balancing only on a specific collection. The command can be seen in the following code snippet:
sh.stopBalancer("DB.COLLECTION");
- Confirm the balancer state by running the following command. A value of false indicates the balancer is disabled:
sh.getBalancerState();
- If you...