Data Transmission Service (DTS) supports real-time one-way data synchronization between two Redis databases. This feature is applicable to scenarios such as active geo-redundancy and geo-disaster recovery. This topic describes how to configure data synchronization from a user-created Redis database connected over Express Connect, VPN Gateway, or Smart Access Gateway to a user-created Redis database hosted on ECS.
- The version of the source Redis database is 2.8, 3.0, 3.2, 4.0, or 5.0.
Note The database version of the destination Redis database can be 2.8, 4.0, or 5.0. The version of the destination database must be the same as or later than the version of the source database. If you want to synchronize data between different versions of Redis databases, make sure that the versions of the source and destination databases are compatible.
- The available storage space of the destination Redis database is larger than the total size of the data in the source Redis database.
- All nodes of the Redis cluster support the
PSYNCcommand and share the same password. This is required if the source Redis database is deployed in a cluster architecture.
- DTS uses resources of the source and destination databases during initial full data synchronization. This may increase the load of the database server. If the data volume is large or the specification is low, database services may become unavailable. Before you synchronize data, evaluate the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours.
- If the
bindparameter is configured in the
redis.conffile of the source Redis database, set the value of this parameter to the intranet IP address of ECS to ensure that DTS can connect to the source database normally.
- We recommend that you increase the value of the
repl-backlog-sizeparameter in the
redis.conffile of the source Redis database. This ensures the stability of data synchronization.
- To ensure the synchronization quality, DTS adds the following key to the source Redis
DTS_REDIS_TIMESTAMP_HEARTBEAT. This key is used to record the time when data is synchronized to ApsaraDB for Redis.
- If you configure data synchronization between ApsaraDB for Redis clusters, you cannot
FLUSHALLcommand in the source cluster. Otherwise, data in the source and destination databases may be inconsistent.
- If the data eviction policy (
maxmemory-policy) of the destination database is not set to
noeviction, the data between the source and destination databases may become inconsistent. For more information about the data eviction policy, see How does ApsaraDB for Redis evict data by default?
Supported synchronization topologies
- One-way one-to-one synchronization
- One-way one-to-many synchronization
- One-way cascade synchronization
For more information about synchronization topologies, see Synchronization topologies.
Operations that can be synchronized
- BITOP, BLPOP, BRPOP, and BRPOPLPUSH
- DECR, DECRBY, and DEL
- EVAL, EVALSHA, EXEC, EXPIRE, and EXPIREAT
- GEOADD and GETSET
- HDEL, HINCRBY, HINCRBYFLOAT, HMSET, HSET, and HSETNX
- INCR, INCRBY, and INCRBYFLOAT
- LINSERT, LPOP, LPUSH, LPUSHX, LREM, LSET, and LTRIM
- MOVE, MSET, MSETNX, and MULTI
- PERSIST, PEXPIRE, PEXPIREAT, PFADD, PFMERGE, PSETEX, and PUBLISH
- RENAME, RENAME, RESTORE, RPOP, RPOPLPUSH, RPUSH, and RPUSHX
- SADD, SDIFFSTORE, SELECT, SET, SETBIT, SETEX, SETNX, SETRANGE, SINTERSTORE, SMOVE, SPOP, SREM, and SUNIONSTORE
- ZADD, ZINCRBY, ZINTERSTORE, ZREM, ZREMRANGEBYLEX, ZUNIONSTORE, ZREMRANGEBYRANK, and ZREMRANGEBYSCORE
- SWAPDB and UNLINK (supported only when the version of the source Redis cluster is 4.0)
- If you use the EVAL or EVALSHA command to call Lua scripts, DTS cannot identify whether these Lua scripts are executed on the destination database. During incremental data synchronization, the destination database does not explicitly return the execution results of Lua scripts.
- When calling the SYNC or PSYNC command to transfer data of the LIST type, DTS does not clear the existing data. In this case, duplicate data may exist in the destination database.
- Purchase a data synchronization instance. For more information, see Purchase procedure.
Note On the buy page, set both Source Instance and Target Instance to Redis.
- Log on to the DTS console.
- In the left-side navigation pane, click Data Synchronization.
- At the top of the Synchronization Tasks page, select the region where the destination instance resides.
- Find the data synchronization instance and click Configure Synchronization Channel in the Actions column.
- Configure the source and destination instances.
Section Parameter Description N/A Synchronization Task Name DTS automatically generates a task name. We recommend that you use an informative name for easy identification. You do not need to use a unique task name. Source Instance Details Instance Type Select User-Created Database Connected over Express Connect, VPN Gateway, or Smart Access Gateway. Instance Region The region of the source instance. The region is the same as the source region that you selected when you purchased the data synchronization instance. You cannot change the value of this parameter. Peer VPC Select the ID of the VPC that is connected to the user-created Redis database. Database Type The value of this parameter is set to Redis. Instance Mode Select Standalone or Cluster based on the architecture of the source Redis database. IP Address Enter the server IP address of the source Redis database.Note If the source Redis database is deployed in a cluster architecture, enter the IP address of the server to which a master node belongs. Port Number Enter the service port number of the user-created Redis database. The default port number is 6379.Note If the source Redis database is deployed in a cluster architecture, enter the service port number of a master node. Database Password Enter the password for the source Redis database.Note This parameter is optional and can be left blank if no database password is set. Destination Instance Details Instance Type Select User-Created Database in ECS Instance. Instance Region The region of the destination instance. The region is the same as the destination region that you selected when you purchased the data synchronization instance. You cannot change the value of this parameter. Instance ID Select the ID of the ECS instance that is connected to the destination Redis database.Note If the destination Redis database is deployed in a cluster architecture, select the ID of the ECS instance where a master node resides. Instance Mode Select Standalone or Cluster based on the architecture of the destination Redis database. Port Number Enter the service port number of the destination Redis database. The default port number is 6379.Note If the destination Redis database is deployed in a cluster architecture, enter the service port number of a master node. Database Password Enter the password for the destination Redis database.Note This parameter is optional and can be left blank if no database password is set.
- In the lower-right corner of the page, click Set Whitelist and Next.
Note The CIDR blocks of DTS servers are automatically added to an inbound rule of the destination ECS instance. This ensures that DTS servers can connect to the destination ECS instance.
- Configure the processing mode in existing destination tables and the objects to be
Parameter Description Processing Mode In Existed Target Table
- Pre-check and Intercept: checks whether the destination database is empty. If the destination database is empty, the precheck is passed. If the database is not empty, an error is returned during precheck and the data synchronization task cannot be started.
- Ignore: skips the precheck for empty destination databases.
Warning If you select Ignore, the data records in the source database overwrite the data records with the same keys in the destination database.
Objects to be synchronized
- Select databases from the Available section and click the icon to move 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.
- In the lower-right corner of the page, click Next.
- Configure initial synchronization. The value is set to Include full data + incremental data.
Note Before synchronizing incremental data, DTS synchronizes historical data from the source Redis database to the destination Redis database.
- In the lower-right corner of the page, click Precheck.
- Before you can start the data synchronization task, a precheck is performed. You can start the data synchronization task only after the task passes the precheck.
- If the task fails to pass the precheck, click the icon next to each failed item to view details. Troubleshoot the issues based on the causes and run the precheck again.
- Close the Precheck dialog box after the following message is displayed: The precheck is passed.
- Wait until the initial synchronization is complete and the data synchronization task
is in the Synchronizing state.
Note You can view the status of the data synchronization task on the Synchronization Tasks page.