Adding a Slave to 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 Administrator 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 Administrator 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:
    sudo monit stop proxy
  4. Initialize New Slave Database.
    1. Initialize New Slave Database by importing mysqldump file.
      The Administrator should prepare mysqldump in the existing Slave Instance.
      1. The administrator 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 Administrator 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
      3. Copy mysqldump to new Slave instance:
        scp administrator@remote_host:/mnt/dump/onprem.sql /mnt/dump
         
         
        md5sum /mnt/dump/onprem.sql
      4. Stop MySQL Slave:
        mysql -u masheryonprem -p'password_for_masheryonprem' onprem
        stop slave
      5. Import mysqldump to new Slave instance:
        screen
        mysql -u masheryonprem -p'password_for_masheryonprem' onprem < /mnt/dump/onprem.sql
    2. 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:
          screen
          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:
          screen
          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:
    sudo service mysqld restart
  6. Start "proxy" Service:
    sudo monit start proxy