You can use Data Transmission Service (DTS) 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, 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 version of the self-managed Oracle database is 9i, 10g, or 11g. Real Application Cluster (RAC) or pluggable database (PDB) instances are not supported.
Supplemental logging is enabled for the self-managed Oracle database. The SUPPLEMENTAL_LOG_DATA_PK and SUPPLEMENTAL_LOG_DATA_UI parameters are set to Yes. 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.
If the ApsaraDB RDS for MySQL instance is of the classic network type, an internal endpoint is configured for the ApsaraDB RDS for MySQL instance.
Usage notes
Category | Description |
Limits on the source database |
|
Other limits | You must make sure that the precision settings for columns of the FLOAT or DOUBLE data type meet your business requirements. DTS uses the |
Before you begin
Log on to the source Oracle database, create a database account, and grant the database administrator (DBA) permissions to the account. For more information, see CREATE USER and GRANT.
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.
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:
NoteYou 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
Enable minimal supplemental logging:
alter database add supplemental log data;
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
Enable minimal supplemental logging:
alter database add supplemental log data;
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 ;
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
- Go to the Change Tracking Tasks page.
- Log on to the Data Management (DMS) console.
- In the top navigation bar, click DTS.
- In the left-side navigation pane, choose .
Note- If you log on to the DMS console and click the Enter Simple Mode icon in the upper-right corner, you can move the pointer over the icon in the upper-left corner, and then choose Customize the layout and style of the DMS console. . For more information, see
- You can also configure the settings by using the new DTS console.
- 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.
Click Create Task. On the page that appears, specify the source database instance and the consumer network type.
WarningAfter 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.
Section
Parameter
Description
None
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 an existing database connection
The instance to which the source database belongs. You can choose whether to use an existing instance based on your business requirements.
If you use an existing instance, DTS automatically applies the parameter settings of the source database.
If you do not use an existing instance, you must set parameters for the source database.
Database Type
The type of the source database. Select Oracle.
Access Method
Select the type of the source instance. In this example, Self-managed Database on ECS is selected.
NoteIf your source database is a self-managed database, you must complete the preparation for the database. For more information, see Preparation overview.
Instance Region
The region in which the self-managed Oracle database resides.
ECS Instance ID
The ID of the ECS instance that hosts the self-managed Oracle database.
Port Number
The service port number of the self-managed Oracle database. Default value: 1521.
Oracle Type
If you select Non-RAC Instance, you must specify the SID parameter.
If you select RAC or PDB Instance, you must specify the Service Name parameter.
ImportantRAC or PDB instances are not supported.
In this example, Non-RAC Instance is selected.
Database Account
The account of the self-managed Oracle database. For more information about the permissions that are required for the account, see Before you begin.
Database Password
The password that is used to access the database instance.
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.
NoteAfter 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.
In the lower part of the page, click Test Connectivity and Proceed.
If the source database instance is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers in the corresponding region to the whitelist of the instance. If the source database instance is a self-managed database hosted on an ECS instance, DTS automatically adds the CIDR blocks of DTS servers in the corresponding region to the security group rules of the ECS instance. To allow DTS to access the database, you must also manually add the CIDR blocks of DTS servers in the corresponding region to the security settings of the database. If the source database instance is a self-managed database that is deployed in a data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers in the corresponding region to the security settings of the database to allow DTS to access the database. For more information, see the CIDR blocks of DTS servers section of the Add the CIDR blocks of DTS servers topic.
WarningIf the public CIDR blocks of DTS servers are automatically or manually added to the whitelist of a database instance or to the security group rules of an ECS instance, security risks may arise. Therefore, before you use DTS to track data changes, 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 security group rules and forbidding unauthorized CIDR blocks, or connecting the database instance to DTS by using Express Connect, VPN Gateway, or Smart Access Gateway.
Configure the objects for change tracking and 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 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 icon to add the objects to the Selected Objects section.
NoteYou 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.
Advanced Settings
Parameter
Description
Monitoring and Alerting
Specify whether to configure alerting for the change tracking task. If the task fails or the latency exceeds the specified threshold, the specified alert contacts can receive notifications. Valid values:
No: does not configure alerting.
Yes: configures alerting. In this case, you must also specify the alert threshold and alert contacts.
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: 120. We recommend that you set the time range to more than 30 minutes. If DTS reconnects to the source instance within the specified time range, DTS resumes the change tracking task. Otherwise, the change tracking task fails.
NoteIf an instance serves as the source or destination database of multiple change tracking tasks, the shortest retry time range 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.
Configure ETL
Specify whether to configure the extract, transform, and load (ETL) feature. For more information, see What is ETL?. Valid values:
Yes: configures the ETL feature. You can enter your policy in the code editor.
No: does not configure the ETL feature.
Click Next: Save Task Settings and Precheck in the lower part of the page.
You can move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters to view the parameter settings of the API operation that is called to configure the instance.
NoteBefore 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.
Wait until Success Rate becomes 100%. Then, click Next: Purchase Instance.
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.
NoteThis parameter is available only if you select the Subscription billing method.
Read and select the Data Transmission Service (Pay-as-you-go) Service Terms.
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.
For more information about how to create and manage consumer groups, see Create consumer groups.
Use one of the following methods to consume the tracked data: