This topic describes how to create a change tracking task to track data changes from a PolarDB-X 1.0 instance by using Data Transmission Service (DTS).

Prerequisites

  • A PolarDB-X 1.0 instance is created. For more information, see Create a instance and Create a database.
    Note The storage type of the PolarDB-X 1.0 instance must be ApsaraDB RDS for MySQL, such as custom ApsaraDB RDS instance or purchased ApsaraDB RDS instance. PolarDB for MySQL cannot be used as the storage type.
  • An internal endpoint is configured for the ApsaraDB RDS for MySQL instance.

Limits

Category Description
Limits on the source database
  • The source tables must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, DTS may track duplicate data changes. DTS does not allow you to track the schema updates of tables that have only UNIQUE constraints. We recommend that you select the tables that have PRIMARY KEY constraints.
  • If you select tables as the objects to be tracked, up to 500 tables can be tracked in a single change tracking task. If you run a change tracking task to track more than 500 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to track the tables in batches or configure a change tracking task for the entire database.
  • The following requirements for the binary logs of the ApsaraDB RDS for MySQL instances attached to a PolarDB-X 1.0 instance must be met:
    • The binary logging feature must be enabled. The value of the binlog_row_image parameter must be set to full. Otherwise, error messages are returned during the precheck, and the change tracking task cannot be started.

    • The binary logs of the source database must be stored for more than 24 hours. Otherwise, DTS may fail to obtain the binary logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. Make sure that you set the retention period of binary logs based on the preceding requirements. Otherwise, the Service Level Agreement (SLA) of DTS does not guarantee service reliability or performance.
  • A read-only instance or temporary instance cannot be used as the source instance for change tracking.
Other limits
  • When DTS tracks data changes from a PolarDB-X 1.0 instance, data is distributed across the attached ApsaraDB RDS for MySQL instances. DTS runs a subtask for each ApsaraDB RDS for MySQL instance. The status of the subtask is displayed on the Task Topology page.
  • A PolarDB-X 1.0 instance supports database and table sharding. If a DDL operation is performed on the source PolarDB-X 1.0 instance, the DDL operation is performed on all table shards. The progress of each subtask may be inconsistent with that of other subtasks. Therefore, the data tracked by DTS may contain duplicate DDL operations. If you consume these DDL operations multiple times, an exception may occur on the change tracking client. We recommend that you handle the exception as appropriate.
  • Limits on the objects for change tracking:
    • You can track data changes only at the table level.
    • After the change tracking task is configured, the objects for change tracking cannot be reselected. If you want to track the data changes of tables that are not included in the selected objects, you must create another change tracking task for the tables.
  • If you perform a primary/secondary switchover on the source database when the change tracking task is running, the task fails.
  • When the change tracking task is running, do not scale in or out the source instance, migrate frequently-accessed tables, change shards, or perform DDL operations. Otherwise, the change tracking task fails or data inconsistency occurs.
  • If the source database is used in another task such as a running data migration task, DTS may track the data changes of other objects. In this case, you must manually filter the tracked data on the change tracking client.
  • You must make sure that the precision settings for columns of the FLOAT or DOUBLE data type meet your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.
  • DTS does not track the DDL operations that are performed by using gh-ost or pt-online-schema-change. Therefore, the change tracking client may fail to write the consumed data to the destination tables due to schema conflicts.

Procedure

  1. Go to the Change Tracking Tasks page.
    1. Log on to the Data Management (DMS) console.
    2. In the top navigation bar, click DTS.
    3. In the left-side navigation pane, choose DTS (DTS) > Change Tracking.
    Note
  2. To the right of Change Tracking Tasks, select the region in which you want to create the change tracking task.
    Note If you use the new DTS console, you must select the region from the drop-down list to the right of Workbench on the Change Tracking Tasks page of the DTS console.
  3. Click Create Task. On the page that appears, configure the source database and the consumer network type.
    Warning After you select the source instance, we recommend that you read the limits displayed in the upper part of the page. This helps you create and run the change tracking task.
    Section Parameter Description
    N/A Task Name

    The task name that DTS automatically generates. We recommend that you specify a descriptive name that makes it easy to identify the task. You do not need to use a unique task name.

    The instance that you want to use. You can choose whether to select an existing instance based on your business requirements.
    • If you use an existing instance, DTS automatically applies the parameter settings of the instance.
      Note
      • To modify the connection settings of a template, you can edit the template when you configure the Select Instance parameter in the Source Database section.
      • To edit the template name, you can click Edit Template in the lower part of the Source Database section.
      • The modified connection template takes effect the next time you select the connection template. The database instance that you have configured by using the template is not affected.
    • If you do not use an existing instance, you must configure the following parameters.
    Source Database Select Instance
    Database Type The type of the source database. Select PolarDB-X 1.0.
    Access Method The access method of the source database. Select Alibaba Cloud Instance.
    Instance Region The region in which the PolarDB-X 1.0 instance resides.
    Instance ID The ID of the PolarDB-X 1.0 instance.
    Database Account The database account of the PolarDB-X 1.0 instance. The account must have read permissions on the objects for change tracking.
    Database Password

    The password of the database account.

    Save as Instance or Edit Template
    This parameter must be specified based on whether you select an existing instance for Select Instance.
    1. If you select an existing instance, you can click Edit Template to specify a custom template name.
      Note The modified connection template takes effect the next time you select the connection template. The database instance that you have configured by using the template is not affected.
    2. If you do not select an existing instance, click Save as Instance. In the dialog box that appears, set the name of the database connection and click OK. The connection settings of the database instance are saved as a template.
      Note We recommend that you specify a descriptive name that makes it easy to identify. You do not need to use a unique name.
    Consumer Network Type Network Type
    The Network Type parameter is set to VPC. You must select a VPC and a vSwitch. For more information, see VPCs.
    Note
    • After the task is created, you cannot change the settings in the Consumer Network Type section.
    • If your change tracking client is deployed in a VPC, we recommend that you select the same VPC and vSwitch as the client.
    • If you track data changes over internal networks, the network latency is minimal.
  4. In the lower part of the page, click Test Connectivity and Proceed.
    Warning
    • If the source or destination database instance is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, or is a self-managed database hosted on ECS, DTS automatically adds the CIDR blocks of DTS servers to the whitelist of the database instance or ECS security group rules. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases. If the source or destination database is a self-managed database on data centers or is from other cloud service providers, you must manually add the CIDR blocks of DTS servers to allow DTS to access the database.
    • If the CIDR blocks of DTS servers are automatically or manually added to the whitelist of the database, Alibaba Cloud database instance, or ECS security group rules, security risks may arise. Therefore, before you use DTS to migrate data, you must understand and acknowledge the potential risks and take preventive measures, including but not limited to the following measures: enhancing the security of your username and password, limiting the ports that are exposed, authenticating API calls, regularly checking the whitelist or ECS security group rules and forbidding unauthorized CIDR blocks, or connecting the database to DTS by using Express Connect, VPN Gateway, or Smart Access Gateway.
    • After the DTS task is complete or released, we recommend that you manually detect and remove the added CIDR blocks from the whitelist of the database, Alibaba Cloud database instance, or ECS security group rules.
  5. Select objects for the task and configure advanced settings.
    • Basic Settings
      Parameter Description
      Data Change Types
      • Data Update

        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.

      Source Objects Select one or more objects from the Source Objects section and click the Rightwards arrow icon to add the objects to the Selected Objects section.
      Note
      • You can track data changes only at the table level.
      • After the change tracking task is configured, the objects for change tracking cannot be reselected. If you want to track the data changes of tables that are not included in the selected objects, you must create another change tracking task for the tables.
    • Advanced Settings
      Parameter Description
      Set Alerts
      Select whether to set alerts for the change tracking task. If the task fails or the latency exceeds the threshold, the alert contacts will receive notifications. Valid values:
      • No: does not set alerts.
      • Yes: sets alerts. In this case, you must also set the alert threshold and alert contacts.
      Retry Time for Failed Connections
      The retry time for failed connections. Valid values: 10 to 1440. Unit: minutes. Default value: 120. We recommend that you set the retry time to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified time, DTS resumes the change tracking task. Otherwise, the change tracking task fails.
      Note
      • If an instance serves as the source database of multiple change tracking tasks, the less value of this parameter that is set for the instance takes precedence.
      • When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time range based on your business requirements. You can also release the DTS instance at your earliest opportunity after the source and destination instances are released.
  6. Click Next: Save Task Settings and Precheck in the lower part of the page.
    Note
    • Before you can start the change tracking task, DTS performs a precheck. You can start the change tracking task only after the task passes the precheck.
    • If the task fails to pass the precheck, click the Info icon icon next to each failed item to view details.
      • After you troubleshoot the issues based on the causes, run a precheck again.
      • If you do not need to troubleshoot the issues, ignore failed items and run a precheck again.
  7. Wait until the Success Rate becomes 100%. Then, click Next: Purchase Instance.
  8. On the Purchase Instance page, specify the billing method of the change tracking instance. The following table describes the parameters.
    Parameter Description
    Billing method
    • Subscription: You pay for the instance when you create an instance. The subscription billing method is more cost-effective than the pay-as-you-go billing method for long-term use. You are offered lower prices for longer subscription periods.
    • Pay-as-you-go: A pay-as-you-go instance is billed on an hourly basis. The pay-as-you-go billing method is suitable for short-term use. If you no longer require a pay-as-you-go instance, you can release it to reduce costs.
    Billing Type of Change Tracking Instance

    If you select the subscription billing method, Billing Type for Change Tracking Instance is set to USD 120 per month for configuration fee (no data traffic fee).

    Subscription Length
    If you select the subscription billing method, set the subscription duration and the number of instances that you want to create. The subscription duration can be one to nine months or one to three years.
    Note This parameter is available only if you select the subscription billing method.
  9. Read and select Data Transmission Service (Pay-as-you-go) Service Terms.
  10. Click Buy and Start to start the change tracking task. You can view the progress of the task in the task list.

What to do next

When the change tracking task is running, you can create consumer groups based on the downstream client to consume the tracked data.
  1. For more information about how to create and manage consumer groups, see Create consumer groups.
  2. Use one of the following methods to consume the tracked data: