Switch DM-worker Connection between Upstream MySQL Instances
When the upstream MySQL instance that DM-worker connects to needs downtime maintenance or when the instance crashes unexpectedly, you need to switch the DM-worker connection to another MySQL instance within the same migration group.
For more details on GTID set, refer to MySQL documentation.
Switch DM-worker connection via virtual IP
When DM-worker connects the upstream MySQL instance via a virtual IP (VIP), switching the VIP connection to another MySQL instance means switching the MySQL instance connected to DM-worker, without the upstream connection address changed.
To switch one upstream MySQL instance (when DM-worker connects to it via a VIP) to another, perform the following steps:
- Use the
query-statuscommand to get the GTID sets (syncerBinlogGtid) corresponding to the binlog that the current processing unit of binlog replication has replicated to the downstream. Mark the sets asgtid-S. - Use the
SELECT @@GLOBAL.gtid_purged;command on the new MySQL instance to get the GTID sets corresponding to the purged binlogs. Mark the sets asgtid-P. - Use the
SELECT @@GLOBAL.gtid_executed;command on the new MySQL instance to get the GTID sets corresponding to all successfully executed transactions. Mark the sets asgtid-E. - Make sure that the following conditions are met. Otherwise, you cannot switch the DM-work connection to the new MySQL instance:
gtid-Scontainsgtid-P.gtid-Pcan be empty.gtid-Econtainsgtid-S.
- Use
pause-taskto pause all running tasks of data migration. - Change the VIP for it to direct at the new MySQL instance.
- Use
resume-taskto resume the previous migration task.
Change the address of the upstream MySQL instance that DM-worker connects to
To make DM-worker connect to a new MySQL instance in the upstream by modifying the DM-worker configuration, perform the following steps:
- Use the
query-statuscommand to get the GTID sets (syncerBinlogGtid) corresponding to the binlog that the current processing unit of binlog replication has replicated to the downstream. Mark this sets asgtid-S. - Use the
SELECT @@GLOBAL.gtid_purged;command on the new MySQL instance to get the GTID sets corresponding to the purged binlogs. Mark this sets asgtid-P. - Use the
SELECT @@GLOBAL.gtid_executed;command on the new MySQL instance to get the GTID sets corresponding to all successfully executed transactions. Mark this sets asgtid-E. - Make sure that the following conditions are met. Otherwise, you cannot switch the DM-work connection to the new MySQL instance:
gtid-Scontainsgtid-P.gtid-Pcan be empty.gtid-Econtainsgtid-S.
- Use
stop-taskto stop all running tasks of data migration. - Use the
operator-source stopcommand to remove the source configuration corresponding to the address of the old MySQL instance from the DM cluster. - Update the address of the MySQL instance in the source configuration file and use the
operate-source createcommand to reload the new source configuration in the DM cluster. - Use
start-taskto restart the migration task.