Adding a Slave to a Running Mashery Local Cluster
Procedure
-
Register the Mashery Local Instance as new Slave.
Follow the instructions in the topic "Configuring a Local Mashery Slave" in this guide to register the Mashery Local Instance as Slave, to finish the settings for the Slave in Cluster Manager.
-
Exclude existing Slave or Master Instance from taking traffic.
In order to prepare mysqldump, it is recommended that the user exclude an existing Slave Instance from Load Balancer, so that the Master Instance and other Slave Instances can keep taking traffic. In the case of high availability setup, the user can also switch traffic from the primary cluster to a backup cluster, then stop proxy service in the Master Instance of the primary cluster.
-
Stop "proxy" Service in existing Slave or Master Instance.
Use the following command:
docker exec -it ml-tm nohup service javaproxy stop
-
Initialize New Slave Database.
-
Initialize New Slave Database by importing mysqldump file.
The user should prepare mysqldump in the existing Slave Instance.
- The user generates mysqldump in existing Slave instance:
mysqldump -u masherybackup -p'password_for_masherybackup' --opt --dump-slave --master-data --single-transaction onprem > /mnt/dump/onprem.sql md5sum /mnt/dump/onprem.sql
- Or, the user generates mysqldump in existing Master instance:
mysqldump -u masherybackup -p'password_for_masherybackup' --opt --master-data --single-transaction onprem > /mnt/dump/onprem.sql md5sum /mnt/dump/onprem.sql
- The user generates mysqldump in existing Slave instance:
-
Import mysqldump to new Slave instance.
Copy mysqldump to new Slave instance:
- First transfer the mysqldump from remote host to the current host.scp root@remote_host:<Absolute path of onprem.sql on remote host> <LOCAL DEST DIR>
- Now copy the mysqldump file from host machine to DB container's file systemdocker cp <LOCAL DEST DIR>/onprem.sql ml-db:/mnt/dump/
- md5sum /mnt/dump/onprem.sql
Stop MySQL Slave:mysql -u masheryonprem -p'password_for_masheryonprem' onprem stop slave
Import mysqldump to new Slave Instance:mysql -u masheryonprem -p'password_for_masheryonprem' onprem < /mnt/dump/onprem.sql
-
Initialize New Slave Database by streaming mysqldump.
- Stop Slave in new Slave Instance:
mysql -u masheryonprem -p'password_for_masheryonprem' onprem stop slave
- Import mysqldump to new Slave Instance via Stream:
- Stream from existing Slave Instance:
mysqldump -h remote_host_internal_ip -u mashonpremrepl -p'password_for_mashonpremrepl' \ --opt --dump-slave --single-transaction onprem \ | mysql -u masheryonprem -p'password_for_masheryonprem' onprem
- Stream from existing Master Instance:
mysqldump -h remote_host_internal_ip -u mashonpremrepl -p'password_for_mashonpremrepl' \ --opt --master-data --single-transaction onprem \ | mysql -u masheryonprem -p'password_for_masheryonprem' onprem
- Stream from existing Slave Instance:
- Stop Slave in new Slave Instance:
-
Initialize New Slave Database by importing mysqldump file.
-
Restart MySQL Service:
service mysqld restart
-
Start "proxy" Service:
docker exec -it ml-tm nohup service javaproxy start
Copyright © Cloud Software Group, Inc. All rights reserved.