Workload switchover procedure

更新时间:
复制 MD 格式

Use this procedure to perform a workload switchover and create a rollback solution, minimizing business impact during data migration.

Prerequisites

A data migration task is configured, and its status is Migrating or Completed. For configuration examples, see Migration scenarios.

Usage notes

  • Perform the workload switchover during off-peak hours, as you must stop business applications and database writes.

  • Create a dedicated database account with the necessary permissions for data migration. This helps you identify session information and improves security.

Procedure

  1. Wait for the data migration task to enter the Incremental Data Migration phase. The status must show Undelayed or a latency of less than 5 seconds.

    Note

    If you did not select incremental data migration when you configured the task, the task does not enter the Incremental Data Migration phase and automatically terminates. In this case, you must stop all application traffic to the source database before you start the migration. Then, skip to step 5.

  2. Stop all application traffic and prevent new write operations to the source database.

  3. Log on to the source database and run the command for your database type to verify that no new sessions are performing write operations.

    MySQL

    show processlist;

    SQL Server

    select * from sys.dm_exec_connections;

    Oracle

    select sid,serial#,username,program,machine,status from v$session;

    PostgreSQL

    select * from pg_stat_activity;

    Redis

    CLIENT LIST

    MongoDB

    use admin
    db.runCommand({currentOp: 1, $all:[{"active" : true}]})
    Note

    The results of these commands include the processes or sessions that DTS uses to connect to the source database.

  4. Wait for the Incremental Data Migration status to return to Undelayed and remain stable for at least one minute. Then, manually pause the migration task.

    Warning

    While the task is paused, do not restart it. Restarting the task can cause data inconsistency.

    When the incremental sync status shows No delay, select the checkbox for the target migration task, and then click Pause in the batch operations bar at the bottom.

  5. While your applications are still stopped, re-enable write permissions on the source database.

  6. Create and start a reverse data migration task to migrate incremental data from the destination database back to the source. This task provides a rollback solution. If issues occur after switching your applications to the destination database, you can switch the workloads back to the original source database.

    For example, if the original task migrated data from a self-managed MySQL database to an ApsaraDB RDS for MySQL instance, see Migrate from ApsaraDB RDS for MySQL to self-managed MySQL for instructions on how to configure the reverse task. For the reverse task, select only incremental data migration.

    Warning

    When you configure the reverse data migration task, in the Migration Types and Objects section, select only incremental data migration. Then, select the databases or tables that you want to migrate back to the source database.

  7. After switching your applications to the destination database, terminate or release the original DTS data migration task.

  8. The reverse data migration task continuously replicates incremental data from the destination back to the source database. This allows you to switch your applications back to the source at any time if issues arise.

Next steps

After your applications run stably on the destination database for a period and you verify that all business features work correctly, you can terminate the reverse data migration task. For details, see Terminate a data migration task.

Warning

The database account used for data migration has read and write permissions. To ensure database security, delete this account or revoke its write permissions after the migration is complete.

FAQ

  • Q: What should I do if my application has issues after the workload switchover?

    A: The reverse data migration task continuously replicates incremental data from the destination database back to the source. If you encounter any issues, you can switch your applications back to the source database at any time.

  • Q: If the workload switchover fails, how can I ensure data consistency in the source database?

    A: We recommend that you back up the source database before you begin the switchover.

  • Q: After the switchover, what should I do if new data is accidentally written to the source database?

    A: Use data verification to identify and manually correct any data discrepancies between the source and destination databases.