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 a user-created Oracle database.

Prerequisites

  • The version of the user-created Oracle database is 9i, 10g, 11g, or 12c.
  • Supplemental logging, including SUPPLEMENTAL_LOG_DATA_PK and SUPPLEMENTAL_LOG_DATA_UI, is enabled for the user-created Oracle database. For more information, see Supplemental Logging.
  • The ARCHIVELOG mode is enabled for the user-created Oracle database. Archived log files are accessible and a suitable retention period is set for archived log files. For more information, see Managing Archived Redo Log Files.

Precautions

  • DTS does not track data definition language (DDL) operations that are performed by 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 conflict.
  • If the source database is used in another task, for example, it is used in a running data migration task, DTS may track data changes of other objects. In this case, you must use the change tracking client to filter the tracked data.

Supported source database types

You can use DTS to track data changes from the following types of user-created Oracle databases:

  • User-created Oracle database with a public IP address
  • User-created Oracle database connected over a database gateway
  • User-created Oracle database hosted on ECS
  • User-created Oracle database connected over Express Connect, VPN Gateway, or Smart Access Gateway

This topic uses a user-created Oracle database hosted on ECS as an example to describe how to configure a change tracking task. You can also follow the procedure to configure change tracking tasks for other types of user-created Oracle databases.

Preparations

Log on to the source Oracle database, create a database account for change tracking, and grant permissions to the account.

#Create a database account for change tracking. Set the username to dtstest and the password to Dts123456.
create user dtstest IDENTIFIED BY Dts123456;
grant create session to dtstest;
grant connect to dtstest;
grant resource to dtstest;
grant execute on sys.dbms_logmnr to dtstest;
grant select on v_$logmnr_contents to dtstest;
grant select on v_$log to dtstest;
grant select on v_$logfile to dtstest;
grant select on v_$archived_log to dtstest;
grant select on v_$logmnr_logs to dtstest;
grant select on v_$parameter to dtstest;
grant select on v_$database to dtstest;
grant select on all_objects to dtstest;
grant select on all_tab_cols to dtstest;
grant select on dba_registry to dtstest;
grant select any table to dtstest;
grant select any transaction to dtstest;
grant select on v$active_instances to dtstest;
grant select on v$instance to dtstest;
grant select on sys.USER$ to dtstest;
grant select on SYS.OBJ$ to dtstest;
grant select on SYS.COL$ to dtstest;
grant select on SYS.IND$ to dtstest;
grant select on SYS.ICOL$ to dtstest;
grant select on SYS.CDEF$ to dtstest;
grant select on SYS.CCOL$ to dtstest;
grant select on SYS.TABPART$ to dtstest;
grant select on SYS.TABSUBPART$ to dtstest;
grant select on SYS.TABCOMPART$ to dtstest;
grant select on gv_$listener_network to dtstest;
Note If the version of the source Oracle database is 12c, you must run the following statements:
grant LOGMINING TO dtstest;
grant EXECUTE_CATALOG_ROLE to dtstest;
grant LOGMINING TO dtstest;

Procedure

  1. Create a change tracking instance. For more information, see Purchase a change tracking instance.
    Note On the buy page, set Source Database to Oracle and select the region where the source instance resides.
  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 information and network type for the change tracking task.
    Configure the source database information and network type
    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 User-Created Database in ECS Instance.
    Database Type The value of this parameter is set to Oracle and cannot be changed.
    Instance Region The region of the source instance. The region is the same as the source region that you selected when you purchased the change tracking instance. You cannot change the value of this parameter.
    ECS Instance ID Select the ID of the ECS instance that is connected to the user-created Oracle database.
    Port Number Enter the service port number of the user-created Oracle database.
    SID Enter the system ID (SID) of the user-created Oracle database.
    Database Account Enter the account of the user-created Oracle database.
    Note For more information about how to create and authorize a database account, see Preparations.
    Database Password Enter the password for the database account.
    Consumer Network Type N/A 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.
    • Classic

      If you select Classic, no other configurations are required. For more information about the classic network, see Classic network.

    • VPC

      If you select VPC, you must specify the VPC and VSwitch. For more information about VPC, see VPC.

  7. Click Set Whitelist and Next. The following table describes the details about whitelist settings.
    Instance type of the source database Description
    User-created Oracle 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 Oracle database with a public IP address
    • User-created Oracle 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.
  8. Select the data change types and objects.
    Supported data 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 tracked data.

    Note
    • 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 of this table. In this case, if you want to track data changes of another table, you must add the table to the required objects. For more information, see Modify the objects for change tracking.
    Required Objects

    Select objects from the Required Objects section and click the Right arrow icon to add the objects to the Selected section.

    Note You can select tables or databases as the objects for change tracking.
  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, click the Info icon icon next to each failed item to view details. Troubleshoot the issues based on the causes and run the precheck again.
  10. 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.

What to do next

  1. Create consumer groups
  2. Use a Kafka client to consume tracked data