This topic describes how to migrate data from an ApsaraDB RDS for PostgreSQL instance to an ApsaraDB RDS for MySQL instance by using Data Transmission Service (DTS). DTS supports full data migration and incremental data migration. When you configure a data migration task, you can select both of the supported migration types to ensure service continuity.

Prerequisites

Precautions

  • 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.
  • To ensure that the data migration task runs as expected, you can perform a primary/secondary switchover only on a V11 ApsaraDB RDS for PostgreSQL instance. In this case, you must set the rds_failover_slot_mode parameter to sync. For more information, see Logical Replication Slot Failover.
    Warning If you perform a primary/secondary switchover on a self-managed PostgreSQL database or an ApsaraDB RDS for PostgreSQL instance of a version other than V11, the data migration task stops.
  • If you modify the endpoint or zone of the ApsaraDB RDS for PostgreSQL instance, the data migration task stops.
  • Before you configure a data migration task, you must create the corresponding databases and tables in the destination instance.
  • A data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.
  • If a data migration task fails, DTS automatically resumes the task. Before you switch your workloads to the destination instance, stop or release the data migration task. Otherwise, the data in the source database overwrites the data in the destination instance after the task is resumed.
  • If you perform a primary/secondary switchover during data migration, incremental data fails to be migrated. We recommend that you perform the primary/secondary switchover after the data migration task is complete.

Billing

Migration type Task 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 Pricing.
Incremental data migration Charged. For more information, see Pricing.

Migration types

Migration type Description
Full data migration DTS migrates the historical data of required objects from the source database to the destination ApsaraDB RDS for MySQL instance.
Notice During full data migration, we recommend that you do not perform DDL operations on the required objects. Otherwise, the objects may fail to be migrated.
Incremental data migration DTS retrieves redo log files from the source database. Then, DTS migrates incremental data from the source database to the destination ApsaraDB RDS for MySQL instance. DTS can synchronize DML operations, such as INSERT, UPDATE, and DELETE. DTS cannot synchronize DDL operations.

Incremental data migration allows you to ensure service continuity when you perform data migration.

Permissions required for database accounts

Database Full data migration Incremental data migration
ApsaraDB RDS for PostgreSQL instance The SELECT permission on the objects to migrate Permissions of the superuser role
Note If the source database runs on an ApsaraDB RDS for PostgreSQL V9.4 instance and you migrate only DML operations, the database account must have the REPLICATION permission.
ApsaraDB RDS for MySQL instance Read and write permissions Read and write permissions
For more information about how to create a database account and grant permissions to the account, see the following topics:
  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 cluster resides.
  4. In the upper-right corner of the page, click Experience the new console.
  5. On the Create Task page, configure the data migration task.
    1. Specify the information about the source and destination databases.
      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 Select Template Select an existing database connection template for quick configuration.
      Database Type Select PostgreSQL.
      Access Method Select Cloud Instance.
      Instance Region The region where the ApsaraDB RDS for PostgreSQL instance resides.
      The ID of the instance. The ID of the ApsaraDB RDS for PostgreSQL instance.
      Database Name The name of the ApsaraDB RDS for PostgreSQL instance.
      Database Account The database account of the ApsaraDB RDS for PostgreSQL instance.
      Database Password The password of the database account.
      Save as Template Save the source database settings as a template.
      Destination Database Database Type Select MySQL.
      Access Method Select Cloud Instance.
      Instance Region The region where the ApsaraDB RDS for MySQL instance resides.
      RDS Instance ID The ID of the ApsaraDB RDS for MySQL instance.
      Database Account The database account of the ApsaraDB RDS for MySQL instance.
      Database Password The password of the database account.
      Encryption Select Non-encrypted or SSL-encrypted. If you want to select SSL-encrypted, you must enable SSL encryption for the ApsaraDB RDS for MySQL instance before you configure the data migration task. For more information, see Configure SSL encryption for an ApsaraDB RDS for MySQL instance.
      Note The Encryption parameter is available only for regions in the Chinese mainland and the China (Hong Kong) region.
      Save as Template Save the source database settings as a template.
    2. Click Test Connectivity and Proceed to verify whether the parameters specified for the source and destination databases are valid.
      • If the specified parameters are valid, the Passed message is displayed.
      • If the Failed message is displayed, click Check next to Failed. Modify the parameters of the source or destination database based on the check results.
    3. Select objects for the task and perform advanced settings.
      Section Parameter Description
      Basic Settings Task Stages To ensure data consistency, we recommend that you select both Full Data Migration and Incremental Data Migration.
      If you select only Full Data Migration, take note of the following items:
      • If the ApsaraDB RDS for PostgreSQL instance has data updates during full data migration, the data updates may not be migrated to the ApsaraDB RDS for MySQL instance.
      • If the ApsaraDB RDS for MySQL instance has less than 2 CPU cores, we recommend that you disable the slow query logging feature. For more information, see Disable slow query log to improve migration performance.
      If you select only Incremental Data Migration, take note of the following items:
      Select the processing mode of conflicting tables
      • Precheck and Report Errors: checks whether the destination instance is empty. If the destination instance is empty, the precheck is passed. If the instance is not empty, an error is returned during the precheck and the data synchronization task cannot be started.
      • Ignore Errors and Proceed: skips the check for empty destination instances.
        Warning If you select Ignore Errors and Proceed, the data records in the source database overwrite the data records that have the same keys in the destination database. Proceed with caution.
      Select the objects to be synchronized

      Select one or more objects from the Available section and click the p260322 icon to add the objects to the Selected section.

      Note
      • You can select columns, tables, or databases as the objects to migrate.
      • 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.
      Advanced Settings Set alerts Specify whether to set alerts for the data migration task.
      • If you do not want to set alerts, select No.
      • If you want to set alerts, select Yes.
      Specify the retry time range for a failed connection to the source or destination instance. Valid values: 10 to 1440. We recommend that you set the retry time range to more than 30 minutes. If multiple DTS instances have the same source or destination database, the lowest value takes effect. For example, the retry time is set to 30 minutes for Instance A and 60 minutes for Instance B, DTS retries failed connections at an interval of 30 minutes.
    4. Click Next: Save Task Settings and Precheck in the lower part of the page.
    5. Run a precheck before you start the data migration task. DTS migrates data 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 causes, you can run a precheck again.
    6. After the precheck is complete, click Next: Purchase Instance in the lower part of the page.
    7. On the Purchase Instance page, specify the Specification parameter and read and select Data Transmission Service (Pay-as-you-go) Service Terms.
    8. Click Buy and Start to start the data migration task.
      • 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 may be incomplete. You can wait until the full data migration task automatically stops.

      • Incremental data migration
        An incremental data migration task does not automatically stop. You must manually stop the task.
        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 database for a few minutes. The delay time of incremental data migration may be displayed in the progress bar.
        2. Wait until the state of incremental data migration changes to The data migration task is not delayed again. Then, manually stop the migration task.
      Note To delete a data migration task, you can select the task and click 2 in the lower part of the page, and click the del to release the task.
  6. Switch your workloads from the ApsaraDB RDS for PostgreSQL instance to the ApsaraDB RDS for MySQL instance. For more information, see Switch workloads to the destination database.