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
- An ApsaraDB RDS for PostgreSQL instance is created. For more information, see Create an ApsaraDB RDS for PostgreSQL instance.
- An ApsaraDB RDS for MySQL instance is created. For more information, see Create an ApsaraDB RDS for MySQL instance.
- The available storage space of the ApsaraDB RDS for MySQL instance is larger than the total size of the data in the ApsaraDB RDS for PostgreSQL instance.
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 tosync
. 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 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 Billing overview. |
Incremental data migration | Charged. For more information, see Billing overview. |
Migration types
Migration type | Description |
---|---|
Full data migration | DTS 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 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 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
Instance | Full data migration | Incremental data migration |
---|---|---|
ApsaraDB RDS for PostgreSQL instance | SELECT permission on the objects to be migrated | Permissions 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 instance | Read and write permissions | Read and write permissions |
- ApsaraDB RDS for PostgreSQL instance:Create an account on an ApsaraDB RDS for PostgreSQL instance
- ApsaraDB RDS for MySQL instance:Create an account on an ApsaraDB RDS for MySQL instance
- Log on to the DTS console. Note If you are redirected to the Data Management (DMS) console, you can click the icon in the lower-right corner to go to the previous version of the DTS console.
- In the left-side navigation pane, click Data Migration.
- At the top of the Migration Tasks page, select the region where the destination cluster resides.
- In the upper-right corner of the page, click Experience the new console.
- On the Create Task page, configure the data migration task.
- Specify the parameters of 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 The type of the source database. Select PostgreSQL. Access Method The access method of the source database. Select Alibaba Cloud Instance. Instance Region The region in which the ApsaraDB RDS for PostgreSQL instance resides. Instance ID 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 The type of the destination database. Select MySQL. Access Method The access method of the destination database. Select Alibaba Cloud Instance. Instance Region The region in which 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 Specifies 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 Template Save the source database settings as a template. - 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.
- Select objects for the task and perform advanced settings.
Section Parameter Description Basic Settings Specify 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 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:- DTS migrates only the incremental data that is generated in the ApsaraDB RDS for PostgreSQL instance after the task is started.
- Triggers cannot be synchronized during incremental data migration. For more information, see Configure a data synchronization task for a source database that contains a trigger.
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 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 failed connections to the source or destination database 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. - Click Next: Save Task Settings and Precheck in the lower part of the page.
- 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.
- After the precheck is passed, click Next: Purchase Instance in the lower part of the page.
- 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.
- 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.
- 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.
- 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 in the lower part of the page. - Full data migration
- Specify the parameters of the source and destination databases.
- 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.