Data Transmission Service (DTS) migrates data from a PolarDB for PostgreSQL (Compatible with Oracle) cluster to a self-managed Oracle database. It supports full data migration to transfer historical data, and incremental data migration to replicate ongoing changes with minimal service downtime.
Prerequisites
Before you begin, make sure that:
-
The source PolarDB for PostgreSQL (Compatible with Oracle) cluster is created. For more information, see Create a PolarDB for PostgreSQL(Compatible with Oracle) cluster.
-
The
wal_levelparameter of the source cluster is set tological. This enables logical encoding in write-ahead logging (WAL). For more information, see Configure cluster parameters.
Permissions required
| Database | Required permission |
|---|---|
| Source PolarDB for PostgreSQL (Compatible with Oracle) cluster | Privileged account |
| Self-managed Oracle database | Schema owner |
To create accounts and grant permissions, see:
-
PolarDB for PostgreSQL (Compatible with Oracle): Create database accounts
-
Self-managed Oracle databases: CREATE USER and GRANT
Billing
| Migration type | Instance configuration fee | Internet traffic fee |
|---|---|---|
| Full data migration | Free of charge | Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Billing overview. |
| Incremental data migration | Charged. For more information, see Billing overview. | Charged only when data is migrated from Alibaba Cloud over the Internet. |
Migration types
| Migration type | Description |
|---|---|
| Full data migration | Migrates historical data from the source to the destination database. Do not perform DDL operations on migrated objects during this phase. |
| Incremental data migration | Reads redo log files from the source database and replicates ongoing changes to the destination. Select this type together with full data migration to keep services running during migration. |
SQL operations supported for incremental migration
| Operation type | SQL statements |
|---|---|
| DML | INSERT, UPDATE, DELETE |
| DDL | Available only when the source database account is a privileged account: CREATE TABLE, DROP TABLE, ALTER TABLE (including RENAME TABLE, ADD COLUMN, ADD COLUMN DEFAULT, ALTER COLUMN TYPE, DROP COLUMN, ADD CONSTRAINT, ADD CONSTRAINT CHECK, ALTER COLUMN DROP DEFAULT), TRUNCATE TABLE, CREATE INDEX ON TABLE |
DDL migration is available only for tasks created after October 1, 2020. If your task was created before May 12, 2023, create a trigger and a function in the source database before configuring the migration task. For more information, see Use triggers and functions to implement incremental DDL migration for PostgreSQL databases.
The following DDL operations are not migrated:
-
Additional DDL information such as CASCADE or RESTRICT
-
DDL statements from sessions where
SET session_replication_role = replicais executed -
DDL statements submitted in the same transaction as DML statements
-
DDL statements on objects not selected for migration
Incremental data migration does not support the BIT data type.
Limitations
During schema migration, DTS migrates foreign keys from the source to the destination database. During full and incremental data migration, DTS temporarily disables foreign key constraint checks and cascade operations at the session level. If you perform cascade and delete operations on the source database during migration, data inconsistency may occur.
Source database limitations
-
The source database server must have sufficient outbound bandwidth. Insufficient bandwidth reduces migration speed.
-
Tables to be migrated must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate records.
-
If you select tables as migration objects and need to rename tables or columns in the destination database, a single task supports up to 1,000 tables. For more than 1,000 tables, configure multiple tasks or migrate the entire database.
-
For incremental data migration, WAL must be enabled and WAL logs must be retained for the following durations: If logs are not retained for the required duration, DTS may fail to obtain WAL logs and the task may fail. In exceptional circumstances, data loss or inconsistency may occur. After full data migration completes, you can reduce the retention period to more than 24 hours.
-
Incremental data migration only: more than 24 hours
-
Full data migration and incremental data migration: at least seven days
-
-
During full data migration, do not perform DDL operations that change the schemas of databases or tables. The migration task will fail.
-
If you perform only full data migration, do not write data to the source database during migration. To ensure data consistency, select both Full Data Migration and Incremental Data Migration.
-
If you plan to perform a primary/secondary switchover on the source cluster, enable the Logical Replication Slot Failover feature first to prevent logical subscriptions from being interrupted. For more information, see Logical replication slot failover.
-
If long-running transactions exist in the source database during incremental migration, WAL logs generated before those transactions commit may accumulate and cause insufficient disk space.
Other limitations
-
Schema migration is not supported. Before configuring a migration task, create the required databases and tables in the destination instance.
-
A single migration task migrates data from one database only. To migrate multiple databases, create a separate task for each database.
-
During incremental migration, if you select a schema as the migration object and then create or rename a table in that schema, run the following statement before writing data to the table:
ALTER TABLE schema.table REPLICA IDENTITY FULL;Replace
schemaandtablewith the actual schema name and table name. -
To track migration latency, DTS creates a table named
dts_postgres_heartbeatin the source database. The following figure shows the table structure.
-
During incremental migration, DTS creates a replication slot prefixed with
dts_sync_in the source database. DTS can obtain incremental logs from the last 15 minutes using this slot.-
After the DTS instance is released, the replication slot is automatically deleted.
-
If you change the source database password or remove DTS from the IP address whitelist, the replication slot is not automatically deleted. Manually delete it from the source database to prevent slot accumulation.
-
If the migration task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source cluster, log on to the secondary instance to clear the replication slot.
-
-
Full data migration uses concurrent INSERT operations, which causes fragmentation in destination tables. After migration completes, the tablespace of the destination database is larger than that of the source database.
-
DTS uses the
ROUND(COLUMN,PRECISION)function to retrieve values from FLOAT and DOUBLE columns. The default precision is 38 digits for FLOAT and 308 digits for DOUBLE. Confirm that these precision settings meet your requirements before starting the migration. -
DTS attempts to resume failed tasks for up to seven days. Before switching workloads to the destination database, stop or release any failed tasks, or run a
REVOKEstatement to remove write permissions from the DTS accounts on the destination database. Otherwise, the resumed task may overwrite data in the destination database.
Special cases
If the self-managed Oracle database is deployed in a Real Application Cluster (RAC) architecture and connected to DTS over a virtual private cloud (VPC), connect the Single Client Access Name (SCAN) IP address and the virtual IP address (VIP) of each node to the VPC and configure routes. When configuring the Oracle database in the DTS console, specify the SCAN IP address as the database endpoint or IP address. For more information, see Connect an on-premises database to Alibaba Cloud and Connect a data center to DTS by using VPN Gateway.
Configure a migration task
Step 1: Go to the Data Migration Tasks page
-
Log on to the Data Management (DMS) console.
-
In the top navigation bar, click DTS.
-
In the left-side navigation pane, choose DTS (DTS) > Data Migration.
Operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode and Customize the layout and style of the DMS console. You can also go directly to the Data Migration Tasks page in the new DTS console.
Step 2: Select the region
From the drop-down list next to Data Migration Tasks, select the region where the data migration instance resides.
In the new DTS console, select the region in the upper-left corner.
Step 3: Configure source and destination databases
Click Create Task. In the Create Task wizard, configure the source and destination databases using the following parameters.
Read the limits displayed at the top of the page before proceeding. Skipping this step may cause task failures or data inconsistency.
Source database
| Parameter | Description |
|---|---|
| Task Name | The name of the task. DTS assigns a name automatically. Specify a descriptive name to make the task easy to identify. The name does not need to be unique. |
| Database Type | Select PolarDB (Compatible with Oracle). |
| Access Method | Select Public IP Address. |
| Instance Region | The region where the source PolarDB for PostgreSQL (Compatible with Oracle) cluster resides. |
| Data Sources | Select Single Data Source to configure the primary node endpoint and port only. Select Multiple Data Sources to specify the IP addresses and port numbers of multiple nodes (including the primary node) in the IP:Port of Data Sources field. With multiple data sources configured, DTS automatically switches to a new primary node during a primary/secondary switchover, which is useful for disaster recovery scenarios. This example uses Single Data Source. |
| Domain Name or IP Address | The endpoint of the primary node in the source cluster. Run the ping command on your computer to get the IP address. |
| Port Number | The service port of the source database. Default value: 1521. The port must be accessible over the Internet. |
| IP:Port of Data Sources | The IP addresses and port numbers of multiple nodes including the primary node. Separate multiple entries with commas (,). Required when Multiple Data Sources is selected. |
| Oracle Type | Select Non-RAC Instance to configure the SID parameter, or select RAC or PDB Instance to configure the Service Name parameter. This example uses Non-RAC Instance. |
| Database Name | The name of the source database in the cluster. |
| Database Account | The database account of the source cluster. For required permissions, see Permissions required. |
| Database Password | The password of the database account. |
Destination database
| Parameter | Description |
|---|---|
| Database Type | Select Oracle. |
| Access Method | Select Public IP Address. |
| Instance Region | The region where the destination Oracle database resides. |
| Hostname or IP Address | The endpoint of the destination Oracle database. |
| Port Number | The service port of the destination database. Default value: 1521. |
| Oracle Type | Select Non-RAC Instance to configure the SID parameter, or select RAC or PDB Instance to configure the Service Name parameter. This example uses Non-RAC Instance. |
| Database Account | The account of the destination Oracle database. For required permissions, see Permissions required. |
| Database Password | The password of the database account. |
Step 4: Test connectivity and add DTS IP addresses to the whitelist
If your self-managed database has an IP address whitelist configured, add the CIDR blocks of DTS servers to the whitelist. Then click Test Connectivity and Proceed.
Adding DTS server CIDR blocks to a database instance whitelist or ECS security group rules may expose your environment to security risks. Before proceeding, take protective measures, including strengthening account and password security, limiting exposed ports, authenticating API calls, and regularly reviewing whitelist rules. Consider using Express Connect, VPN Gateway, or Smart Access Gateway to connect the database to DTS instead of exposing it over the Internet.
Step 5: Configure migration objects and settings
| Parameter | Description |
|---|---|
| Migration Types | Select Full Data Migration for historical data only. Select both Full Data Migration and Incremental Data Migration to keep services running during migration. If you do not select Incremental Data Migration, do not write data to the source database during migration. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors: checks whether the destination database contains tables with the same names as those in the source. If identical names exist, the precheck fails and the task cannot start. Use the object name mapping feature to rename conflicting tables. For more information, see Map object names. Ignore Errors and Proceed: skips the name conflict check. If source and destination schemas match, DTS skips records with duplicate primary key values. If schemas differ, only specific columns are migrated or the task may fail. Use with caution. |
| Source Objects | Select objects from Source Objects and click the arrow icon to add them to Selected Objects. You can select columns, tables, or schemas. If you select tables or columns, DTS does not migrate views, triggers, or stored procedures. |
| Selected Objects | To rename a single object in the destination instance, right-click the object in Selected Objects. For more information, see Map the name of a single object. To rename multiple objects at once, click Batch Edit in the upper-right corner. For more information, see Map multiple object names at a time. To filter data with WHERE conditions, right-click a table in Selected Objects and specify the conditions. For more information, see Use SQL conditions to filter data. To select specific SQL operations to migrate for an object, right-click the object in Selected Objects and select the operations. |
Renaming an object using the object name mapping feature may cause other objects that depend on it to fail migration.
Step 6: Configure advanced settings
Click Next: Advanced Settings and configure the following parameters.
| Parameter | Description |
|---|---|
| Set Alerts | Select No to skip alerting. Select Yes to configure alerting. When the task fails or migration latency exceeds the threshold, the specified alert contacts receive notifications. For more information, see Configure monitoring and alerting. |
| Retry Time for Failed Connections | The time range during which DTS retries failed connections after the task starts. Valid values: 10–1440 minutes. Default: 720 minutes. Set this to a value greater than 30 minutes. If DTS reconnects within this period, the task resumes. Otherwise, the task fails. If multiple tasks share the same source or destination database, the shortest retry time range applies. |
| The wait time before a retry when other issues occur in the source and destination databases | The retry time range for DDL or DML operation failures. Valid values: 1–1440 minutes. Default: 10 minutes. Set this to a value greater than 10 minutes. This value must be less than the Retry Time for Failed Connections value. |
| Configure ETL | Select Yes to configure the extract, transform, and load (ETL) feature and enter data processing statements in the code editor. For more information, see Configure ETL in a data migration or data synchronization task and What is ETL?. Select No to skip. |
While DTS retries a connection, the DTS instance continues to incur charges. Set the retry time range based on your business requirements and release the DTS instance promptly after the source and destination instances are no longer in use.
Step 7: Save settings and run the precheck
Click Next: Save Task Settings and Precheck.
To view the API parameters for this task, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.
DTS runs a precheck before the task can start. If the precheck fails, click View Details next to each failed item, resolve the issues, and click Precheck Again.
If a precheck alert appears:
-
If the alert cannot be ignored, click View Details, resolve the issue, and rerun the precheck.
-
If the alert can be ignored, click Confirm Alert Details. In the View Details dialog, click Ignore, then click OK, and click Precheck Again. Ignoring an alert may cause data inconsistency.
Step 8: Purchase the instance
Wait until the precheck success rate reaches 100%, then click Next: Purchase Instance.
On the Purchase Instance page, configure the following parameters.
| Section | Parameter | Description |
|---|---|---|
| New Instance Class | Resource Group | The resource group for the data migration instance. Default: default resource group. For more information, see What is Resource Management?. |
| Instance Class | The instance class determines migration speed. Select a class based on your scenario. For more information, see Specifications of data migration instances. |
Step 9: Start the task
Select the Data Transmission Service (Pay-as-you-go) Service Terms check box, then click Buy and Start. Monitor progress in the task list.