PolarDB is a next-generation relational database service that is developed by Alibaba Cloud. The service 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 user-created MySQL database to a PolarDB for MySQL cluster by using Data Transmission Service (DTS).
Prerequisites
- The version of the user-created MySQL database is 5.1, 5.5, 5.6, 5.7, or 8.0.
- The destination PolarDB for MySQL cluster is created. For more information, see Create a PolarDB MySQL cluster.
- If the source MySQL database is an on-premises database, the CIDR blocks of DTS servers are added to the IP whitelist of the source MySQL 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. Before you switch your workloads to the destination cluster, stop or release the data migration task. Otherwise, the data in the source database will overwrite the data in the destination cluster after the task is resumed.
Introduction to migration types
DTS supports schema migration, full data migration, and incremental data migration.
For more information, see Terms.
Note When you select all of the three migration types, data between databases can be smoothly
migrated.
Billing
Migration type | Instance 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 statement |
---|---|
DML | INSERT, UPDATE, DELETE, and REPLACE |
DDL |
|
Permissions required for database accounts
Database | Schema migration and full data migration | Incremental data migration |
---|---|---|
User-created MySQL database | The SELECT permission | The REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, and SELECT permissions |
PolarDB for MySQL cluster | The read/write permissions | The read/write permissions |
For information about how to create and authorize a database account, see the following topics:
- Create an account for a user-created MySQL database and configure binary logging for a user-created MySQL database
- Create a database account for a PolarDB for MySQL cluster