Tablestore is a multi-model data storage service that is developed by Alibaba Cloud. It can store a large amount of structured data and supports fast query and analysis. This topic describes how to synchronize data from a user-created MySQL database or an ApsaraDB RDS for MySQL instance to a Tablestore instance by using Data Transmission Service (DTS).
- DTS uses the read and write resources of the source and destination databases during initial full data synchronization. This may increase the loads of the database servers. Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours.
- DTS does not synchronize data definition language (DDL) operations. If a DDL operation is performed on a table in the source database during data synchronization, you must perform the following steps: Remove the table from the required objects, remove the table from the Tablestore instance, and then add the table to the required objects. For more information see Remove an object from a data synchronization task and Add an object to a data synchronization task.
- You can synchronize at most 64 tables to the Tablestore instance. If you need to synchronize more than 64 tables to the Tablestore instance, submit a ticket to remove the limit.
- The names of the tables or columns to be synchronized must comply with the naming
conventions of the Tablestore instance.
- The name of a table or index can contain letters, digits, and underscores (_). The name must start with a letter or underscore (_).
- The name of a table or index must be 1 to 255 characters in length.
Initial synchronization types
|Initial synchronization type||Description|
|Initial schema synchronization||DTS synchronizes the schemas of tables from the source database to the destination
Warning MySQL and Tablestore are heterogeneous databases. DTS does not ensure that the schemas of the source and destination databases are consistent after initial schema synchronization. We recommend that you evaluate the impact of data type conversion on your business. For more information, see Data type mappings for schema synchronization.
|Initial full data synchronization||DTS synchronizes historical data of tables from the source database to the destination database. Historical data is the basis for subsequent incremental data synchronization.|
|Initial incremental data synchronization||DTS synchronizes incremental data from the source database to the destination database
in real time.
The following SQL operations can be synchronized during initial incremental data synchronization: INSERT, UPDATE, and DELETE.
Warning Do not execute DDL statements in the source database. Otherwise, data synchronization may fail.
Before you begin
- Create a RAM user and grant the AliyunOTSFullAccess permission on Tablestore to the
- Log on to the RAM console.
- Create a RAM user.
- In the left-side navigation pane, choose Identities > Users.
- On the Users page, find the RAM user, and click Add Permissions in the Actions column.
- In the dialog box that appears, enter AliyunOTSFullAccess in the search box, and click the policy name to add the policy to the Selected section.
- Click OK.
- Click Finished.
- Create an AccessKey pair for the RAM user. For more information, see Create an AccessKey pair.
- Optional:If you need to configure a data synchronization task as a RAM user, you must grant
the AliyunDTSDefaultRole permission to the RAM user. For more information, see Authorize DTS as a RAM user.Note If you use an Alibaba Cloud account to configure a data synchronization task, skip this step.
- Purchase a data synchronization instance. For more information, see Purchase a DTS instance.Note On the buy page, set Source Instance to MySQL, set Target Instance to Tablestore, and set Synchronization Topology to One-Way Synchronization.
- Configure the source and destination databases.
Section Parameter Description N/A Synchronization Task Name DTS automatically generates a task name. We recommend that you specify an informative name for easy identification. You do not need to use a unique task name. Source Instance Details Instance Type Select RDS Instance. Instance Region The source region that you selected on the buy page. You cannot change the value of this parameter. Instance ID Select the ID of the source RDS instance. Database Account Enter the database account of the source RDS instance. The account must have the SELECT permission on the required objects, the REPLICATION CLIENT permission, the REPLICATION SLAVE permission, and the SHOW VIEW permission.Note If the database engine of the source RDS instance is MySQL 5.5 or MySQL 5.6, you do not need to configure the database account or database password. Database Password Enter the password of the source database account. Encryption Select Non-encrypted or SSL-encrypted. If you want to select SSL-encrypted, you must enable SSL encryption for the RDS instance before you configure the data synchronization task. For more information, see Configure SSL encryption on an ApsaraDB RDS for MySQL instance.Notice The Encryption parameter is available only for regions in the Chinese mainland and the China (Hong Kong) region. Destination Instance Details Instance Type Select Tablestore. Instance Region The destination region that you selected on the buy page. You cannot change the value of this parameter. Instance ID Select the ID of the destination Tablestore instance. AccessKeyId Enter the AccessKey ID. For more information, see Create an AccessKey pair. AccessKeySecrect Enter the AccessKey secret.
- In the lower-right corner of the page, click Set Whitelist and Next.In this step, DTS adds the CIDR blocks of DTS servers to the whitelists of the source and destination instances. This ensures that DTS servers can connect to the source and destination instances.
- Configure the synchronization policy and the objects to be synchronized.
- Configure the synchronization policy.
Parameter Description Initial Synchronization Select Initial Schema Synchronization, Initial Full Data Synchronization, and Initial Incremental Data Synchronization. For more information, see Initial synchronization types. Processing Mode In Existed Target Table Merge Multi Tables
- Yes: In OLTP scenarios, sharding is implemented to speed up the response to business
tables. You can merge multiple source tables that have the same schema into a single
destination table. This feature allows you to synchronize data from multiple tables
in the source database to a single table in the Tablestore instance.
- DTS adds a column named
__dts_data_sourceto the destination table in the Tablestore instance. This column is used to record the data source. The data type of this column is varchar. DTS specifies the column values based on the following format:
<Data synchronization instance ID>:<Source database name>.<Source table name>. Such column values allow DTS to identify each source table. For example,
dts********:dtstestdata.customer1indicates that the source table is customer1.
- If you set this parameter to Yes, all of the selected source tables in the task are merged into the destination table. If you do not need to merge specific source tables, you can create a separate data synchronization task for these tables.
- DTS adds a column named
- No is selected by default.
Synchronization Type Select the types of operations that you want to synchronize based on your business requirements. All operation types are selected by default.
- Yes: In OLTP scenarios, sharding is implemented to speed up the response to business tables. You can merge multiple source tables that have the same schema into a single destination table. This feature allows you to synchronize data from multiple tables in the source database to a single table in the Tablestore instance.
- Select the objects to be synchronized.
Setting Description Select the objects to be synchronized Select one or more tables from the Available section and click the icon to move the tables to the Selected section. Up to 64 tables can be migrated.
After an object is synchronized to the destination instance, the name of the object remains unchanged. You can use the object name mapping feature to change the names of the objects that are synchronized to the destination instance. For more information, see Rename an object to be synchronized.Warning If you set Merge Multi Tables to Yes in Step 8 and select multiple source tables, you must use the object name mapping feature to change their names to the same table name in the Tablestore instance. Otherwise, data is inconsistent.
- Click Next.
- Configure the synchronization policy.
- Optional:In the Selected section, move the pointer over a table, and then click Edit. In the Edit Table dialog box, set the data type of each column in the Tablestore
- Configure the primary key columns of the tables that you want to synchronize to the Tablestore instance.