Documentation Home
MySQL 9.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 259.0Kb
Man Pages (Zip) - 366.2Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 Reference Manual  / ...  / Replication  / Configuring Replication  / MySQL Multi-Source Replication  /  Adding GTID-Based Sources to a Multi-Source Replica

19.1.5.3 Adding GTID-Based Sources to a Multi-Source Replica

These steps assume you have enabled GTIDs for transactions on the sources usinggtid_mode=ON, created a replication user, ensured that the replica is usingTABLE based replication applier metadata repositories, and provisioned the replica with data from the sources if appropriate.

UseCHANGE REPLICATION SOURCE TO to configure a replication channel for each source on the replica (seeSection 19.2.2, “Replication Channels”). TheFOR CHANNEL clause is used to specify the channel. For GTID-based replication, GTID auto-positioning is used to synchronize with the source (seeSection 19.1.3.3, “GTID Auto-Positioning”). TheSOURCE_AUTO_POSITION option is set to specify the use of auto-positioning.

For example, to addsource1 andsource2 as sources to the replica, use themysql client to issue the statement twice on the replica, like this:

mysql> CHANGE REPLICATION SOURCE TO SOURCE_HOST="source1", SOURCE_USER="ted", \SOURCE_PASSWORD="password", SOURCE_AUTO_POSITION=1 FOR CHANNEL "source_1";mysql> CHANGE REPLICATION SOURCE TO SOURCE_HOST="source2", SOURCE_USER="ted", \SOURCE_PASSWORD="password", SOURCE_AUTO_POSITION=1 FOR CHANNEL "source_2";

To make the replica replicate only databasedb1 fromsource1, and only databasedb2 fromsource2, use themysql client to issue theCHANGE REPLICATION FILTER statement for each channel, like this:

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

For the full syntax of theCHANGE REPLICATION FILTER statement and other available options, seeSection 15.4.2.1, “CHANGE REPLICATION FILTER Statement”.