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

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.
  • To ensure that the data migration task runs as expected, you can perform primary/secondary switchover only on an ApsaraDB RDS for PostgreSQL 11 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 11, the data migration task stops.
  • If you modify the endpoint or zone of the ApsaraDB RDS for PostgreSQL instance, the data migration task stops.
  • Schema migration is not supported. Before you configure a data migration task, you must create databases and tables in the destination instance.
  • A data migration task can migrate data from only onedatabase. 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 cluster, stop or release the data migration task. Otherwise, the data in the source database overwrites the data in the destination cluster 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.
  • If the source database has long-running transactions and the task contains incremental data migration, the write-ahead logging (WAL) logs that are generated before the long-running transactions are submitted may not be cleared and therefore pile up, resulting in insufficient storage space in the source database.

Billing

Migration typeTask configuration feeInternet traffic fee
Full data migrationFree of charge. Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Billing overview.
Incremental data migrationCharged. For more information, see Billing overview.

Migration types

Migration typeDescription
Full data migrationDTS migrates the historical data of objects from the source database to the destination ApsaraDB RDS for MySQL instance.
Important During full data migration, we recommend that you do not perform DDL operations on objects. Otherwise, the objects may fail to be migrated.
Incremental data migrationDTS 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 by using the redo log files. 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

InstanceFull data migrationIncremental data migration
ApsaraDB RDS for PostgreSQL instanceSELECT permission on the objects to be migratedPermissions of the superuser role
Note If the source database runs on an ApsaraDB RDS for PostgreSQL 9.4 instance and you need to migrate only DML operations, only the REPLICATION permission is required for the database account.
ApsaraDB RDS for MySQL instanceRead and write permissionsRead and write permissions
For more information about how to create a database account and grant permissions to the database account, see the following topics:
  1. Log on to the DTS console.
    Note If you are redirected to the Data Management (DMS) console, you can click the old icon in the lower-right corner to go to the previous version of 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 parameters of the source and destination databases.
      SectionParameterDescription
      N/ATask NameThe 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 DatabaseSelect TemplateSelect an existing database connection template for quick configuration.
      Database TypeThe type of the source database. Select PostgreSQL.
      Access MethodThe access method of the source database. Select Alibaba Cloud Instance.
      Instance RegionThe region in which the ApsaraDB RDS for PostgreSQL instance resides.
      Instance IDThe ID of the ApsaraDB RDS for PostgreSQL instance.
      Database NameThe name of the ApsaraDB RDS for PostgreSQL instance.
      Database AccountThe database account of the ApsaraDB RDS for PostgreSQL instance.
      Database PasswordThe password of the database account.
      Save as TemplateSave the source database settings as a template.
      Destination DatabaseDatabase TypeThe type of the destination database. Select MySQL.
      Access MethodThe access method of the destination database. Select Alibaba Cloud Instance.
      Instance RegionThe region in which the ApsaraDB RDS for MySQL instance resides.
      RDS Instance IDThe ID of the ApsaraDB RDS for MySQL instance.
      Database AccountThe database account of the ApsaraDB RDS for MySQL instance.
      Database PasswordThe password of the database account.
      EncryptionSpecifies whether to encrypt the connection to the destination instance. 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 on 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 TemplateSave 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.
      SectionParameterDescription
      Basic SettingsSpecify task stagesTo 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 data of the ApsaraDB RDS for PostgreSQL instance is updated during full data migration, the updated data 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 database is empty, the precheck is passed. If the database 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 databases.
        Warning If you select Ignore, data records in the source database overwrite the data records that have the same keys in the destination database. Proceed with caution.
      Select objects to be synchronized

      Select one or more objects from the Source Objects section and click the > icon to move the objects to the Selected Objects 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 SettingsSet alertsSpecify 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 failed connections to the source or destination databaseValid 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 passed, click Next: Purchase Instance in the lower part of the page.
    7. On the Purchase Instance page, specify the Specification parameter and select the check box to agree to 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 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 migration task is not delayed are displayed in the progress bar of the migration task. Then, stop writing data to the source database 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.
      Note To delete a data migration task, you can select the task and click delete in the lower part of the page.
  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.