This document describes how to use the data sync feature of DTS to sync data from MySQL/MariaDB/Percona to TencentDB for MySQL.
The following deployment modes of the source database are supported:
This document describes how to sync data from MySQL to TencentDB for MySQL. The requirements and steps of data sync from MariaDB and Percona to TencentDB for MySQL are basically the same.
__tencentdb__
in the source database to record the data comparison information during the sync task.__tencentdb__
system database in the source database will not be deleted after the sync task ends.__tencentdb__
system database uses a single-threaded connection wait mechanism and occupies a very small space, about 0.01%–0.1% of the storage space of the source database; for example, if the source database is 50 GB, __tencentdb__
will be about 5–50 MB. Therefore, it has almost no impact on the performance of the source database and will not preempt resources. The source and target databases must meet the requirements for the sync feature and version as instructed in Databases Supported by Data Sync.
Permissions required of the source database:
GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT,REPLICATION SLAVE,SHOW VIEW,PROCESS,SELECT ON *.* TO 'account'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `__tencentdb__`.* TO 'account'@'%';
FLUSH PRIVILEGES;
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.
user1
corresponding to DEFINER
([DEFINER = user1]
) in the source database is the same as the sync account user2
, and if not, DTS will change the SQL SECURITY
attribute of user1
in the target database from DEFINER
to INVOKER
([INVOKER = user1]
) after the sync, and set the DEFINER
in the target database to the sync account user2
([DEFINER = sync account user2]
). If the view definition in the source database is too complex, the task may fail.STATEMENT
format, sync will fail.ALTER VIEW
statement is not supported and will be skipped during sync.During the sync, do not perform the following operations; otherwise, the sync task will fail:
STATEMENT
format into the source database.__tencentdb__
during incremental sync. Operation Type | SQL Statements |
---|---|
DML | INSERT, UPDATE, and DELETE |
DDL | CREATE DATABASE, DROP DATABASE, ALTER DATABASE, CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE, RENAME TABLE, CREATE VIEW, DROP VIEW, CREATE INDEX, and DROP INDEX
|
Type | Environment Requirement |
---|---|
Requirements for source database |
|
Requirements for the target database |
|
Other requirements | The environment variable `innodb_stats_on_metadata` must be set to `OFF`. |
Parameter | Description |
---|---|
Billing Mode | Monthly subscription and pay-as-you-go billing are supported. |
Source Instance Type | Select MySQL, which cannot be changed once configured. |
Source Instance Region | Select the source instance region, which cannot be changed once configured. |
Target Instance Type | Select MySQL, which cannot be changed once configured. |
Target Instance Region | Select the target instance region, which cannot be changed once configured. |
Specification | Select a specification based on your business needs. The higher the specification, the higher the performance. |
Category | Parameter | Description |
---|---|---|
Task Configuration | Task Name | DTS will automatically generate a task name, which is customizable. |
Running Mode | Immediate execution and scheduled execution are supported. | |
Source Instance Settings | Source Instance Type | Select the source instance type selected during purchase, which cannot be changed once configured. |
Source Instance Region | Select the source instance region selected during purchase, which cannot be changed once configured. | |
Service Provider | For a self-built database (such as a CVM-based one) or TencentDB database, select Others. For a third-party cloud database, select the corresponding service provider. In this scenario, select Others. | |
Access Type | Select a type based on your scenario. In this scenario, select Direct Connect or VPN Access, and you need to configure VPN-IDC interconnection as instructed in Direct Connect or VPN Access: Configuring VPN-IDC Interconnection. For the preparations for different access types, see Overview.
| |
VPC-based Direct Connect Gateway/VPN Gateway | Only VPC-based Direct Connect gateway is supported. You need to confirm the network type associated with the gateway. VPN Gateway: Select a VPN Gateway instance. | |
VPC | Select a VPC and subnet associated with the VPC-based Direct Connect Gateway or VPN Gateway. | |
Host Address | IP address or domain name for accessing the source MySQL instance. | |
Port | Port for accessing the source MySQL instance. | |
Account | Account of the source instance, which must have the required permissions. | |
Password | Password of the source instance account. | |
Target Instance Settings | Target Instance Type | The target instance type selected during purchase, which cannot be changed. |
Target Instance Region | The target instance region selected during purchase, which cannot be changed. | |
Access Type | Select a type based on your scenario. In this scenario, select Database. | |
Instance ID | Target instance ID. | |
Account | Account of the target instance, which must have the required permissions. | |
Password | Password of the target instance account. |
Category | Parameter | Description |
---|---|---|
Task Configuration | Task Name | DTS will automatically generate a task name, which is customizable. |
Running Mode | Immediate execution and scheduled execution are supported. | |
Source Instance Settings | Source Instance Type | Select the source instance type selected during purchase, which cannot be changed once configured. |
Source Instance Region | Select the source instance region selected during purchase, which cannot be changed once configured. | |
Service Provider | For a self-built database (such as a CVM-based one) or TencentDB database, select Others. For a third-party cloud database, select the corresponding service provider. In this scenario, select Others. | |
Access Type | Select a type based on your scenario. In this scenario, select Database. For the preparations for different access types, see Overview.
| |
Instance ID | Source instance ID. You can view the source instance information in the instance list. | |
Account | Account of the source instance, which must have the required permissions. | |
Password | Password of the source instance account. | |
Target Instance Settings | Target Instance Type | The target instance type selected during purchase, which cannot be changed. |
Target Instance Region | The target instance region selected during purchase, which cannot be changed. | |
Access Type | Select a type based on your scenario. In this scenario, select Database. | |
Instance ID | Target instance ID. | |
Account | Account of the target instance, which must have the required permissions. | |
Password | Password of the target instance account. |
Category | Parameter | Description |
---|---|---|
Task Configuration | Task Name | DTS will automatically generate a task name, which is customizable. |
Running Mode | Immediate execution and scheduled execution are supported. | |
Source Instance Settings | Source Instance Type | Select the source instance type selected during purchase, which cannot be changed once configured. |
Source Instance Region | Select the source instance region selected during purchase, which cannot be changed once configured. | |
Service Provider | For a self-built database (such as a CVM-based one) or TencentDB database, select Others. For a third-party cloud database, select the corresponding service provider. In this scenario, select Alibaba Cloud. | |
Access Type | For a third-party cloud database, you can select ublic Network generally or select VPN Access, Direct Connect, or CCN based on your actual network conditions. In this scenario, select Public Network. For the preparations for different access types, see Overview.
| |
Host Address | IP address or domain name for accessing the source instance. | |
Port | Source instance port. | |
Account | Account of the source instance, which must have the required permissions. | |
Password | Password of the source instance account. | |
Target Instance Settings | Target Instance Type | The target instance type selected during purchase, which cannot be changed. |
Target Instance Region | The target instance region selected during purchase, which cannot be changed. | |
Access Type | Select a type based on your scenario. In this scenario, select Database. | |
Instance ID | Target instance ID. | |
Account | Account of the target instance, which must have the required permissions. | |
Password | Password of the target instance account. |
Note:
- If you only select Full data initialization for Initialization Type, the system will assume by default that you have created the table structures in the target database and will neither sync table structures nor check whether the source and target databases have tables with the same name. Therefore, if you select Precheck and report error for If Target Already Exists, the precheck and error reporting feature won't take effect.
- If you select Full data initialization only, you need to create the table structures in the target database in advance.
- If you want to rename a table (for example, rename table A table B) during sync, you must select the entire database (or entire instance) where table A resides rather than only table A as the sync object; otherwise, the system will report an error.
Category | Parameter | Description |
---|---|---|
Data Initialization Option | Initialization Type |
|
If Target Already Exists |
| |
Data Sync Option | Conflict Resolution Method |
|
SQL Type | Supported operations include INSERT, UPDATE, DELETE, and DDL. If you select Custom DDL, you can select different DDL statement sync policies as needed. For more information, see Setting SQL Filter Policy. | |
Sync Object Option | Database and Table Objects of Source Instance | Select the objects to be synced. You can select basic databases, tables, views, procedures, and functions. The sync of advanced objects is a one-time operation: only advanced objects already in the source database before the task start can be synced, while those added to the source database after the task start will not be synced to the target database. For more information, see Syncing Advanced Object. |
Selected Object |
|
Note:You can click More > Stop in the Operation column to stop a sync task. You need to ensure that data sync has been completed before stopping the task.
Was this page helpful?