This topic describes how to migrate data from a user-created Oracle database to an AnalyticDB for PostgreSQL instance by using Data Transmission Service (DTS).

Prerequisites

  • An Oracle database of version 9i, 10g, 11g, 12c, 18c, or 19c is created.
  • The user-created 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.
  • 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.
  • An AnalyticDB for PostgreSQL instance is created in the china (Shanghai), China (Beijing), or China (Shenzhen) region. For more information, see Create an instance.

Billing

Migration type Instance configuration fee Internet traffic fee
Schema migration and full data migration Free of charge Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Pricing.
Incremental data migration Charged. For more information, see Pricing.

Precautions

  • During full data migration, DTS uses read and write resources of the source and destination databases. This may increase the loads of the database servers. Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours.
  • If a data migration task fails, DTS automatically resumes the task. Before you switch your workloads to the destination database, stop or release the data migration task. Otherwise, the data from the source database will overwrite the data in the destination database after the task is resumed.

Migration types

Migration type Description
Schema migration DTS migrates the schemas of the required objects from the source database to the destination database. DTS supports schema migration for the following types of objects: table, index, constraint, function, sequence, and view.
Warning
  • Oracle and AnalyticDB for PostgreSQL are heterogeneous databases. DTS does not ensure that the schemas of the source and destination databases are consistent after schema migration. We recommend that you evaluate the impact of data type conversion on your business. For more information, see Data type mappings between heterogeneous databases.
  • For partition tables, DTS discards the partition definitions. You must define partitions in the destination database.
Full data migration DTS migrates historical data of the required objects from the source database to the destination database.
Note During schema migration and full data migration, do not perform data definition language (DDL) operations on the required objects. Otherwise, the objects may fail to be migrated.
Incremental data migration After full data migration is complete, DTS retrieves redo log files from the source Oracle database. Then, DTS migrates incremental data from the source Oracle database to the destination database in real time.

DTS can synchronize the following SQL operations during incremental data migration:

  • Data manipulation language (DML) operations: INSERT, UPDATE, and DELETE
  • DDL operations: CREATE TABLE, ALTER TABLE, DROP TABLE, and TRUNCATE TABLE

Incremental data migration allows you to ensure service continuity when you migrate data from an Oracle database to an AnalyticDB for PostgreSQL instance.

Permissions required for database accounts

Database Schema migration Full data migration Incremental data migration
User-created Oracle database The owner permission on schemas The owner permission on schemas DBA
AnalyticDB for PostgreSQL The read and write permissions on the destination database The read and write permissions on the destination database The read and write permissions on the destination database

For more information about how to create and authorize a database account, see the following topics:

Notice If you need to migrate incremental data from an Oracle database but the DBA permission cannot be granted to the database account, you can grant fine-grained permissions to the account. The following sample statements show you how to grant specific permissions to an Oracle database account.

create session;
connect;
resource;
execute on sys.dbms_logmnr;
select on v_$logmnr_contents;
select on v_$log;
select on v_$logfile;
select on v_$archived_log;
select on v_$logmnr_logs;
select on v_$parameter;
select on v_$database;
select on all_objects;
select on all_tab_cols;
select on dba_registry;
select any table;
select any transaction;
select on v$active_instances;
select on v$instance;
select on sys.USER$;
select on SYS.OBJ$;
select on SYS.COL$;
select on SYS.IND$;
select on SYS.ICOL$;
select on SYS.CDEF$;
select on SYS.CCOL$;
select on SYS.TABPART$;
select on SYS.TABSUBPART$;
select on SYS.TABCOMPART$;
select on gv_$listener_network;
#Grant permissions on the pluggable database (PDB) and container database (CDB).
#Grant permissions on the PDB:
create   session;
connect;
resource;
select on  all_objects;
select on  all_tab_cols;
select on  dba_registry;
select any table;
select any transaction;
select on v_$log;
select on v_$logfile;
select on v_$archived_log;
select on v_$parameter;
select on v_$database;
select on v_$active_instances;
select on v_$instance;
select on V_$PDBS;
select on sys.USER$;
select on SYS.OBJ$;
select on SYS.COL$;
select on SYS.IND$;
select on SYS.ICOL$;
select on SYS.CDEF$;
select on SYS.CCOL$;
select on SYS.TABPART$;
select on SYS.TABSUBPART$;
select on SYS.TABCOMPART$;

#Grant permissions on the CDB:
create   session;
LOGMINING;
select on v_$logmnr_contents;

#The following sample statements show you how to grant permissions to a database account named dtstest.
create user dtstest IDENTIFIED BY rdsdt_dtsacct;
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;
#The following sample statements show you how to grant permissions on the pluggable database (PDB) and container database (CDB) to a database account named dtstest.
#Grant permissions on the PDB:
create user dtstest IDENTIFIED BY rdsdt_dtsacct;
grant create  session to dtstest;
grant connect  to dtstest;
grant resource 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;
-- v$log privileges
grant select on v_$log to dtstest;
-- v$logfile privileges
grant select on v_$logfile to dtstest;
-- v$archived_log privileges
grant select on v_$archived_log to dtstest;
-- v$parameter privileges
grant select on v_$parameter to dtstest;
-- v$database privileges
grant select on v_$database to dtstest;
-- v$active_instances privileges
grant select on v_$active_instances to dtstest;
-- v$instance privileges
grant select on v_$instance to dtstest;
-- V$PDBS privileges
grant select on V_$PDBS 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 permissions on the CDB:
create user dtstest IDENTIFIED BY rdsdt_dtsacct;
grant create   session to dtstest;
grant LOGMINING TO dtstest;
-- v$logmnr_contents privileges
grant select on v_$logmnr_contents to dtstest;

Procedure

  1. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration.
  3. At the top of the Migration Tasks page, select the region where the destination instance resides.
    Select a region
  4. In the upper-right corner of the page, click Create Migration Task.
  5. Configure source and destination databases.
    Configure the source and destination databases
    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 an instance type based on the deployment of the source database. In this example, select User-Created Database in ECS Instance.
    Note If you select other instance types, you must prepare the environment that is required for the source database. For more information, see Preparation overview.
    Instance Region Select the region of the ECS instance on which the source Oracle database is deployed.
    ECS Instance ID Select the ID of the ECS instance on which the user-created Oracle database is hosted.
    Database Type Select Oracle.
    Port Number Enter the service port number of the user-created Oracle database. The default port number is 1521.
    Instance Type
    • Non-RAC Instance: If you select this option, you must specify the SID.
    • RAC Instance: If you select this option, you must specify the Service Name.
    In this example, select Non-RAC Instance.
    SID Enter the system ID (SID) of the user-created Oracle database.
    Database Account Enter the account of the user-created Oracle database. For more information about the permissions that are required for the account, see Permissions required for database accounts.
    Database Password Enter the password of the source database account.
    Note After you specify the source database parameters, click Test Connectivity next to Database Password to verify whether the specified parameters are valid. If the specified parameters are valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Modify the source database parameters based on the check results.
    Destination Database Instance Type Select AnalyticDB for PostgreSQL.
    Instance Region Select the region where the destination AnalyticDB for PostgreSQL instance resides.
    Instance ID Select the ID of the destination AnalyticDB for PostgreSQL instance.
    Database Name Enter the name of the destination database.
    Database Account Enter the database account of the destination AnalyticDB for PostgreSQL instance. For more information about the permissions that are required for the account, see Permissions required for database accounts.
    Database Password Enter the password of the destination database account.
  6. In the lower-right corner of the page, click Set Whitelist and Next.
    DTS adds the CIDR blocks of DTS servers to the inbound rule of the ECS instance and the whitelist of the AnalyticDB for PostgreSQL instance. This ensures that DTS servers can connect to the source and destination instances.
  7. Select the migration types, the operation types, and the objects to be migrated.
    Select the migration types and the objects to be migrated
    Setting Description
    Select the migration types
    • To perform only full data migration, select Schema Migration and Full Data Migration.
    • To ensure service continuity during data migration, select Schema Migration, Full Data Migration, and Incremental Data Migration.
    Note If Incremental Data Migration is not selected, do not write data to the source database during full data migration. This ensures data consistency between the source and destination databases.
    Select the operation types Select the types of operations that you want to synchronize during incremental data migration. All operation types are selected by default.
    Select the objects to be migrated Select objects from the Available section and click the Right arrow icon to move the objects to the Selected section.
    Note
    • You can select columns, tables, or schemas as the objects to be migrated.
    • After an object is migrated to the destination database, the name of the object remains unchanged. You can use the object name mapping feature to change the names of the objects that are migrated to the destination database. For more information, see Object name mapping.
    • If you use the object name mapping feature on an object, other objects that are dependent on the object may fail to be migrated.
    Enclose object names in quotation marks Specify whether you need to enclose object names in quotation marks. If you select Yes and the following conditions are met, DTS encloses object names in single or double quotation marks during incremental data migration.
    • The business environment of the source database is case-sensitive but the database name contains both uppercase and lowercase letters.
    • A source table name does not start with a letter and contains characters other than letters, digits, and special characters.
      Note A source table name can contain only the following special characters: underscores (_), number signs (#), and dollar signs ($).
    • The names of the schemas, tables, or columns that you want to migrate are keywords, reserved keywords, or invalid characters in the destination database.
  8. Specify the primary key column and distribution key of the table that you want to synchronize to the AnalyticDB for PostgreSQL instance.
    Advanced settings: Migrate Oracle to AnalyticDB for PostgreSQL
    Note
    • For more information about primary key columns and distribution keys, see Define constraints and Define table distribution.
    • If DTS identifies tables without primary keys, the option Set Primary Keys and Distribution Keys of All Tables Without Primary Keys to ROWID is displayed on the preceding page. If you select this option, DTS adds the ROWID field as the primary key and distribution key to the destination table.
  9. In the lower-right corner of the page, click Precheck.
    Notice
    • Before you can start the data migration task, a precheck is performed. A data migration task can be started only if it 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 perform a precheck again.
  10. After the task passes the precheck, click Next.
  11. In the Confirm Settings dialog box, specify the Channel Specification parameter and select Data Transmission Service (Pay-As-You-Go) Service Terms.
  12. Click Buy and Start to start the data migration task.
    • Schema migration and full data migration

      We recommend that you do not manually stop a data migration task. Otherwise, data migrated to the destination database will be incomplete. Wait until the data migration task automatically stops.

    • Schema migration, full data migration, and incremental data migration

      An incremental data migration task does not automatically stop. You must manually stop the migration task.

      Notice Select an appropriate time to manually stop the migration task. For example, you can stop the migration task during off-peak hours or before you switch your workloads to the destination instance.
      1. Wait until Incremental Data Migration and The migration task is not delayed appear in the progress bar of the migration task. Then, stop writing data to the source database for a few minutes. The delay time of incremental data migration may be displayed in the progress bar.
      2. After the status of incremental data migration changes to The migration task is not delayed, manually stop the migration task.Stop an incremental data migration task