This topic describes how to synchronize data from an ApsaraDB RDS for MySQL instance to an AnalyticDB for PostgreSQL instance in Serverless mode by using Data Transmission Service (DTS). The data synchronization feature provided by DTS allows you to transmit data for analysis.
Prerequisites
- An ApsaraDB RDS for MySQL instance is created. For more information, see Create an ApsaraDB RDS for MySQL instance.
- An AnalyticDB for PostgreSQL instance of V1.0.3.1 or later in Serverless mode is created.
- For more information about how to create an AnalyticDB for PostgreSQL instance in Serverless mode, see Create an instance.
- For more information about how to view and update the minor engine version of an instance, see View the minor engine version and Update the minor engine version.
Supported MySQL database types
The following types of MySQL databases can be synchronized to AnalyticDB for PostgreSQL instances in Serverless mode. In this topic, an ApsaraDB RDS for MySQL instance is used to describe how to configure a data synchronization task. You can also follow the procedure to configure data synchronization tasks for other types of MySQL databases.- ApsaraDB RDS for MySQL instance
- Self-managed database that is hosted on Elastic Compute Service (ECS)
- Self-managed database that is connected over Express Connect, VPN Gateway, or Smart Access Gateway
- Self-managed database that is connected over Database Gateway
- Self-managed database that is connected over Cloud Enterprise Network (CEN)
DTS can also synchronize data from PostgreSQL, SQL Server, and Db2 databases. For more information, see Supported databases.
Precautions
Category | Description |
---|---|
Limits on the source database |
|
Other limits |
|
Special cases | If the source database is a self-managed MySQL database, take note of the following items:
|
Billing
Synchronization type | Task configuration fee |
---|---|
Schema synchronization and full data synchronization | Free of charge. |
Incremental data synchronization | Charged. For more information, see Billing overview. |
Supported synchronization topologies
- One-way one-to-one synchronization
- One-way one-to-many synchronization
- One-way many-to-one synchronization
SQL operations that can be synchronized
- DML operations: INSERT, UPDATE, and DELETE
- DDL operation: ADD COLUMN Note The CREATE TABLE operation is not supported. To synchronize data from a new table, you must add the table to the selected objects. For more information, see Add an object to a data synchronization task.
Term mappings
MySQL | AnalyticDB for PostgreSQL |
---|---|
Database | Schema |
Table | Table |
Procedure
- Go to the Data Synchronization page of the new DTS console. Note You can also log on to the DMS console. In the top navigation bar, click DTS. Then, in the left-side navigation pane, choose .
- In the top navigation bar, select the region where the data synchronization instance resides.
- Click Create Task. On the Create Task page, configure 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. You do not need to use a unique task name. Source Database Select Instance Select an existing ApsaraDB RDS for MySQL instance. This parameter is optional. Database Type Select MySQL. Access Method Select Alibaba Cloud Instance. Instance Region The region where the source ApsaraDB RDS for MySQL instance resides. Replicate Data Across Alibaba Cloud Accounts Select No in this example. RDS Instance ID The ID of the source ApsaraDB RDS for MySQL instance. Database Account The database account of the source ApsaraDB RDS for MySQL database. The account must have the REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, and SELECT permissions. Database Password The password of the database account. Encryption Select Non-encrypted or SSL-encrypted based on your requirements. If you want to select SSL-encrypted, you must enable SSL encryption for the ApsaraDB RDS for MySQL instance before you configure the data synchronization task. For more information, see Configure SSL encryption for an ApsaraDB RDS for MySQL instance. Destination Database Select Instance Select an existing AnalyticDB for PostgreSQL instance in Serverless mode. This parameter is optional. Database Type Select AnalyticDB for PostgreSQL. Access Method Select Alibaba Cloud Instance. Instance Region The region where the destination AnalyticDB for PostgreSQL instance in Serverless mode resides. Instance ID The ID of the destination AnalyticDB for PostgreSQL instance in Serverless mode. Database Name The name of the destination database in the AnalyticDB for PostgreSQL instance in Serverless mode. Database Account The initial account of the destination AnalyticDB for PostgreSQL instance in Serverless mode. Note You can also enter an account that has the RDS_SUPERUSER permission. For more information, see Manage users and permissions.Database Password The password of the database account. - In the lower part of the page, click Test Connectivity and Proceed. Note
- DTS adds the CIDR blocks of DTS servers to the whitelist of the ApsaraDB RDS for MySQL instance. For more information, see the "CIDR blocks of DTS servers" section of the Add the CIDR blocks of DTS servers to the security settings of on-premises databases topic.
- After your DTS task is completed or released, we recommend that you manually remove the added CIDR blocks from the whitelist.
- In the lower part of the page, click Next: Configure Database and Table Fields. On the page that appears, set the primary key columns and distribution key columns of the tables that you want to synchronize to the destination AnalyticDB for PostgreSQL instance.
- In the lower part of the page, click Next: Save Task Settings and Precheck. Note
- Before you can start the data synchronization task, DTS performs a precheck. You can start the data synchronization task 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 analyze the causes based on the check results, troubleshoot the issues. Then, run a precheck again.
- If an alert is generated for an item during the precheck, perform the following operations based on the scenario:
- In scenarios in which you cannot ignore the alert item, click View Details next to the failed item. After you analyze the causes based on the check results, troubleshoot the issues. Then, run a precheck again.
- In scenarios in which you can ignore the alert item, click Confirm Alert Details next to the failed item. In the View Details dialog box, click Ignore. In the message that appears, click OK. Then, click Precheck Again to run a precheck again. If you ignore the alert item, data inconsistency may occur and your business may be exposed to potential risks.
- Wait until the success rate becomes 100%. Then, click Next: Purchase Instance.
- On the Purchase Instance page, configure the Billing Method and Instance Class parameters for the data synchronization instance. The following table describes the parameters.
Section Parameter Description New Instance Class Billing Method - Subscription: You pay for the instance when you create an instance. The subscription billing method is more cost-effective than the pay-as-you-go billing method for long-term use.
- Pay-as-you-go: A pay-as-you-go instance is charged on an hourly basis. The pay-as-you-go billing method is suitable for short-term use. If you no longer require a pay-as-you-go instance, you can release the pay-as-you-go instance to reduce costs.
Instance Class DTS provides several instance classes that have different performance in synchronization speed. You can select an instance class based on your business scenario. For more information, see Specifications of data synchronization instances. Subscription Duration If you select the subscription billing method, set the subscription duration and the number of instances that you want to create. The subscription duration can be one to nine months or one to three years. Note This parameter is displayed only if you select the subscription billing method. - Read and select the check box for Data Transmission Service (Pay-as-you-go) Service Terms.
- Click Buy and Start to start the data synchronization task. You can view the progress of the task in the task list.
Troubleshooting
- If an error is repeatedly reported during schema synchronization after you make sure that the table schema is consistent, Submit a ticket.
- VACUUM operations are not automatically performed during data synchronization because they may affect subsequent data write speeds. We recommend that you periodically perform VACUUM operations on databases.
- If an exception occurs during full data synchronization, you must clear the data in the destination table and write data again.
- The data synchronization performance of AnalyticDB for PostgreSQL instances in Serverless mode is good in scenarios where a large amount of data is written from a single table, but poor in scenarios where a small amount of data is written from hot data rows or multiple tables. If your business involves the latter scenarios, we recommend that you Submit a ticket for parameter optimization and performance improvement.