Create a PolarDB for MySQL change tracking task

更新时间:
复制 MD 格式

The change tracking feature allows you to subscribe to incremental data in real time. You can use this feature for scenarios such as lightweight cache updates, asynchronous service decoupling, and real-time data synchronization involving extract, transform, and load (ETL) processes. This topic describes how to create a change tracking task for PolarDB for MySQL.

Prerequisites

Limitations

Type

Description

Source database limitations

  • Subscribed tables must have a primary key or a unique constraint, and the fields in the constraint must be unique. Otherwise, you may receive duplicate data.

  • If you subscribe to data at the table level, a single subscription task supports up to 500 tables. If you exceed this limit, the task fails with an error after submission. In this case, we recommend that you split the tables into multiple subscription tasks, or configure a subscription task for the entire database.

  • Binary log:

    • Binary logging must be enabled, and the loose_polar_log_bin parameter must be set to on. Otherwise, the precheck fails and the change tracking task cannot start.

    • The binary log of the source database must be retained for more than 24 hours. Otherwise, the DTS task may fail because DTS cannot obtain the binary log. In extreme cases, data may be inconsistent or lost. Issues that arise from a binary log retention period shorter than required are not covered by the DTS Service Level Agreement (SLA).

  • If the source instance is a read-only instance or a temporary instance, make sure that the instance logs transactions.

Other limitations

  • Check if the subscription precision for FLOAT or DOUBLE columns meets your business requirements. DTS reads values from these columns by using the ROUND(COLUMN,PRECISION) function. If you do not explicitly define a precision, DTS sets the precision for FLOAT columns to 38 digits and for DOUBLE columns to 308 digits.

  • DTS does not subscribe to DDL changes made by tools such as pt-online-schema-change. As a result, the consumer client may fail to write data to the destination table due to schema inconsistencies.

  • DTS does not support consuming single data rows larger than 16 MB. This may cause an Out of Memory (OOM) error on the consumer client.

  • If a task fails, DTS support staff will attempt to restore it within eight hours. During restoration, they may restart the task or adjust its parameters.

    Note

    Parameter adjustments modify only the DTS instance parameters, not the database parameters.

Procedure

  1. Use one of the following methods to go to the Change Tracking Tasks page and select the region in which the change tracking instance resides.

    DTS console

    1. Log on to the DTS console.

    2. In the left-side navigation pane, click Change Tracking.

    3. In the upper-left corner of the page, select the region in which the change tracking instance resides.

    DMS console

    Note

    The actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.

    1. Log on to the DMS console.

    2. In the top navigation bar, move the pointer over Data + AI > DTS (DTS) > Change Tracking.

    3. From the drop-down list to the right of Change Tracking Tasks, select the region in which the change tracking instance resides.

  2. Click Create Task to go to the task configuration page.

  3. Configure parameters in the Source Database and Consumer Network Type sections.

    Warning

    After you specify the source database instance, we recommend that you read the Limits that are displayed in the upper part of the page. Otherwise, the task may fail or the tracked data cannot be consumed.

    Category

    Parameter

    Description

    N/A

    Task Name

    The name of the change tracking task. DTS automatically assigns a name to the task. 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.

    Source Database

    Select Existing Connection

    • To use a database instance that is already registered, select it from the drop-down list. DTS automatically configures the connection settings.

      Note

      In the DMS console, this parameter is named Select a DMS database instance..

    • If the database instance is not registered, or you do not want to use a registered instance, you must manually configure the connection settings.

    Database Type

    Select PolarDB for MySQL.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region where the PolarDB for MySQL cluster resides.

    Replicate Data Across Alibaba Cloud Accounts

    For this tutorial, select No.

    Important

    If you need to access source database resources across accounts (by selecting Yes), you must configure RAM authorization for the Alibaba Cloud account used to create the DTS task. You also need to enter the Alibaba Cloud Account and RAM Role Name. For instructions, see Configure RAM authorization for cross-account tasks.

    PolarDB Cluster ID

    Select the cluster ID of the PolarDB for MySQL cluster.

    Database Account

    Enter the Read-only account of the PolarDB for MySQL database, or a custom account with the REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, and SELECT permissions.

    Database Password

    The password that is used to access the database instance.

    Encryption

    Select an option based on your requirements. For more information about SSL encryption, see Enable SSL encryption.

    Consumer Network Type

    Network Type

    The value of the Network Type parameter is fixed to VPC. You must select a VPC and a vSwitch. For more information, see VPCs.

    Note
    • After a change tracking task is configured, 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 connected to 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.

    Note

    Make sure that the CIDR blocks of DTS servers can be automatically or manually added to the security settings of the source and destination databases to allow access from DTS servers. For more information, see DTS server IP whitelist.

  5. Configure the objects for change tracking.

    1. On the Configure Objects page, configure the objects for change tracking.

      Parameter

      Description

      Data Change Types

      Data Change Types is selected by default and cannot be changed.

      • Data Update

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

      • Schema Update

        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 data to be tracked.

      Source Objects

      Select one or more objects from the Source Objects section and click the Right arrow icon to add the objects to the Selected Objects section.

      Note

      You can select tables or databases as the objects for change tracking.

      • If you select a database as the object, DTS tracks incremental data of all objects, including new objects in the database.

      • If you select a table as the object, DTS tracks only incremental data of this table. In this case, if you want to track data changes of another table, you must add the table to the object list. For more information, see Modify the objects for change tracking.

    2. Click Next: Advanced Settings to configure advanced settings.

      Parameter

      Description

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules the task to a shared cluster. You do not need to configure this parameter. You can purchase dedicated clusters of specified specifications to run DTS change tracking tasks. For more information, see What is a DTS dedicated cluster?.

      Retry Time for Failed Connections

      The retry time range for failed connections. If the change tracking task fails, DTS immediately retries a connection within the time range. Valid values: 10 to 1440. Unit: minutes. Default value: 720. We recommend that you set the parameter to a value greater than 30. If DTS is reconnected to the source database instance within the specified time range, DTS resumes the change tracking task. Otherwise, the change tracking task fails.

      Note
      • If multiple change tracking tasks are configured for a database instance, the shortest retry time range takes precedence. For example, Task A and Task B are configured for the same database instance. Task A is configured with a retry time range of 30 minutes, and Task B is configured with a retry time range of 60 minutes. In this case, the retry time range of 30 minutes takes precedence.

      • When DTS retries a connection, fees are charged. We recommend that you specify the retry time range based on your business requirements, or release the DTS instance at the earliest opportunity after the source database instance is released.

      Retry Time for Other Issues

      The retry time range for other issues. For example, if DDL or DML operations fail to be performed after the change tracking task is started, DTS immediately retries the operations within the retry time range. Valid values: 1 to 1440. Unit: minutes. Default value: 10. We recommend that you set the parameter to a value greater than 10. If the failed operations are successfully performed within the specified retry time range, DTS resumes the change tracking task. Otherwise, the change tracking task fails.

      Important

      The value of the Retry Time for Other Issues parameter must be smaller than the value of the Retry Time for Failed Connections parameter.

      Environment Tag

      You can select an environment tag to identify the instance based on your business requirements. This example does not require a tag.

      Whether to delete SQL operations on heartbeat tables of forward and reverse tasks

      Choose whether DTS writes heartbeat SQL information to the source database while the instance is running.

      • Yes: Does not write heartbeat SQL information to the source database. The DTS instance may display latency.

      • No: Writes heartbeat SQL information to the source database. This may interfere with source database operations like physical backups and cloning.

      Monitoring and Alerting

      Specifies whether to enable alerting for the change tracking task. If alerting is configured and the task fails or the latency exceeds the threshold, alert notifications are sent. Valid values:

  6. In the lower part of the page, click Next: Save Task Settings and Precheck.

    • To view the parameters to be specified when you call the relevant API operation to configure the DTS task, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.

    • If you do not need to view or have viewed the parameters, 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 View Details next to each failed item. After you troubleshoot the issues based on the error message, you can run a precheck again.

    • If an alert is generated for an item during the precheck, perform the following operations based on the scenario:

      • If an alert item cannot be ignored, click View Details next to the failed item and troubleshoot the issues. Then, run a precheck again.

      • If the alert item can be ignored, click Confirm Alert Details. In the View Details dialog box, click Ignore. In the message that appears, click OK. Then, click Precheck Again to run a precheck again. If you ignore the alert item, data inconsistency may occur and your business may be exposed to potential risks.

  7. Purchase the instance.

    1. Wait until Success Rate becomes 100%. Then, click Next: Purchase Instance.

    2. On the Purchase page, specify the billing method of the change tracking instance. The following table describes the parameters.

      Parameter

      Description

      Billing method

      • Subscription: You pay for your subscription 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 durations.

      • Pay-as-you-go: A pay-as-you-go instance is billed on an hourly basis. We recommend that you select the pay-as-you-go billing method for short-term use. If you no longer require a pay-as-you-go instance, you can release the instance to reduce costs.

      Resource Group Settings

      The resource group to which the instance belongs. Default value: default resource group. For more information, see What is Resource Management?

      Subscription Duration

      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, one year, two years, three years, or five years.

      Note

      This parameter is available only if you select the Subscription billing method.

    3. Read and select the Data Transmission Service (Pay-as-you-go) Service Terms.

    4. Click Buy and Start to start the change tracking task. You can view the progress of the task in the task list.

Next steps

Once the subscription task is running, create a consumer group and choose a data consumption method for your client.