You can use Data Transmission Service (DTS) to track data changes in real time. This feature applies to the following scenarios: lightweight cache updates, business decoupling, asynchronous data processing, and synchronization of extract, transform, and load (ETL) operations. This topic describes how to track data changes from a Distributed Relational Database Service (DRDS) instance.

Prerequisites

A database is created in the DRDS instance based on one or more ApsaraDB RDS for MySQL instances, and the database version is 5.5 or 5.6.
Note DTS does not support DRDS databases that are created based on PolarDB for MySQL clusters.

Precautions

  • A change tracking instance stores the data that was generated in the last 24 hours and deletes expired data.
  • When the change tracking task is running, do not scale out or scale in the capacity of the DRDS instance, migrate frequently-accessed tables, change shard keys, or perform DDL operations on source objects. Otherwise, the change tracking task fails.
  • After the change tracking task is configured, you cannot reselect the objects for change tracking. For more information, see Modify objects for change tracking.
  • You can track data changes of specific tables. You cannot track data changes of an entire database.

Procedure

  1. Create a change tracking instance. For more information, see Purchase a DTS instance.
    Note On the buy page, set Source Database to DRDS.
  2. Log on to the DTS console.
  3. In the left-side navigation pane, click Change Tracking.
  4. At the top of the Change Tracking Tasks page, select the region where the change tracking instance resides.
    Select a region
  5. Find the change tracking instance and click Configure Channel in the Actions column.
  6. Configure the source database for the change tracking task.
    Configure the source database
    Section Parameter Description
    N/A Task Name DTS automatically generates a task name. We recommend that you specify an informative name for easy identification. You do not need to use a unique task name.
    Source Database Instance Type Select DRDS Instance.
    Database Type The value of this parameter is set to DRDS and cannot be changed.
    Instance Region The source region that you selected on the buy page. You cannot change the value of this parameter.
    DRDS Instance ID Select the ID of the source DRDS instance.
    Database Name Select the name of the source database in the DRDS instance.
    Database Account Enter the database account of the source DRDS instance.
    Database Password Enter the password of the database account.
  7. In the lower-right corner of the page, click Set Whitelist and Next.
    Note In this step, DTS adds the CIDR blocks of DTS servers to the whitelists of the source DRDS instance. This ensures that DTS servers can connect to the source instance.
  8. Select the data change types and objects.
    Select the data change types and objects
    Parameter Description
    Required Data Types
    • Data Updates

      DTS tracks data updates of the selected objects, including the INSERT, DELETE, and UPDATE operations.

    • Schema Updates

      DTS tracks the create, delete, and modify operations that are performed on all object schemas of the source instance. You must use the change tracking client to filter the required data.

    Required Objects Select one or more objects from the Required Objects section and click the Rightwards arrow icon to move the objects to the Selected section.
    Note
    • You can select tables as the objects for change tracking. You cannot select databases as the objects for change tracking.
    • After the change tracking task is configured, you cannot reselect the objects for change tracking. If you need to track data changes of tables that are not included in the selected objects, you must create another change tracking task for the tables.
  9. In the lower-right corner of the page, click Save and Precheck.
    Note
    • Before you can start the change tracking task, a precheck is performed. You can start the change tracking task only after the task passes the precheck.
    • If the task fails to pass the precheck, you can click the Info icon icon next to each failed item to view details. You can troubleshoot the issues based on the causes and run a precheck again.
  10. Close the Precheck dialog box after the following message is displayed: The precheck is passed.

What to do next

After the change tracking task is configured, DTS performs initial change tracking. After initial change tracking is completed, you can consume the tracked data. For more information, see Use the SDK demo code to consume tracked data.