All Products
Search
Document Center

Data Transmission Service:Track data changes from a self-managed Oracle database

Last Updated:Oct 17, 2024

Data Transmission Service (DTS) allows you to track data changes from databases in real time. You can use the change tracking feature in the following scenarios: lightweight cache updates, business decoupling and asynchronous data processing, and synchronization of extract, transform, and load (ETL) operations. This topic describes how to track data changes from a self-managed Oracle database.

Prerequisites

  • The engine version of the self-managed Oracle database is 9i, 10g, or 11g. Real Application Cluster (RAC) instances are not supported.

  • Supplemental logging, including SUPPLEMENTAL_LOG_DATA_PK and SUPPLEMENTAL_LOG_DATA_UI, is enabled for the self-managed Oracle database. For more information, see Supplemental Logging.

  • The self-managed Oracle database is running in ARCHIVELOG mode. 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 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.

  • If the source database is involved in another task such as a running data migration task, DTS may track data changes of other objects. In this case, you must manually filter the tracked data on the change tracking client.

Preparations

Log on to the source Oracle database, create a database account, and grant the database administrator (DBA) permission to the account.

Important

If you need to track data changes from an Oracle database but the database administrator (DBA) permission cannot be granted to the database account, you can enable archive logging and supplemental logging, and grant fine-grained permissions to the account.

  1. Enable archive logging and supplemental logging.

    Type

    Procedure

    Archive logging

    Execute the following statements to enable archive logging:

    shutdown immediate;
    startup mount;
    alter database archivelog;
    alter database open;
    archive log list;

    Supplemental logging

    Enable supplemental logging at the database or table level:

    Note

    You can enable database-level supplemental logging to ensure the stability of DTS tasks. You can enable table-level supplemental logging to reduce the disk usage of the source Oracle database.

    • Enable database-level supplemental logging

      1. Enable minimal supplemental logging:

        alter database add supplemental log data;
      2. Enable primary key and unique key supplemental logging at the database level:

        alter database add supplemental log data (primary key,unique index) columns;
    • Enable table-level supplemental logging

      1. Enable minimal supplemental logging:

        alter database add supplemental log data;
      2. Enable table-level supplemental logging by using one of the following methods:

        • Enable primary key supplemental logging at the table level:

          alter table table_name add supplemental log data (primary key) columns;
        • Enable table-level supplemental logging for all columns:

          alter table tb_name add supplemental log data (all) columns ;
  2. Grant fine-grained permissions to an Oracle database account.

    Oracle Versions 9i to 11g

    # Create a database account, for example, rdsdt_dtsacct, and grant permissions to the account.
    create user rdsdt_dtsacct IDENTIFIED BY rdsdt_dtsacct;
    grant create session to rdsdt_dtsacct;
    grant connect to rdsdt_dtsacct;
    grant resource to rdsdt_dtsacct;
    grant execute on sys.dbms_logmnr to rdsdt_dtsacct;
    grant select on V_$LOGMNR_LOGS to rdsdt_dtsacct;
    grant select on all_objects to rdsdt_dtsacct;
    grant select on all_tab_cols to rdsdt_dtsacct;
    grant select on dba_registry to rdsdt_dtsacct;
    grant select any table to rdsdt_dtsacct;
    grant select any transaction to rdsdt_dtsacct;
    -- v$log privileges
    grant select on v_$log to rdsdt_dtsacct;
    -- v$logfile privileges
    grant select on v_$logfile to rdsdt_dtsacct;
    -- v$archived_log privileges
    grant select on v_$archived_log to rdsdt_dtsacct;
    -- v$parameter privileges
    grant select on v_$parameter to rdsdt_dtsacct;
    -- v$database privileges
    grant select on v_$database to rdsdt_dtsacct;
    -- v$active_instances privileges
    grant select on v_$active_instances to rdsdt_dtsacct;
    -- v$instance privileges
    grant select on v_$instance to rdsdt_dtsacct;
    -- v$logmnr_contents privileges
    grant select on v_$logmnr_contents to rdsdt_dtsacct;
    -- system tables
    grant select on sys.USER$ to rdsdt_dtsacct;
    grant select on SYS.OBJ$ to rdsdt_dtsacct;
    grant select on SYS.COL$ to rdsdt_dtsacct;
    grant select on SYS.IND$ to rdsdt_dtsacct;
    grant select on SYS.ICOL$ to rdsdt_dtsacct;
    grant select on SYS.CDEF$ to rdsdt_dtsacct;
    grant select on SYS.CCOL$ to rdsdt_dtsacct;
    grant select on SYS.TABPART$ to rdsdt_dtsacct;
    grant select on SYS.TABSUBPART$ to rdsdt_dtsacct;
    grant select on SYS.TABCOMPART$ to rdsdt_dtsacct;

Procedure

  1. Create a change tracking instance. For more information, see Purchase a DTS instance.

    Note

    On the buy page, set Instance Type to Oracle and select the region where you want to create the instance.

  2. Log on to the DTS console.

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

  4. In the upper part of the Change Tracking Tasks page, select the region where the change tracking instance resides.

  5. Find the change tracking instance and click Configure Task in the Actions column.

  6. Configure the source database and network type for the change tracking task.

    Configure the source database and network type

    Section

    Parameter

    Description

    None

    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.

    Source Database

    Instance type

    The type of the source instance. In this example, User-Created Database in ECS Instance is used.

    Note

    If you select other instance types, you must deploy the network environment for the self-managed database. For more information, see Preparation overview.

    Database Type

    The value of this parameter is set to Oracle and cannot be changed.

    Instance Region

    The source region that you selected on the buy page. The value of this parameter cannot be changed.

    ECS Instance ID

    The ID of the Elastic Compute Service (ECS) instance that hosts the self-managed Oracle database.

    Port Number

    The service port number of the self-managed Oracle database.

    SID

    The system ID (SID) of the self-managed Oracle database.

    Database Account

    The account of the self-managed Oracle database.

    Note

    For more information about how to create and authorize a database account, see Preparations.

    Database Password

    The password of the database account.

    Consumer Network Type

    None

    The network type of the change tracking instance.

    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 virtual private cloud (VPC), select VPC as the network type and specify the VPC and vSwitch parameters.

    • 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, see Classic networks.

    • VPC

      If you select VPC, you must specify the VPC and vSwitch parameters. For more information, see VPC.

  7. In the lower-right corner of the page, click Set Whitelist and Next.

    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 Elastic Compute Service (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 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: enhance the security of your account and password, limit the ports that are exposed, authenticate API calls, regularly check the whitelist or ECS security group rules and forbid unauthorized CIDR blocks, or connect the database to DTS by using Express Connect, VPN Gateway, or Smart Access Gateway.

    • After your DTS task is completed or released, we recommend that you manually detect and remove the added CIDR blocks from the whitelist of the database instance or ECS security group rules.

  8. Select the data change types and objects.

    Select the data change 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 required 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 selected objects. For more information, see Modify the objects for change tracking.

    Required Objects

    Select one or more objects from the Required Objects section and click the Rightwards 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, 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, you can click the Info icon icon next to each failed item to view details. After you troubleshoot the issues based on the causes, you can run a precheck again.

  10. Close the Precheck dialog box after the following message is displayed: Precheck Passed.

    After the change tracking task is configured, DTS performs initial change tracking. Initial change tracking takes about one minute. After initial change tracking is complete, you can create one or more consumer groups to consume the tracked data.

What to do next

  1. Create consumer groups

  2. Use a Kafka client to consume tracked data

  3. Use the SDK demo to consume tracked data