Use the create reverse task feature

更新时间:
复制 MD 格式

This topic describes how to use the Create Reverse Task feature of Data Transmission Service (DTS) to send data back to a source database in disaster recovery or service switchover scenarios.

Prerequisites

Usage notes

  • You can create a reverse instance only for a data synchronization instance between SQL Server databases, MySQL databases, or ApsaraDB for MongoDB instances. You can select only Incremental Data Synchronization for the Synchronization Types parameter when you configure the reverse instance.

    Important

    If the original instance is a data synchronization instance between SQL Server databases or between MySQL databases, this feature is available only for the destination ApsaraDB databases.

  • The data that is directly written to the destination database of the original synchronization instance before a reverse instance is created is not synchronized.

  • A precheck is immediately performed after a reverse instance is created. After the precheck is passed, DTS collects the incremental data but does not write the data to the source database of the original synchronization instance.

  • You must pause the forward synchronization instance before starting the reverse instance. Otherwise, this may cause data inconsistency or the instance fails to run.

  • You can create only one reverse instance for each synchronization instance. After the reverse instance is started, the original synchronization instance cannot be directly started.

  • You cannot create a reverse instance for a cross-border synchronization instance.

  • Ensure that the tables to be synchronized have primary keys or UNIQUE constraints, and that all fields in the constraints are unique. Otherwise, duplicate data may occur.

  • Set the retention period of binary logs based on the estimated recovery time after an exception occurs in the production database.

  • If the original task uses a Serverless instance, the reverse task uses a pay-as-you-go instance of the micro specification. If the original task uses a subscription or pay-as-you-go instance, the reverse task uses the same billing method and specifications as the original task by default.

  • If the original task is a cross-region synchronization task, you must switch to the source region of the forward task to view the reverse task in the synchronization task list.

  • You are charged for a reverse task even when it is paused.

  • It is normal for the Status of a DTS task to be Retrying if an exception prevents a connection to the business database.

Procedure

Database disaster recovery scenario

  1. Create a forward synchronization task to synchronize data from the production database to the disaster recovery database based on your service requirements.

    Select specifications as needed. Set the Retry Time for Failed Connections parameter based on the estimated recovery time for your database. For more information about creating a forward synchronization task, see One-way synchronization between RDS MySQL instances, Synchronization between RDS SQL Server instances, Synchronize data from an ApsaraDB for MongoDB replica set instance to another replica set or sharded cluster instance, and Synchronize data from an ApsaraDB for MongoDB sharded cluster instance to an ApsaraDB for MongoDB replica set or sharded cluster instance.

  2. Wait until the forward synchronization task's Status is Running, and then create a reverse task.

    1. In the Data Synchronization Tasks list, locate your forward synchronization task.

    2. Find the data synchronization instance that you want to manage.

    3. In the Note message, click OK.

      Wait until the precheck of the reverse instance is complete and Performing Initial Synchronization is displayed in the Status column of the instance.

      Note
      • If Auto Refresh is disabled, you must click the 刷新 icon above the Actions column to refresh the state of the reverse instance.Status

      • If the precheck fails, click View Cause. On the page that appears, click View Details in the Check Result column of the failed check item. Follow the instructions to resolve the issue and run the precheck again.

    4. After the reverse task is created, no further operations are required.

  3. If the production database cannot be connected due to an exception, perform the following steps to restore your service.

    1. Pause the original DTS task.

      1. On the Data Synchronization Tasks page, find the original DTS task.

      2. To the right of the task, choose 更多设置 > Pause Task.

      3. In the Note dialog box, click OK.

      4. In the Task Paused dialog box, click OK.

    2. Switch your services to the disaster recovery database.

    3. Start the reverse instance.

      1. On the Data Synchronization Tasks page, click the ID of the reverse instance.

      2. In the Actions column, click the 更多设置 icon and select Start Reverse Task.

      3. In the Note message, click OK.

  4. After the production database is restored, perform the following steps to switch your services back to the production database and resume the synchronization tasks.

    1. Switch your services back to the original production database.

    2. Wait until the reverse task has no latency, and then pause the reverse task.

      The reverse task synchronizes data that is written to the disaster recovery database back to the original production database.

    3. After the reverse task is paused, you can start the original forward synchronization task.

Service switchover scenario

  1. Create a reverse synchronization task.

    1. In the Data Synchronization Tasks list, find the forward synchronization task (the original DTS task).

    2. Find the data synchronization instance that you want to manage.

    3. In the Note message, click OK.

      Wait until the precheck of the reverse instance is complete and Performing Initial Synchronization is displayed in the Status column of the instance.

      Note
      • If Auto Refresh is disabled, you must click the 刷新 icon above the Actions column to refresh the state of the reverse instance.Status

      • If the precheck fails, click View Cause. On the page that appears, click View Details in the Check Result column of the failed check item. Follow the instructions to resolve the issue and run the precheck again.

    4. After the reverse synchronization task is created, no further operations are required.

  2. Wait until the Incremental Data Collection module is running with zero latency.

    You can click the ID of a reverse synchronization task. On the Task Management page, you can view the status and latency of the module in the Progress section.

  3. Stop writing business data.

    To prevent data loss, you must temporarily stop your services and prohibit new data from being written to the database.

  4. Pause the original DTS task.

    1. On the Data Synchronization Tasks page, find the original DTS task.

    2. To the right of the task, choose 更多设置 > Pause Task.

    3. In the Note dialog box, click OK.

    4. In the Task Paused dialog box, click OK.

  5. Switch your services to the destination database of the forward synchronization task.

  6. Start the reverse instance.

    1. On the Data Synchronization Tasks page, click the ID of the reverse instance.

    2. In the Actions column, click the 更多设置 icon and select Start Reverse Task.

    3. In the Note message, click OK.

  7. You can end or release the forward synchronization task.

    For more information, see End a DTS task and Release a DTS task.

FAQ

  • How do I select specifications when I create a forward synchronization task?

    We recommend that you select the smallest specification (micro). After you create the reverse task, you can upgrade the task specifications based on your service volume. For more information about how to upgrade specifications, see Upgrade the link specifications of a task.

  • What do I do if a DTS task is in the Failed state after the production database is restored?

    You can start the DTS task. For more information, see Start a DTS task.