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

Prerequisites

  • The version of the self-managed Oracle database is 9i, 10g, 11g, 12c, 18c, or 19c.
  • 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.
  • 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.
  • An AnalyticDB for PostgreSQL instance is created. For more information, see Create a AnalyticDB for PostgreSQL instance.

Billing

Migration type Task 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 in 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 partitioned 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, we recommend that you 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:

  • DML operations: INSERT, UPDATE, and DELETE
  • DDL operation: ADD COLUMN

Incremental data migration allows you to ensure service continuity when you migrate data from a self-managed Oracle database.

Permissions required for database accounts

Database Schema migration Full data migration Incremental data migration
Self-managed Oracle database The permissions of the schema owner The permissions of the schema owner The database administrator (DBA) permission
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.

Enable logging and grant fine-grained permissions to an Oracle database account

Notice If you need to migrate data 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
    # 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;
    # Switch to the pluggable database (PDB). Create a database account, for example, rdsdt_dtsacct, and grant permissions to the account.
    ALTER SESSION SET container = ORCLPDB1;
    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  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;
    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;
    -- V$PDBS privileges
    grant select on V_$PDBS to rdsdt_dtsacct;
    
    # Switch to the container database (CDB). Create a database account and grant permissions to the account by using one of the following methods:
    ALTER SESSION SET container = CDB$ROOT;
    Method 1: Create a global account starting with C##, for example, C##rdsdt_dtsacct, and grant permissions to the account. If you use this method, you must submit a ticket and contact the DTS team to modify some parameters. The link to submit a ticket is provided in the note.
    create user C##rdsdt_dtsacct IDENTIFIED BY rdsdt_dtsacct;
    grant create session to C##rdsdt_dtsacct;
    grant connect to C##rdsdt_dtsacct;
    grant resource to C##rdsdt_dtsacct;
    grant select on v_$logmnr_contents to rdsdt_dtsacct;
    grant LOGMINING to C##rdsdt_dtsacct;
    grant EXECUTE_CATALOG_ROLE to C##rdsdt_dtsacct;
    grant execute on sys.dbms_logmnr to C##rdsdt_dtsacct;
    Method 2: Create a database account, for example, rdsdt_dtsacct, and grant permissions to the account. If you use this method, you must modify the default parameters of the Oracle database.
    alter session set "_ORACLE_SCRIPT"=true;
    create user rdsdt_dtsacct IDENTIFIED BY rdsdt_dtsacct;
    grant create session to rdsdt_dtsacct;
    grant connect to rdsdt_dtsacct;
    grant select on v_$logmnr_contents to rdsdt_dtsacct;
    grant LOGMINING TO rdsdt_dtsacct;
    grant EXECUTE_CATALOG_ROLE to rdsdt_dtsacct;
    grant execute on sys.dbms_logmnr to rdsdt_dtsacct;
    # 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 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;
    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;
    grant LOGMINING TO rdsdt_dtsacct;
    grant EXECUTE_CATALOG_ROLE to rdsdt_dtsacct;
    grant execute on sys.dbms_logmnr to rdsdt_dtsacct;
    Note To create a global account starting with C## for a multitenant container database (CDB) in Oracle 12c to 19c, you must submit a ticket and contact the DTS team to modify some parameters.

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 the 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 to identify the task. 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 Elastic Compute Service (ECS) instance on which the self-managed Oracle database is hosted.
    ECS Instance ID Select the ID of the ECS instance on which the self-managed Oracle database is hosted.
    Database Type Select Oracle.
    Port Number Enter the service port number of the self-managed Oracle database. The default port number is 1521.
    Instance Type
    • If you select Non-RAC Instance, you must specify the SID parameter.
    • 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 self-managed Oracle database.
    Database Account Enter the account of the self-managed 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 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 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 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 one or more objects from the Available section and click the Rightwards arrow icon to move the objects to the Selected section.
    Note
    • You can select columns, tables, or schemas as the objects to be migrated.
    • By default, 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 rename the objects that are migrated to the destination database. For more information, see Object name mapping.
    • If you use the object name mapping feature to rename an object, other objects that are dependent on the object may fail to be migrated.
    Specify whether to rename objects You can use the object name mapping feature to rename the objects that are migrated to the destination instance. For more information, see Object name mapping.
    Specify the retry time for failed connections to the source or destination database By default, if DTS fails to connect to the source or destination database, DTS retries within the next 12 hours. You can specify the retry time based on your needs. If DTS reconnects to the source and destination databases within the specified time, DTS resumes the data migration task. Otherwise, the data migration task fails.
    Note When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time based on your business needs. You can also release the DTS instance at your earliest opportunity after the source and destination instances are released.
    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 schema migration and 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 columns and distribution keys of the tables that you want to migrate 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 tables.
  9. In the lower-right corner of the page, click Precheck.
    Note
    • Before you can start the data migration task, a precheck is performed. You can start the data migration 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.
      • You can troubleshoot the issues based on the causes and run a precheck again.
      • If you do not need to troubleshoot the issues, you can ignore failed items and run 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 the task during full data migration. Otherwise, the data migrated to the destination database will be incomplete. You can wait until the data migration task automatically stops.

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

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

      Notice We recommend that you select an appropriate time to manually stop the data migration task. For example, you can stop the task during off-peak hours or before you switch your workloads to the destination cluster.
      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. Wait until the status of incremental data migration changes to The migration task is not delayed again. Then, manually stop the migration task. Stop a task during incremental data migration