This topic contains important information on necessary precautions. We recommend that you read this topic carefully before proceeding.
Tair (Redis OSS-Compatible) is a database service that is compatible with the open source Redis protocol and supports a hybrid of memory and disks for storage. Based on reliable hot standby architectures and scalable cluster architectures, Tair (Redis OSS-Compatible) is suitable for scenarios that require flexible configuration changes, high throughput, and low latency. This topic describes how to synchronize data from a Twemproxy Redis cluster to an Tair (Redis OSS-Compatible) instance by using Data Transmission Service (DTS).
The available storage capacity of the Tair (Redis OSS-Compatible) instance is larger than the total size of data stored in the Twemproxy Redis cluster.
All master nodes in the Twemproxy Redis cluster support the PSYNC command.
The timeout period for data replication between the master and replica nodes in the source instance is specified by the repl-timeout parameter. By default, this parameter is set to 60 seconds. We recommend that you run the config set repl-timeout 600 command to set this parameter to 600 seconds. If the source instance stores a large amount of data, you can increase the value of the repl-timeout parameter based on your business requirements.
How DTS synchronizes data from a Twemproxy Redis cluster
A Twemproxy Redis cluster consists of multiple Redis servers. DTS synchronizes data of each Redis server in a data synchronization task until the entire cluster is synchronized.
Architecture of the Twemproxy Redis cluster
In this topic, the Twemproxy Redis cluster consists of two Redis servers. Each Redis server runs in a master-replica architecture. The following figure shows the architecture of the cluster.
Precautions
DTS uses the resources of the source and destination instances during initial full data synchronization. This may increase the loads on the database servers. If you synchronize a large volume of data or if the server specifications cannot meet your requirements, database services may become unavailable. Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination instances. We recommend that you synchronize data during off-peak hours.
If the bind parameter is configured in the redis.conf file of the source Redis database, you must set the value of this parameter to the internal IP address of the ECS instance. The setting ensures that DTS can connect to the source database.
To ensure the stability of data synchronization, we recommend that you increase the value of the repl-backlog-size parameter in the redis.conf file of the source Codis cluster.
To ensure the synchronization quality, DTS adds the following key to the source Codis cluster: DTS_REDIS_TIMESTAMP_HEARTBEAT. This key is used to record the time when data is synchronized to Tair (Redis OSS-Compatible).
We recommend that you do not run the FLUSHDB or FLUSHALL command in the source Codis cluster. Otherwise, data may become inconsistent between the source and destination databases.
By default, the maxmemory-policy parameter that specifies how data is evicted is set to volatile-lru for Tair (Redis OSS-compatible) instances. If the destination instance has insufficient memory, data inconsistency may occur between the source and destination instances due to data eviction. In this case, the data synchronization task does not stop running.
To prevent data inconsistency, we recommend that you set maxmemory-policy to noeviction for the destination instance. This way, the data synchronization task fails if the destination instance has insufficient memory, but data loss can be prevented for the destination instance.
If an expiration policy is enabled for specific keys in the source database, these keys may not be deleted at the earliest opportunity after they expire. Therefore, the number of keys in the destination database may be less than that in the source database. You can run the INFO command to view the number of keys in the destination database.
Note
The number of keys that do not have the expiration policy enabled or have not expired is the same between the source and destination databases.
The database version of the destination Tair (Redis OSS-Compatible) instance can be 4.0, 5.0 or 6.0. The version of the destination database must be the same as or later than the version of the source database. If you synchronize data between different versions of Redis databases, make sure that the versions of the source and destination databases are compatible. For example, you can create a pay-as-you-go destination instance to check the compatibility between the source and destination instances. Then, you can release this instance or change the billing method of the instance to subscription.
If the destination instance is deployed in a cluster architecture and the amount of memory used by a shard in the destination instance reaches the upper limit, or if the available storage space of the destination instance is insufficient, the data synchronization task fails due to out of memory (OOM).
If the transparent data encryption (TDE) feature is enabled for the destination instance, you cannot use DTS to synchronize data.
ZADD, ZINCRBY, ZINTERSTORE, ZREM, ZREMRANGEBYLEX, ZUNIONSTORE, ZREMRANGEBYRANK, and ZREMRANGEBYSCORE
Note
PUBLISH operations cannot be synchronized.
If you run the EVAL or EVALSHA command to call Lua scripts, DTS cannot identify whether these Lua scripts are executed on the destination instance. This is because the destination instance does not explicitly return the execution results of Lua scripts during incremental data synchronization.
When DTS runs the SYNC or PSYNC command to transfer data of the LIST type, DTS does not clear the existing data in the destination instance. As a result, the destination instance may contain duplicate data records.
Procedure
Purchase a data synchronization instance. For more information, see Purchase a DTS instance.
Note
On the buy page, select Redis as both the source and destination instance type and One-way Synchronization as the synchronization topology.
If you are redirected to the Data Management (DMS) console, you can click the icon in the to go to the previous version of the DTS console.
In the left-side navigation pane, click Data Synchronization.
In the upper part of the Synchronization Tasks page, select the region in which the destination instance resides.
Find the data synchronization instance and click Configure Task in the Actions column.
Configure the source and destination instances.
Section
Parameter
Description
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 User-Created Database in ECS Instance.
Instance Region
The source region that you selected on the buy page. You cannot change the value of this parameter.
ECS Instance ID
The ID of the Elastic Compute Service (ECS) instance that hosts the master node of the Redis-Server.
Note
DTS synchronizes each Redis server of the Twemproxy Redis cluster by using a data synchronization task until the entire cluster is synchronized. In this step, enter the ECS instance ID for the master node of the Redis server 1. When you configure the data synchronization task for the Redis server 2, enter the ECS instance ID for the master node of the Redis server 2. You can configure data synchronization tasks for all Redis servers by following the procedure described in this topic.
Database Type
The value of this parameter is fixed to Redis.
Instance Mode
Select Standalone.
Note
You must select Standalone for this parameter because data from a Twemproxy Redis cluster cannot be synchronized at a time. DTS synchronizes data of each Redis server of the cluster in a data synchronization task until all Redis servers are synchronized.
Port Number
The service port number of the master node in the Redis-Server.
Database Password
The database password of the master node.
Note
This parameter is optional and can be left empty if no database password is set.
Destination Instance Details
Instance Type
Select Redis Instance.
Instance Region
The destination region that you selected on the buy page. You cannot change the value of this parameter.
Redis Instance ID
The ID of the destination Tair (Redis OSS-Compatible) instance.
Database Password
The database password of the Tair (Redis OSS-Compatible) instance.
Note
The database password is in the <user>:<password> format. For example, if the username of the account that you use to log on to the instance is admin and the password is Rp829dlwa, the database password is admin:Rp829dlwa.
In the lower-right corner of the page, click Set Whitelist and Next.
If the source or destination database is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers to the IP address whitelist of the instance. If the source or destination database is a self-managed database hosted on an Elastic Compute Service (ECS) instance, DTS automatically adds the CIDR blocks of DTS servers to the security group rules of the ECS instance, and you must make sure that the ECS instance can access the database. If the self-managed database is hosted on multiple ECS instances, you must manually add the CIDR blocks of DTS servers to the security group rules of each ECS instance. If the source or destination database is a self-managed database that is deployed in a data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers to the IP address whitelist of the database to allow DTS to access the database. For more information, see Add the CIDR blocks of DTS servers.
Warning
If the CIDR blocks of DTS servers are automatically or manually added to the whitelist of the database or instance, or to the ECS security group rules, security risks may arise. Therefore, before you use DTS to synchronize data, you must understand and acknowledge the potential risks and take preventive measures, including but not limited to the following measures: enhancing the security of your username and password, limiting the ports that are exposed, authenticating API calls, regularly checking the whitelist or ECS security group rules and forbidding unauthorized CIDR blocks, or connecting the database to DTS by using Express Connect, VPN Gateway, or Smart Access Gateway.
Select the processing mode of conflicting tables and the objects to be synchronized.
Setting
Description
Setting
Description
Select the processing mode of conflicting tables
DTS synchronizes each Redis server of the Twemproxy Redis cluster in a data synchronization task until the entire cluster is synchronized. When you configure data synchronization for the Redis server 1, select Pre-check and Intercept if the Tair (Redis OSS-Compatible) instance has no data. When you configure data synchronization for the Redis server 2 to N, select Ignore. Otherwise, errors may occur during data synchronization.
Note
Pre-check and Intercept: checks whether the destination database is empty. If the destination database is empty, the precheck is passed. If the destination database is not empty, an error is returned during the precheck and the data synchronization task cannot be started.
Ignore: skips the precheck for empty destination databases and continues with data synchronization. If the keys in the destination database are the same as those in the source database during data synchronization, the keys in the source database overwrite those in the destination database.
Select the objects to be synchronized
Select one or more databases from the Available section and click to add the databases to the Selected section.
You can select only databases as the objects to be synchronized. You cannot select keys as the objects to be synchronized.
Rename Databases and Tables
The objects that you select to synchronize. In this scenario, you cannot rename the objects.
Replicate Temporary Tables When DMS Performs DDL Operations
If you use DMS to perform online DDL operations on the source database, you can specify whether to synchronize temporary tables generated by online DDL operations.
Yes: DTS synchronizes the data of temporary tables generated by online DDL operations.
Note
If online DDL operations generate a large amount of data, the data synchronization task may be delayed.
No: DTS does not synchronize the data of temporary tables generated by online DDL operations. Only the original DDL data of the source database is synchronized.
Note
If you select No, the tables in the destination database may be locked.
Retry Time for Failed Connections
By default, if DTS fails to connect to the source or destination database, DTS retries within the next 720 minutes (12 hours). You can specify the retry time based on your needs. If DTS reconnects to the source and destination databases within the specified time, DTS resumes the data synchronization task. Otherwise, the data synchronization task fails.
Note
When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time based on your business needs. You can also release the DTS instance at your earliest opportunity after the source and destination instances are released.
In the lower-right corner of the page, click Next.
Configure initial synchronization.
Note
The value is set to Include full data + incremental data. DTS synchronizes historical data from the source Twemproxy Redis cluster to the destination Redis database and then synchronizes incremental data.
In the lower-right corner of the page, click Precheck.
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 details, initiate a new precheck.
If you do not need to troubleshoot the issues, ignore the failed items and initiate a new precheck.
Close the Precheck dialog box after the following message is displayed: Precheck Passed. Then, the data synchronization task starts.
Wait until initial synchronization is complete and the data synchronization task enters the Synchronizing state.
Note
You can view the status of the data synchronization task on the Synchronization Tasks page.
Create and configure a data synchronization task for every other Redis server by repeating Step 1 to 13.
Result
In this topic, the Twemproxy Redis cluster consists of two Redis servers. You must create two data synchronization tasks. The following figure shows that the initial synchronization is complete for both tasks and both tasks are in the Synchronizing state.
In this topic, the database DB0 is synchronized. You can use Data Management (DMS) to log on to the destination Tair (Redis OSS-Compatible) instance and check the total number of keys in the instance. The total number of keys is the same as that in the Twemproxy Redis cluster. For more information about DMS usage, see Log on to an Tair (Redis OSS-Compatible) instance by using DMS.