The change tracking feature allows you to track data changes in real time. With this feature, you can achieve lightweight cache updates, business decoupling, asynchronous data processing, and real-time data synchronization of extract, transform, and load (ETL) operations. This topic describes how to track data changes from ApsaraDB RDS for MySQL.
- A change tracking channel stores the data that is generated in the last 24 hours and deletes expired data.
- We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on objects when you track data changes. Otherwise, data changes may fail to be tracked.
- Create a change tracking instance. For more information, see Purchase a change tracking instance.
- Log on to the DTS console.
- In the left-side navigation pane, click Change Tracking.
- At the top of the Change Tracking Tasks page, select the region where the change tracking instance resides.
- Find the change tracking instance and click Configure Channel in the Actions column.
- Configure the source database information for the change tracking task.
Section Parameter Description Task Name N/A DTS automatically generates a task name. We recommend that you use an informative name for easy identification. You do not need to use a unique task name. Source Database Version Select Old. Instance Type Select RDS Instance. Database Type This parameter is set to MySQL and cannot be modified. Instance Region The region of the source instance. The region is the same as the region that you selected when you purchased the change tracking instance. You cannot change the value of this parameter. RDS Instance ID Select the ID of the RDS instance from which you want to track data changes.Note A read-only instance or temporary instance cannot be used as the source instance for change tracking. Database Account Enter the database account of the source RDS instance.Note
- The account must have the REPLICATION SLAVE permission, the REPLICATION CLIENT permission, the SHOW VIEW permission , and the permission to perform SELECT operations on the required objects.
- If the database engine of the source RDS instance is MySQL 5.5 or MySQL 5.6, you do not need to configure the database account or database password.
Database Password Enter the password for the database account of the source RDS instance.
- In the lower-right corner of the page, click Set Whitelist and Next.
Note The CIDR blocks of DTS servers are automatically added to the whitelist of the source RDS instance. This ensures that DTS servers can connect to the source RDS instance.
- In the Create Change Tracking Account message that appears, click Next after the account is created.
Note This step is required only when the database engine of the source RDS instance is MySQL 5.5 or MySQL 5.6. In this step, DTS creates a database account for change tracking in the source RDS instance.
- Select the data change types and objects.
Parameter Description Required Data Types
- Data Updates
If you select Data Updates, DTS tracks data updates of the selected objects, including INSERT, DELETE, and UPDATE operations.
- Schema Updates
If you select Schema Updates, DTS tracks the create, delete, and modify operations that are performed on all object schemas of the source instance. You need to use the change tracking client to filter the required data.
- If you select a database as the object, DTS tracks data changes of all objects, including new objects in the database.
- If you select a table as the object, DTS only tracks data changes in this table. In this case, if you want to track data changes of a new table, you must add the table to the objects for change tracking. For more information, see Modify objects for change tracking.
Select objects from the Required Objects section and click the icon to add the objects to the Selected section.Note The objects for change tracking include tables and databases.
- Data Updates
- In the lower-right corner of the page, click Save and Precheck.
- 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 PreCheck fails, click icon to view the failure details. Fix the issues based on the instructions and run the precheck again.
- 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, which takes about one minute. After initial change tracking, you can consume the tracked data. For more information, see Use SDK to consume data.