This document describes how to use the data migration feature of DTS to migrate data from a self-built database to a TencentDB database through CCN.
CCN can interconnect a VPC with another VPC or a local IDC. To use CCN access, you must establish cross-VPC and VPC-IDC interconnections through CCN in advance.
In this scenario, you have used CCN to interconnect the three networks of VPC-Guangzhou, VPC-Chengdu, and VPC-Shanghai, have a self-built database in Guangzhou, and plan to migrate the data in the source database in Guangzhou to the target database in Nanjing. VPC-Chengdu is selected as the Accessed VPC.
When selecting CCN access, you need to connect the source database to the source of the DTS migration/sync linkage over CCN as follows: source database > accessed VPC > source of the migration/sync linkage, as shown in orange below.
The accessed VPC and the source of the migration/sync linkage are interconnected as follows in the entire DTS task:
The source of the migration/sync linkage is the network in the region of the source database selected during the task purchase, as shown below:
The region of the source database selected during task purchase must be the same as the region of the accessed VPC; otherwise, the networks cannot be interconnected, and DTS will change the former to the latter.
Accessed VPC: The accessed VPC refers to the VPC in CCN over which the migration/sync linkage is connected. It can be configured when you set the source and target databases as shown below:
The accessed VPC and the VPC of the source database are interconnected over CCN.
You have created a TencentDB for MySQL instance as instructed in Creating MySQL Instance.
The source and target databases must meet the requirements for the migration feature and version as instructed in Databases Supported by Data Migration.
You have completed all preparations as instructed in Overview.
The source database must have the following permissions:
Migration of the entire instance:
CREATE USER 'migration account'@'%' IDENTIFIED BY 'migration password'; GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT,REPLICATION SLAVE,SHOW DATABASES,SHOW VIEW,PROCESS ON *.* TO 'migration account'@'%'; GRANT ALL PRIVILEGES ON `__tencentdb__`.* TO 'migration account'@'%'; GRANT SELECT ON *.* TO 'migration account';
Migration of specified objects:
CREATE USER 'migration account'@'%' IDENTIFIED BY 'migration password'; GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT,REPLICATION SLAVE,SHOW DATABASES,SHOW VIEW,PROCESS ON *.* TO 'migration account'@'%'; GRANT ALL PRIVILEGES ON `__tencentdb__`.* TO 'migration account'@'%'; GRANT SELECT ON `mysql`.* TO 'migration account'@'%'; GRANT SELECT ON database to be migrated.* TO 'migration account';
Permissions required of the target database: ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE USER, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, SELECT, SHOW DATABASES, SHOW VIEW, TRIGGER, and UPDATE.
[DEFINER = user1]) in the source database is the same as the migration account
user2, and if not, DTS will change the
SQL SECURITYattribute of
user1in the target database from
[INVOKER = user1]) after the migration, and set the
DEFINERin the target database to the migration account
[DEFINER = migration account user2]). If the view definition in the source database is too complex, the task may fail.
STATEMENTformat, the migration will fail.
STATEMENTformat into the source database.
__tencentdb__during incremental migration.
|Operation Type||Supported SQL Operations|
|DML||INSERT, UPDATE, DELETE, and REPLACE|
|DDL||TABLE: CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE, and RENAME TABLE
VIEW: CREATE VIEW and DROP VIEW
INDEX: CREATE INDEX and DROP INDEX
DATABASE: CREATE DATABASE, ALTER DATABASE, and DROP DATABASE
The system will automatically check the following environment requirements before starting a migration task and report an error if a requirement is not met. If you can identify the failed check item, fix it as instructed in Database Connection Check; otherwise, wait for the system verification to complete and fix the problem according to the error message.
|Requirements for source database||
|Requirements for the target database||
|Other requirements||The environment variable `innodb_stats_on_metadata` must be set to `OFF`.|
Establish interconnections as instructed in Connecting Network Instances Under the Same Account.
CCN only provides bandwidth below 10 Kbps between all regions free of charge. However, DTS requires a higher bandwidth. Therefore, bandwidth configuration in the link is required.
Log in to the DTS console, select Data Migration on the left sidebar, and click Create Migration Task to enter the Create Migration Task page.
On the Create Migration Task page, select the types, regions, and specifications of the source and target instances and click Buy Now.
|Source Instance Type||Select the source database type, which cannot be changed after purchase. Here, select MySQL.|
|Source Instance Region||Select the source database region. If the source database is a self-built one, select a region nearest to it.|
|Target Instance Type||Select the target database type, which cannot be changed after purchase. Here, select MySQL.|
|Target Instance Region||Select the target database region.|
|Specification||Select the specification of the migration linkage based on your business conditions.|
On the Set source and target databases page, configure the task, source database, and target database settings. After the source and target databases pass the connectivity test, click Create.
If the connectivity test fails, troubleshoot and fix the problem as prompted and as instructed in Database Connection Check and try again.
|Setting Type||Configuration Item||Description|
|Task Configuration||Task Name||Set a meaningful name for easy task identification.|
|Running Mode||Immediate execution: The task will be started immediately after the task verification is passed. Scheduled execution: You need to configure a task execution time and the task will be started automatically then.|
|Tag||Tags are used to manage resources by category in different dimensions. If the existing tags do not meet your requirements, go to the console to create more.|
|Source Database Settings||Source Database Type||The source database type selected during purchase, which cannot be changed.|
|Service Provider||Select Others.|
|Region||The source database region selected during purchase, which cannot be changed.|
|Access Type||Select CCN. For more information on access types, see Overview.|
|Host Address||IP address or domain name for accessing the source MySQL database.|
|Port||Port for accessing the source MySQL database.|
|Account||Account of the source MySQL database, which must have the required permissions.|
|Password||Password of the source MySQL database.|
|VPC-based CCN Instance||Only VPC-based CCN instance is supported. You need to confirm the network type associated with CCN.|
|Accessed VPC||The accessed VPC refers to the VPC in CCN over which the migration/sync linkage is connected. You need to select a CCN-associated VPC other than the VPC where the source database resides. |
To ensure the network connectivity, you must check whether the following key requirements are met:
|Subnet||Name of the subnet of the selected VPC.|
If you cannot pull the subnet, there may be a problem with your account. The account of the accessed VPC must be the same as the migration account.
For example, to migrate a database under account A to account B, you should use account B to create a task. Therefore, the accessed VPC must be under account B.
|Region of Accessed VPC||The region of the source database selected during task purchase must be the same as the region of the accessed VPC; otherwise, DTS will change the former to the latter.|
|Target Database Settings||Target Database Type||The target database type selected during purchase, which cannot be changed.|
|Region||The target database region selected during purchase, which cannot be changed.|
|Access Type||Select Database.|
|Database Instance||Select the instance ID of the target TencentDB database.|
|Account||The account of the target TencentDB database, which needs to have required permissions.|
|Password||Password of the target TencentDB database.|
On the Set migration options and select migration objects page, configure the migration type and objects and click Save.
|Migration Type||Select a type based on your scenario.|
|Specified objects||Select the objects to be migrated in Source Database Object and move them to the Selected Object box.|
On the task verification page, verify the task. After the verification is passed, click Start Task.
If the verification failed, fix the problem as instructed in Database Connection Check and initiate the verification task again.
After the migration task status becomes Task successful, you can formally cut over the business. For more information, see Cutover Description.