Tablestore is a multi-model data storage service that is developed by Alibaba Cloud. Tablestore can store large volumes of structured data by using multiple models, and supports fast data query and analytics. This topic describes how to synchronize data from an ApsaraDB RDS for MySQL instance to a Tablestore instance by using Data Transmission Service (DTS). You can also follow the procedure to synchronize data from a self-managed MySQL database to a Tablestore instance. The data synchronization feature allows you to transfer and analyze data with ease.
Prerequisites
A Tablestore instance is created. For more information, see Create instances.Precautions
- During initial full data synchronization, DTS consumes the read and write resources of the source and destination databases. 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 selected objects, remove the table from the Tablestore instance, and then add the table to the selected objects again. For more information see Remove an object from a data synchronization task and Add an object to a data synchronization task.
- You can synchronize up to 64 tables to the Tablestore instance. If you want to synchronize more than 64 tables to the Tablestore instance, you can disable the limit for the destination Tablestore instance.
- The names of the tables and columns to be synchronized must comply with the naming conventions of the Tablestore instance.
- The name of a table or an index can contain letters, digits, and underscores (_). The name must start with a letter or underscore (_).
- The name of a table or an index must be 1 to 255 characters in length.
Billing
Synchronization type | Task configuration fee |
---|---|
Schema synchronization and full data synchronization | Free of charge. |
Incremental data synchronization | Charged. For more information, see Billing overview. |
Initial synchronization types
Initial synchronization type | Description |
---|---|
Initial schema synchronization | DTS synchronizes the schemas of tables from the source database to the destination database. 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 We recommend that you do not execute DDL statements in the source database. Otherwise, data synchronization may fail. |
Before you begin
Important When you configure the destination database, you must specify the AccessKey pair. To protect the AccessKey pair of your Alibaba Cloud account, we recommend that you grant permissions to a RAM user and create an AccessKey pair for the RAM user.
- Create a RAM user and grant the AliyunOTSFullAccess permission on Tablestore to the RAM user.
- 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 to access Alibaba Cloud resources. Note If you use an Alibaba Cloud account to configure a data synchronization task, skip this step.
Procedure
- Purchase a data synchronization instance. For more information, see Purchase a DTS instance. Note On the buy page, set Source Instance to MySQL, set Destination Instance to Tablestore, and set Synchronization Topology to One-way Synchronization.
- Log on to the DTS console.
- In the left-side navigation pane, click Data Synchronization.
- In the upper part of the Synchronization Tasks page, select the region where the destination instance resides.
- Find the data synchronization instance and click Configure Task in the Actions column.
- Configure the source and destination databases.
Section Parameter Description N/A Synchronization Task Name The task name that DTS automatically generates. We recommend that you specify a descriptive name that makes it easy to identify the task. 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. The value of this parameter cannot be changed. Instance ID The ID of the source ApsaraDB RDS for MySQL instance. Database Account The database account of the source ApsaraDB RDS instance. The account must have the SELECT permission on the objects to be synchronized and the REPLICATION CLIENT, REPLICATION SLAVE permission, and SHOW VIEW permissions. Note If the database engine of the source ApsaraDB RDS instance is MySQL 5.5 or MySQL 5.6, you do not need to configure the Database Account or Database Password parameter.Database Password The password of the database account. Encryption Select Non-encrypted or SSL-encrypted. If you want to select SSL-encrypted, you must enable SSL encryption for the ApsaraDB RDS instance before you configure the data synchronization task. For more information, see Configure SSL encryption for an ApsaraDB RDS for MySQL instance. Important The Encryption parameter is available only within 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. The value of this parameter cannot be changed. Instance ID The ID of the destination Tablestore instance. AccessKeyId The AccessKey ID. For more information, see Create an AccessKey pair. AccessKeySecrect The AccessKey secret. - In the lower-right corner of the page, click Set Whitelist and Next. Note
- You do not need to modify the security settings for ApsaraDB instances (such as ApsaraDB RDS for MySQL and ApsaraDB for MongoDB) and ECS-hosted databases. DTS automatically adds the CIDR blocks of DTS servers to the whitelists of ApsaraDB instances or the security group rules of Elastic Compute Service (ECS) instances. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
- After data synchronization is complete, we recommend that you remove the CIDR blocks of DTS servers from the whitelists or security groups.
- Configure the synchronization policy and the objects to be synchronized.
- 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 instance.
- Configure the primary key columns of the tables that you want to synchronize to the Tablestore instance. Note For more information about primary keys of Tablestore instances, see Primary keys.
- In the lower-right corner of the page, click Next: Precheck and Start Task. Note
- Before you can start the data synchronization task, DTS performs a precheck. You can start the data synchronization task only after the task passes the precheck.
- If the task fails to pass the precheck, you can click the icon next to each failed item to view details. After you troubleshoot the issues based on the causes, you can run a precheck again.
- Close the Precheck dialog box after the following message is displayed: The precheck is passed. Then, the data synchronization task starts.
- Wait until initial synchronization is complete and the data synchronization task enters the Synchronizing state. You can view the state of the data synchronization task on the Synchronization Tasks page.