PolarDB is a next-generation relational database service that is developed by Alibaba Cloud. PolarDB is compatible with the MySQL database engine and features high availability, ease of use, and reliability. This topic describes how to migrate data from a self-managed MySQL database to a PolarDB for MySQL cluster by using Data Transmission Service (DTS).
Prerequisites
- The engine version of the self-managed MySQL database is 5.1, 5.5, 5.6, 5.7, or 8.0.
- A PolarDB for MySQL cluster is created. For more information, see Create a PolarDB for MySQL cluster.
- If the source MySQL database is an on-premises database, the CIDR blocks of DTS servers must be added to the IP whitelist of the database. This setting ensures that DTS servers can access the source MySQL database. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
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 source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
- DTS uses the
ROUND(COLUMN,PRECISION)
function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits. You must check whether the precision settings meet your business requirements. - If a data migration task fails, DTS automatically resumes the task. Therefore, 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.
Migration types
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 Pricing. |
Incremental data migration | Charged. For more information, see Pricing. |
SQL operations that can be synchronized during incremental data migration
Operation type | SQL statements |
---|---|
DML | INSERT, UPDATE, DELETE, and REPLACE |
DDL |
|
Permissions required for database accounts
Database | Schema migration and full data migration | Incremental data migration |
---|---|---|
Self-managed MySQL database | The SELECT permission | The REPLICATION SLAVE, REPLICATION CLIENT, SHOW VIEW, and SELECT permissions |
PolarDB for MySQL cluster | 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:
- Self-managed MySQL databases: Create an account for a user-created MySQL database and configure binary logging
- PolarDB for MySQL clusters: Create a database account
Preparations
Create an account for a user-created MySQL database and configure binary logging