Data Transmission Service (DTS) supports two-way data synchronization between Tair (Enterprise Edition) instances, enabling active geo-redundancy and disaster recovery architectures.
To configure two-way synchronization using OpenAPI instead of the console, see Call an OpenAPI operation to configure one-way or two-way data synchronization between Tair Enterprise Edition instances.
How it works
Two-way synchronization requires two DTS tasks configured in sequence:
Forward synchronization task: runs full migration followed by incremental synchronization.
Remote sync task: runs incremental synchronization only.
Full migration copies all historical data from source to destination and is free of charge. Incremental synchronization then replicates changes in real time, billed by duration rather than data volume. For pricing details, see Billable items.
Do not write to the same key in both instances simultaneously while the tasks are running. Concurrent writes to the same key cause data inconsistency.
Prerequisites
Before you begin, make sure that:
Both the source and destination instances are Tair (Enterprise Edition) instances
Neither instance is a disk-based Tair (Enterprise Edition) instance (disk-based instances do not support two-way synchronization)
If the source is a Tair persistent memory-optimized instance, the
appendonlyparameter is manually enabled on that instance
Usage notes
Task stability
Do not scale, change the specifications, or change the endpoint of either instance while a synchronization task is running. If you do, the task fails and must be reconfigured. Schedule migrations during off-peak hours to minimize resource impact on your instances.
If a two-way synchronization task is paused for more than 5 seconds, all data must be re-synchronized.
If an instance is located outside China, two-way synchronization is supported only between instances in the same region — cross-region two-way synchronization is not supported. For example, two instances in Japan (Tokyo) can be synchronized bidirectionally, but an instance in Japan (Tokyo) cannot be synchronized bidirectionally with an instance in Germany (Frankfurt).
Data scope
When an object is included in both the forward and the reverse synchronization task, the following rules apply:
Only one task can synchronize both full data and incremental data for that object. The other task synchronizes only incremental data.
Data synchronized by one task is not used as a source for the other task, which prevents infinite loops.
Memory and eviction
The default maxmemory-policy for Tair (Redis OSS-compatible) instances is volatile-lru. If the destination instance runs out of memory under this policy, data is silently evicted and the task continues running, leaving the two instances inconsistent.
Set maxmemory-policy to noeviction on the destination instance. With noeviction, the task fails immediately when memory is exhausted rather than evicting data, so you can address the issue before data is lost. For more information, see What is the default eviction policy?
Network interruptions
If the network is interrupted during full migration, DTS may perform multiple full migrations after reconnecting. DTS overwrites any existing keys with the same name in the destination. Delete operations performed during the interruption are not replicated, so the destination may temporarily contain more keys than the source.
Configure two-way synchronization
The overall process consists of these steps:
Create the forward synchronization task (full migration + incremental synchronization)
Wait for the forward task to reach Running status
Create the remote sync task (incremental synchronization only)
Confirm both tasks are in Running status
Step 1: Go to the Data Synchronization Tasks page
Log on to the Data Management (DMS) console.
In the top navigation bar, click Data + AI.
In the left-side navigation pane, choose DTS > Data Synchronization.
Step 2: Create the forward synchronization task
Click Create Task.
Configure the source and destination databases, then click Test Connection And Proceed.
Category Parameter Description N/A Task Name A name for the DTS task. DTS generates a default name. Specify a descriptive name for easy identification — it does not need to be unique. Source Database Select DMS Database Instance If the source database is already added to DMS, select it here to skip manual entry. Database Type Select Tair/Redis. Connection Type Select Alibaba Cloud Instance. Instance Region Select the region where the source instance is located. Cross-account Data Synchronization For same-account migrations, select No. Instance ID Select the source instance ID. Authentication Method Select Password Login or Password-free Login. Select Password Login if password-free access is not enabled for the instance. Database Password Enter the password for the source instance. If you use a custom account, the format is <user>:<password>— for example,admin:Rp829dlwa. The account must have read permission. Leave blank if no password is set.Destination Database Select DMS Database Instance If the destination database is already added to DMS, select it here to skip manual entry. Database Type Tair/Redis is selected by default. Connection Type Select Alibaba Cloud Instance. Instance Region Select the region where the destination instance is located. Instance ID Select the destination instance ID. Authentication Method Select Password Login or Password-free Login. Select Password Login if password-free access is not enabled for the instance. Database Password Enter the password for the destination instance. If you use a custom account, the format is <user>:<password>— for example,admin:Rp829dlwa. The account must have write permission.Configure the synchronization objects, then click Next: Advanced Configuration.
Parameter Description Synchronization Type Select Full Synchronization if needed. Incremental Synchronization is always selected and cannot be cleared. Synchronization Topology Select Two-way Synchronization. Processing Mode for Existing Destination Tables Precheck And Report Errors (default): the precheck verifies whether keys already exist in the destination. If they do, an error is reported and the task does not start. Ignore Errors And Proceed: skips the existence check. If a key with the same name already exists in the destination, it is overwritten. Source Objects and Selected Objects In Source Objects, select the databases or keys to synchronize, then click
to move them to Selected Objects. To remove an object, select it in Selected Objects and click
. Objects can be selected at the database level (DB 0 to DB 255).Configure advanced settings, then click Next: Data Validation. In most cases, the default settings are sufficient. For details, see Appendix: Advanced settings.
Configure data verification, then click Next: Save Task Settings and Precheck. In most cases, the default settings are sufficient. For details, see Configure data verification.
Run the precheck, then click Next: Purchase Instance. If any Warning or Failed items appear, click View Details to troubleshoot. To skip a check item, click Confirm Alert Details — note that skipping checks may lead to data inconsistency. For common precheck issues, see the DTS FAQ. After resolving issues, run the precheck again.
On the buy page, configure the instance parameters, then click Buy and Start. After purchase, the forward synchronization task starts. Monitor its progress on the Data Synchronization page.
(Optional) Select the resource group for the DTS instance. The default is default resource group.
(Optional) Select the instance specifications. Higher specifications provide faster synchronization at higher cost. The default is large. For details, see Specifications of data synchronization instances.
Read and accept the terms of service.
Step 3: Create the remote sync task
Wait for the Status of the forward synchronization task to change to Running, then click Configure Task for the remote sync task listed below it.
Follow the same configuration steps as the forward task.
Once the Precheck Pass Rate reaches 100%, click Return To List.
Verify the configuration
In the data synchronization task list, confirm that the Running Status of both the forward and the remote sync tasks is Running. Two-way synchronization is active when both tasks are running.
FAQ
Why does the connectivity test fail?
Check two common causes: an invalid password format and a firewall blocking DTS. The password must use the format user:password — see Connect to an instance. If the source database is in an on-premises data center or a third-party cloud, add the CIDR blocks of DTS servers in the corresponding region to the database's firewall allowlist. See Add the CIDR blocks of DTS servers.
Why does the synchronization task fail to run?
The most common causes are instance changes and memory issues:
If you scale or change the specifications or endpoint of either instance during the task, the task fails. Reconfigure the task after making the changes.
If the destination instance lacks available memory, or a specific shard in a cluster instance has reached its memory limit, the task fails with an out of memory (OOM) error.
If transparent data encryption (TDE) is enabled on the destination instance, DTS cannot migrate data to it.
Why are the key counts different between source and destination?
Several scenarios can cause key count differences:
Keys with an expiration policy may expire at slightly different times in each instance, temporarily causing the destination to have fewer keys.
When transmitting list data using
PSYNCorSYNC, DTS does not flush existing data in the destination, which may result in duplicate entries.If the network is interrupted during full migration, DTS may perform multiple full migrations after reconnecting and overwrites matching keys. Delete operations during the interruption are not replicated, leaving extra keys in the destination.
Why does the `CROSSSLOT Keys in request don't hash to the same slot` error occur?
If the destination instance uses a cluster architecture, Redis does not support cross-slot operations in a single command. Operate on only one key at a time during DTS synchronization to avoid interrupting the sync link.
Which commands are synchronized?
The following commands are synchronized:
APPENDBITOP,BLPOP,BRPOP,BRPOPLPUSHDECR,DECRBY,DELEVAL,EVALSHA,EXEC,EXPIRE,EXPIREATGEOADD,GETSETHDEL,HINCRBY,HINCRBYFLOAT,HMSET,HSET,HSETNXINCR,INCRBY,INCRBYFLOATLINSERT,LPOP,LPUSH,LPUSHX,LREM,LSET,LTRIMMOVE,MSET,MSETNX,MULTIPERSIST,PEXPIRE,PEXPIREAT,PFADD,PFMERGE,PSETEXRENAME,RENAMENX,RESTORE,RPOP,RPOPLPUSH,RPUSH,RPUSHXSADD,SDIFFSTORE,SELECT,SET,SETBIT,SETEX,SETNX,SETRANGE,SINTERSTORE,SMOVE,SPOP,SREM,SUNIONSTOREZADD,ZINCRBY,ZINTERSTORE,ZREM,ZREMRANGEBYLEX,ZUNIONSTORE,ZREMRANGEBYRANK,ZREMRANGEBYSCORESWAPDB,UNLINK(requires source database engine version Redis 4.0 or later)XADD,XCLAIM,XDEL,XAUTOCLAIM,XGROUP CREATECONSUMER,XTRIM
PUBLISH commands are not synchronized.
If you use EVAL or EVALSHA to call Lua scripts, DTS cannot confirm whether the scripts execute successfully in the destination. The destination does not return explicit execution results for Lua scripts during incremental synchronization.