This topic describes how to migrate data from a self-managed Oracle database to an ApsaraDB RDS for MySQL instance by using Data Transmission Service (DTS). DTS supports schema migration, full data migration, and incremental data migration. When you migrate data from a self-managed Oracle database, you can select all of the supported migration types to ensure service continuity.

Prerequisites

  • The engine version of the self-managed Oracle database is 9i, 10g, 11g, 12c, 18c, or 19c.
  • 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 runs in ARCHIVELOG mode. Archived log files of the Oracle database are accessible, and an appropriate retention period is specified for the archived log files. For more information, see Managing Archived Redo Log Files.
  • The size of available storage in the ApsaraDB RDS for MySQL instance is larger than the size of data that you want to migrate from the self-managed Oracle database.

Limits

  • DTS uses read and write resources of the source and destination databases during full data migration. This may increase the loads of the database servers. If the database performance is unfavorable, the specification is low, or the data volume is large, database services may become unavailable. For example, DTS occupies a large amount of read and write resources in the following cases: a large number of slow SQL queries are performed on the source database, the tables have no primary keys, or a deadlock occurs in the destination database. 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. For example, you can migrate data when the CPU utilization of the source and destination databases is less than 30%.
  • The tables to be migrated in the source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If the self-managed Oracle database is deployed in a Real Application Cluster (RAC) architecture and is connected to DTS over an Alibaba Cloud virtual private cloud (VPC), you must connect the Single Client Access Name (SCAN) IP address of the Oracle RAC and the virtual IP address (VIP) of each node to the VPC and configure routes. The settings ensure that your DTS task can run as expected. For more information, see Configure a route between DTS and Express Connect, VPN Gateway, or Smart Access Gateway.
    Important When you configure the source Oracle database in the DTS console, you can specify the SCAN IP address of the Oracle RAC as the database endpoint or IP address.
  • Table names in the ApsaraDB RDS for MySQL instance are not case-sensitive. If a table name in the self-managed Oracle database contains uppercase letters, ApsaraDB RDS converts all uppercase letters to lowercase letters and then creates the table.

    If the self-managed Oracle database contains identical table names that differ only in capitalization, the table names are identified as duplicates. As a result, the "The object already exists" message may be displayed during schema migration. To prevent table name conflicts in the ApsaraDB RDS for MySQL instance, you can rename the migrated objects by using the object name mapping feature of DTS. For more information, see Object name mapping.

  • DTS automatically creates a destination database in the ApsaraDB RDS for MySQL instance. If the name of the source database is invalid, you must manually create a destination database in the ApsaraDB RDS for MySQL instance before you configure a data migration task. For more information about the naming conventions of databases in ApsaraDB RDS for MySQL and how to create a database, see Create a database.

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 Billing overview.
Incremental data migration Charged. For more information, see Billing overview.

Migration types

  • Schema migration
    DTS supports schema migration for tables and indexes. DTS does not support schema migration for the following types of objects: views, synonyms, triggers, stored procedures, stored functions, packages, and user-defined data types. DTS has the following limits on schema migration for tables and indexes:
    • DTS does not support schema migration for nested tables. DTS converts clustered tables and index-organized tables into standard tables in the destination database.
    • DTS does not support schema migration for function-based indexes, domain indexes, bitmap indexes, or reverse indexes.
  • Full data migration

    DTS migrates the historical data of specified objects from the self-managed Oracle database to the destination database in the ApsaraDB RDS for MySQL instance.

  • Incremental data migration

    DTS uses the round-robin algorithm to retrieve redo log files from the self-managed Oracle database. Then, DTS migrates incremental data from the self-managed Oracle database to the destination database in the ApsaraDB RDS for MySQL instance. Incremental data migration ensures service continuity when you migrate data from the self-managed Oracle database to the destination database in the ApsaraDB RDS for MySQL instance.

SQL operations that can be synchronized

  • INSERT, DELETE, and UPDATE
  • CREATE TABLE
    Note If a CREATE TABLE statement creates a table that contains functions, DTS does not migrate the statement.
  • ALTER TABLE, ADD COLUMN, DROP COLUMN, RENAME COLUMN, and ADD INDEX
  • DROP TABLE
  • RENAME TABLE, TRUNCATE TABLE, and CREATE INDEX

Data type mappings

For more information, see Data type mappings between heterogeneous databases.

Preparations

Log on to the self-managed Oracle database, create an account that you want to use to collect data, and then grant permissions to the account.

Note If you have created an account that is granted the permissions listed in the following table, you can skip this step.
Database Schema migration Full data migration Incremental data migration
Self-managed Oracle databases Permissions of the schema owner Permissions of the schema owner Database administrator (DBA)
ApsaraDB RDS for MySQL instance Write permissions on the destination database Write permissions on the destination database Write permissions on the destination database

To create a database account and grant permissions to the database account, perform the following operations:

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

Important If you need to migrate incremental data from an Oracle database but the database administrator (DBA) permissions 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 based on your business requirements.
    Note You can enable database-level supplemental logging to ensure the stability of Data Transmission Service (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. Execute the following statement to enable minimal supplemental logging:
        alter database add supplemental log data;
      2. Execute the following statement to 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. Execute the following statement to 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;
    Force logging Execute the following statement to enable force logging:
    alter database force logging;
  2. Grant fine-grained permissions to an Oracle database account
    # Create a database account named 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;
    grant select_catalog_role TO rdsdt_dtsacct;
    
    # Switch to the pluggable database (PDB). Create a database account named 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;
    grant select on v$database to rdsdt_dtsacct;
    grant select on dba_objects to rdsdt_dtsacct;
    grant select on DBA_TAB_COMMENTS to rdsdt_dtsacct;
    grant select on dba_tab_cols to rdsdt_dtsacct;
    grant select_catalog_role TO rdsdt_dtsacct;
    
    # Switch to the CDB$ROOT, which is the root container of the container database (CDB). Create a database account and grant permissions to the account.
    ALTER SESSION SET container = CDB$ROOT;
    # Create a database account named rdsdt_dtsacct and grant permissions to the account. 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 named 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;
    grant select on v$database to rdsdt_dtsacct;
    grant select on dba_objects to rdsdt_dtsacct;
    grant select on DBA_TAB_COMMENTS to rdsdt_dtsacct;
    grant select on dba_tab_cols 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;
    grant select_catalog_role TO rdsdt_dtsacct;

Procedure

  1. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration.
  3. In the upper part of the Migration Tasks page, select the region where the ApsaraDB RDS for MySQL instance resides.
  4. In the upper-right corner of the page, click Create Migration Task.
  5. Configure the self-managed Oracle database and the ApsaraDB RDS for MySQL instance. Configure the self-managed Oracle database and the ApsaraDB RDS for MySQL instance
    Section Parameter Description
    N/A 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 specify a unique task name.
    Source Database Instance Type The type of the source database. In this example, User-Created Database with Public IP Address is selected.
    Note If you select a different instance type, you must set up the environment that is required for the self-managed database. For more information, see Preparation overview.
    Instance Region If you select User-Created Database with Public IP Address as the instance type, you do not need to specify the Instance Region parameter.
    Note If an IP address whitelist is configured for the self-managed Oracle database, you must add the CIDR blocks of DTS servers to the IP address whitelist of the database. You can click Get IP Address Segment of DTS next to Instance Region to obtain the CIDR blocks of DTS servers.
    Database Type Select Oracle.
    Hostname or IP Address The endpoint that is used to connect to the self-managed Oracle database. In this example, the public IP address of the database is used.
    Port Number The port number that is used to connect to the self-managed Oracle database. The port must be accessible over the Internet. The default port number is 1521.
    Instance 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.
    Database Account The account of the self-managed Oracle database. For information about the permissions that are required for the account, see Preparations.
    Database Password The password of the preceding account.
    Note After you specify the information about the self-managed Oracle database, you can click Test Connectivity next to Database Password to check whether the information is valid. If the information is valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Then, modify the information based on the check results.
    Destination Database Instance Type Select RDS Instance.
    Instance Region The region where the destination instance resides.
    RDS Instance ID The ID of the destination instance.
    Database Account The database account of the destination instance. For information about the permissions that are required for the account, see Preparations.
    Database Password The password of the preceding account.
    Note After you specify the information about the ApsaraDB RDS for MySQL instance, you can click Test Connectivity next to Database Password to check whether the information is valid. If the information is valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Then, modify the information based on the check results.
  6. 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 the 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.
  7. Select the migration types and the objects that you want to migrate. Select the migration types and the objects that you want to migrate
    Setting Description
    Select migration types
    • If you want 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 you do not select Incremental Data Migration, make sure that no data is written to the self-managed Oracle database during full data migration. This ensures data consistency between the self-managed Oracle database and the ApsaraDB RDS for MySQL instance.
    Select the objects that you want to migrate

    Select one or more objects in the Available section and click the Rightwards arrow icon to move the objects to the Selected section.

    Note
    • You can select columns, tables, or databases as the objects to be migrated.
    • By default, the name of an object that is migrated to the ApsaraDB RDS for MySQL instance remains the same as that in the self-managed Oracle database. You can use the object name mapping feature to rename the objects that are migrated to the ApsaraDB RDS for MySQL instance. For more information, see Object name mapping.
    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 range for failed connections to the self-managed Oracle database or ApsaraDB RDS for MySQL instance By default, if DTS fails to connect to the source and destination databases, DTS retries within the following 12 hours. You can specify the retry time range based on your business requirements. If DTS is reconnected to the source and destination databases within the specified time range, DTS resumes the data migration task. Otherwise, the data migration task fails.
    Note Within the time range in which DTS attempts to reconnect to the source and destination databases, 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 the earliest opportunity after the source and destination databases are released.
  8. Click Precheck.
    Note
    • A precheck is performed before the migration task starts. The migration task only starts after the precheck succeeds.
    • If the precheck fails, click the Note icon next to each failed check item to view the related details. Fix the issues as instructed and run the precheck again.
  9. After the task passes the precheck, click Next.
  10. In the Confirm Settings dialog box, set the Channel Specification parameter and select Data Transmission Service (Pay-as-you-go) Service Terms.
  11. Click Buy and Start to start the data migration task.
    • Full data migration

      Do not manually stop a full data migration task. If you manually stop a full data migration task, the data that is migrated to the ApsaraDB RDS for MySQL instance may be incomplete. You can wait until the data migration task automatically stops.

    • Incremental data migration

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

      Note We recommend that you manually stop an incremental data migration task at an appropriate point in time. For example, you can stop the task during off-peak hours or before you switch your workloads over to the ApsaraDB RDS for MySQL instance.
      1. Wait until Incremental Data Migration and The data migration task is not delayed are displayed in the progress bar of the data migration task. Then, stop writing data to the source instance for a few minutes. The latency of incremental data migration may be displayed in the progress bar.
      2. Wait until the status of incremental data migration changes to The data migration task is not delayed again. Then, manually stop the migration task. The data migration task is not delayed
  12. Switch your workloads over to the ApsaraDB RDS for MySQL instance.

What to do next

The accounts that are used to migrate data are granted the read and write permissions. After the data migration is complete, you must delete the accounts of the self-managed Oracle database and the ApsaraDB RDS for MySQL instance to ensure database security.

References

DTS supports reverse data transmission when you migrate data from a self-managed Oracle database to an ApsaraDB RDS for MySQL instance. You can use this feature to synchronize data changes from the ApsaraDB RDS for MySQL instance to the self-managed Oracle database.