Updated on 2024-09-25 GMT+08:00
How Do I Disable the Balancer?
Before using the DRS service to migrate collections between sharded clusters, you must disable the balancer of the collections to be migrated.
- You can disable the DDS cluster balancer by calling an API. For details, see Enabling or Disabling Cluster Balancing or contact DDS technical support. For a self-built MongoDB database, refer to the following steps.
- After the migration is complete, enable the balancer. The balancer is disabled during the migration, generating different numbers of chunks on each shard of the source database. After the balancer is enabled, chunks will be distributed between shards in the cluster, which may affect the performance of the source database.
Procedure
- Log in to a database through mongo shell.
- Run the following command in the command window of the mongos node to switch to the config database:
use config
- Run the following commands to check whether the balancer can be disabled:
while( sh.isBalancerRunning() ) { print("waiting..."); sleep(1000); }
- If the command output is waiting, the balancer is migrating chunks. In this case, do not disable the balancer. Otherwise, data inconsistency may occur.
Figure 1 Viewing the command output
- If no command output is displayed, the balancer is not migrating any chunks. In this case, you can disable the balancer:
- If the command output is waiting, the balancer is migrating chunks. In this case, do not disable the balancer. Otherwise, data inconsistency may occur.
- Disable the balancer.
- If you migrate the entire DB instance, run the following command to disable the balancer.
sh.stopBalancer()
- If you need to disable the balancer of the sharded collections to be migrated, run the following command:
sh.disableBalancing("database.collection")
database.collection indicates the namespace of the collection to be migrated.
- If you migrate the entire DB instance, run the following command to disable the balancer.
Parent topic: Real-Time Migration
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot