This topic describes how to migrate data from an ApsaraDB RDS for MySQL instance to a self-managed MySQL database by using Data Transmission Service (DTS). This applies to scenarios such as data analysis and functional tests.
Prerequisites
- The tables to be migrated from the ApsaraDB RDS for MySQL instance contain primary keys or UNIQUE NOT NULL indexes.
- The available storage space of the self-managed MySQL database is larger than the total size of the data in the ApsaraDB RDS for MySQL instance.
- The version of the self-managed MySQL database is the same as that of the ApsaraDB RDS for MySQL instance. This ensures compatibility.
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.
- During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the size of used tablespace of the destination database is larger than that of the source database.
- If a data migration task fails, DTS automatically resumes the task. Therefore, before you switch your workloads to the destination database, stop or release the data migration task. Otherwise, the data in the source database overwrites the data in the destination database after the task is resumed.
Limits
- DTS supports the following types of objects for schema migration: table, view, trigger,
stored procedure, and function.
Note During schema migration, DTS changes the value of the SECURITY attribute from
DEFINER
toINVOKER
for views, stored procedures, and functions. - DTS does not migrate user information from the source database. After data migration is complete, if you want to call a view, stored procedure, or function of the destination database, you must grant the read and write permissions to INVOKER.
Migration types
DTS supports schema migration, full data migration, and incremental data migration.
For more information, see Terms.
Note When you migrate data between PolarDB for MySQL clusters, you can select all of the
supported migration types to ensure service continuity.
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 Billing overview. |
Incremental data migration | Charged. For more information, see Billing overview. |
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 | Required permission |
---|---|
ApsaraDB RDS for MySQL instance | Read permissions on the objects to migrate |
Self-managed MySQL database | Read and write permissions on the objects to migrate |
For more information about how to create and authorize a database account, see the following topics:
- ApsaraDB RDS for MySQL: Create an account on an ApsaraDB RDS for MySQL instance and Modify the permissions of a standard account on an ApsaraDB RDS for MySQL instance
- Self-managed MySQL database: Create an account for a user-created MySQL database and configure binary logging
Procedure