Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.3Mb
PDF (A4) - 39.3Mb
PDF (RPM) - 38.4Mb
HTML Download (TGZ) - 10.9Mb
HTML Download (Zip) - 11.0Mb
HTML Download (RPM) - 9.6Mb
Man Pages (TGZ) - 217.9Kb
Man Pages (Zip) - 327.5Kb
Info (Gzip) - 3.6Mb
Info (Zip) - 3.6Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  Adding a Binary Log Based Master to a Multi-Source Replication Slave

16.1.4.4 Adding a Binary Log Based Master to a Multi-Source Replication Slave

These steps assume that you have enabled binary logging on the master using --log-bin, the slave is using TABLE based replication repositories, and that you have enabled a replication user and noted the current binary log position. You need to know the current MASTER_LOG_FILE and MASTER_LOG_POSITION.

Use the CHANGE MASTER TO statement to configure a replication channel for each master on the replication slave (see Section 16.2.3, “Replication Channels”). The FOR CHANNEL clause is used to specify the channel. For example, to add master1 and master2 as masters to the replication slave, use the mysql client to issue the CHANGE MASTER TO statement twice on the slave, like this:

mysql> CHANGE MASTER TO MASTER_HOST="master1", MASTER_USER="ted", MASTER_PASSWORD="password", \
MASTER_LOG_FILE='master1-bin.000006', MASTER_LOG_POS=628 FOR CHANNEL "master_1";
mysql> CHANGE MASTER TO MASTER_HOST="master2", MASTER_USER="ted", MASTER_PASSWORD="password", \
MASTER_LOG_FILE='master2-bin.000018', MASTER_LOG_POS=104 FOR CHANNEL "master_2";

For the full syntax of the CHANGE MASTER TO statement and other available options, see Section 13.4.2.1, “CHANGE MASTER TO Statement”.

To make the replication slave replicate only database db1 from master1, and only database db2 from master2, use the mysql client to issue the CHANGE REPLICATION FILTER statement for each channel, like this:

mysql> CHANGE REPLICATION FILTER REPLICATE_WILD_DO_TABLE = ('db1.%') FOR CHANNEL "master_1";
mysql> CHANGE REPLICATION FILTER REPLICATE_WILD_DO_TABLE = ('db2.%') FOR CHANNEL "master_2";

For the full syntax of the CHANGE REPLICATION FILTER statement and other available options, see Section 13.4.2.2, “CHANGE REPLICATION FILTER Statement”.