Add new mysql slave to an existing replication

A new slave can be added to an existing replication without stopping the master. Setup the new slave by making a copy of existing slave. Dont forget to change the server-id value .

To copy an existing slave :

  1. Stop the slave : >mysqladmin shutdown

  2. Copy the data directory from existing slave to new slave. Using rsync..

3.In order to avoid error message like the one below, use same –relay-log on the new slave as the one used in the existing slave.

Neither –relay-log nor –relay-log-index were used; so
replication may break when this MySQL server acts as a slave and has his hostname
changed!! Please use ‘–relay-log=new_slave_hostname-relay-bin’ to avoid this problem.

As an alsternative step 4 and 5 will avoid the above warning.

  1. Issue stop slave on the new slave

  2. Copy contents of existing slave’s relay log index file into the new slaves relay log index file overwriting existing.

  3. Copy the master.info and relay-log.info files from the existing slave to the new slave.

  4. Start the existing slave

8.On the new slave make sure you have unique value for server-id.

  1. Start new slave. The slave will use information in master.info to start replication process.