To add another slave to an existing replication configuration,
you can do so without stopping the master. Instead, set up the
new slave by making a copy of an existing slave, except that you
configure the new slave with a different
To duplicate an existing slave:
Shut down the existing slave:
Copy the data directory from the existing slave to the new
slave. You can do this by creating an archive using
WinZip, or by
performing a direct copy using a tool such as
cp or rsync. Ensure
that you also copy the log files and relay log files.
A common problem that is encountered when adding new replication slaves is that the new slave fails with a series of warning and error messages like these:
071118 16:44:10 [Warning] 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. 071118 16:44:10 [ERROR] Failed to open the relay log './
old_slave_hostname-relay-bin.003525' (relay_log_pos 22940879) 071118 16:44:10 [ERROR] Could not find target log during relay log initialization 071118 16:44:10 [ERROR] Failed to initialize the master info structure
This situation can occur if the
--relay-log option is not
specified, as the relay log files contain the host name as
part of their file names. This is also true of the relay log
index file if the
--relay-log-index option is
not used. See Section 17.1.4, “Replication and Binary Logging Options and Variables”, for
more information about these options.
To avoid this problem, use the same value for
--relay-log on the new slave
that was used on the existing slave. If this option was not
set explicitly on the existing slave, use
If this is not possible, copy the existing slave's relay log
index file to the new slave and set the
--relay-log-index option on
the new slave to match what was used on the existing slave.
If this option was not set explicitly on the existing slave,
Alternatively, if you have already tried to start the new
slave after following the remaining steps in this section
and have encountered errors like those described previously,
then perform the following steps:
If you have not already done so, issue a
STOP SLAVE on the new
If you have already started the existing slave again,
STOP SLAVE on the
existing slave as well.
Copy the contents of the existing slave's relay log index file into the new slave's relay log index file, making sure to overwrite any content already in the file.
Proceed with the remaining steps in this section.
Copy the master info and relay log info repositories (see Section 17.2.2, “Replication Relay and Status Logs”) from the existing slave to the new slave. These hold the current log coordinates for the master's binary log and the slave's relay log.
Start the existing slave.
On the new slave, edit the configuration and give the new
slave a unique
used by the master or any of the existing slaves.
Start the new slave. The slave uses the information in its master info repository to start the replication process.