You can use DTS to track data changes in real time. This feature applies to the following scenarios: 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.
- If you use tools such as gh-ost or pt-online-schema-change to perform DDL changes, these changes will not be subscribed to. Therefore, when a client writes the consumed data to destination table, writing may fail due to the table structure inconsistency.
- If the source database to be subscribed exists in another task (for example, the database exists in a running data migration task), you may subscribe to data other than the subscription object. In such scenarios, you need to filter unwanted data in the change tracking clients.
- 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 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 and network type for the change tracking
Section Parameter Description N/A Task Name 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 Instance Type Select RDS Instance.Note If your source database is a user-created MySQL database, you must prepare the environments that are required for the source database. For more information, see Preparation overview. Database Type The value of this parameter is set to MySQL. You cannot change the value of this parameter. 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 for 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. Network Type
Select the network type of the change tracking task.Note
- We recommend that you select the same network type as the ECS instance on which the change tracking client is installed For example, if the ECS instance is deployed in a VPC, select VPC as the network type and specify the VPC and VSwitch.
- If you track data changes over internal networks, the network latency is minimal.
- Click Set Whitelist and Next. The following table describes the details about whitelist settings.
Instance type of the source database Description ApsaraDB RDS for MySQL The CIDR blocks of DTS servers are automatically added to the whitelist of the source ApsaraDB RDS for MySQL instance. This ensures that DTS servers can connect to the source RDS instance. User-created MySQL database hosted on ECS The CIDR blocks of DTS servers are automatically added to an inbound rule of the ECS instance. This ensures that DTS servers can connect to the source instance.
- User-created MySQL database with a public IP address
- User-created MySQL database connected over Express Connect, VPN Gateway, or Smart Access Gateway
If a whitelist is configured for the user-created database, you must add the CIDR blocks of DTS servers to the whitelist of the database. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
- 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 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 tracks only 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.
In the Required Objects section, select the required objects 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 task fails to pass the precheck, click the icon next to each failed item to view details. Troubleshoot the issues based on the causes and run the precheck again.
- Close the Precheck dialog box after the following message is displayed: The precheck is passed.
After the change tracking task is configured, DTS performs initial change tracking, which takes about one minute. After initial change tracking, you can create consumer groups and consume tracked data.