Adding a Slave to a Running Mashery Local Cluster

The following section describes how to add a Slave to a running Mashery Local Cluster.

Procedure

  1. 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.
  2. 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.
  3. Stop "proxy" Service in existing Slave or Master Instance.
    Use the following command:
    docker exec -it ml-tm nohup service javaproxy stop
  4. Initialize New Slave Database.
    1. Initialize New Slave Database by importing mysqldump file.
      The user should prepare mysqldump in the existing Slave Instance.
      1. 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
      2. 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
    2. Import mysqldump to new Slave instance.
      Copy mysqldump to new Slave instance:
      1. 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>
      2. Now copy the mysqldump file from host machine to DB container's file systemdocker cp <LOCAL DEST DIR>/onprem.sql ml-db:/mnt/dump/
      3. 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
    3. Initialize New Slave Database by streaming mysqldump.
      1. Stop Slave in new Slave Instance:
        mysql -u masheryonprem -p'password_for_masheryonprem' onprem
        stop slave
      2. 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
          
  5. Restart MySQL Service:
    service mysqld restart
  6. Start "proxy" Service:
    docker exec -it ml-tm nohup service javaproxy start