Data Transmission Service (DTS) allows you to synchronize data in one direction between ApsaraDB for Redis instances. This feature is suitable for scenarios such as active geo-redundancy and geo-disaster recovery. This topic describes how to synchronize data in one direction between ApsaraDB for Redis instances.

Warning After you configure a data synchronization task, do not change the architecture type of the source or destination database. Otherwise, data synchronization fails. For example, if you change the master-replica architecture to the cluster architecture, data synchronization fails.

Prerequisites

  • The engine version of the source ApsaraDB for Redis instance is Redis 4.0 or 5.0.
    Note The engine version of the destination instance can be Redis 4.0 or 5.0. The engine version of the destination instance must be the same or later than the engine version of the source instance. Before you synchronize data between two ApsaraDB for Redis instances that use different engine versions, check the compatibility of the two versions. You can create a pay-as-you-go ApsaraDB for Redis instance to verify the compatibility of the two databases. Then, you can release the instance or change the billing method to subscription.
  • The available storage of the destination ApsaraDB for Redis instance is larger than the total size of the data in the source ApsaraDB for Redis instance.

Precautions

  • DTS uses the resources of the source and destination instances during initial full data synchronization. This may increase the loads of the database servers. If you synchronize a large amount of data or 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 databases. We recommend that you synchronize data during off-peak hours.
  • If an expiration policy is enabled for some keys in the source database, some keys may not be deleted in a timely manner after they expired. 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 an expiration policy or have not expired is the same in the source and destination databases.
  • If the engine version of the source ApsaraDB for Redis instance is Redis 2.8, DTS does not synchronize incremental data.
  • We recommend that you do not run the FLUSHDB or FLUSHALL command on the source instance during data synchronization. If you run one of the two commands, data between the source and destination instances may become inconsistent.
  • If the data eviction policy (maxmemory-policy) of the destination instance is not set to noeviction, data between the source and destination instances may become inconsistent. For more information about the data eviction policy, see How does ApsaraDB for Redis evict data by default?

Supported synchronization scenarios

Note
  • You can synchronize data between different database types and architectures described in the following table. For example, you can synchronize data from a standard instance of ApsaraDB for Redis Community Edition to a cluster instance of ApsaraDB for Redis Enhanced Edition (Tair).
  • Before you synchronize data to instances of different types or architectures, make sure that the command limits of the destination instance do not affect your business. For more information, see Overview.
Supported source database Supported destination database Supported architecture Supported synchronization topology
  • ApsaraDB for Redis Community Edition

    Redis 4.0 and 5.0

  • ApsaraDB for Redis Enhanced Edition (Tair)

    Redis 5.0

  • ApsaraDB for Redis Community Edition

    Redis 4.0 and 5.0

  • ApsaraDB for Redis Enhanced Edition (Tair)

    Redis 5.0

  • One-way one-to-one synchronization
  • One-way one-to-many synchronization
  • One-way cascade synchronization
For more information, see Synchronization topologies.

Supported commands for data synchronization

  • APPEND
  • 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, RENAMENX, 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, which are supported only if the engine version of the source ApsaraDB for Redis instance is Redis 4.0
Note
  • If you run the EVAL or EVALSHA command to execute Lua scripts, DTS cannot identify whether the Lua scripts are executed in the destination database. During incremental data synchronization, the destination database does not return the execution results of Lua scripts.
  • When DTS runs the SYNC or PSYNC command to synchronize data of the LIST type, DTS does not clear the existing data. In this case, the destination database may contain duplicate data.

Permissions required for database accounts

Database Permissions and authorization method
Source ApsaraDB for Redis instance The database account must have read permissions. For more information about how to authorize the account, see Create and manage database accounts.
Destination ApsaraDB for Redis instance The database account must have the read and write permissions. For more information about how to authorize the account, see Create and manage database accounts.

Procedure

  1. Purchase a data synchronization instance. For more information, see Purchase a data synchronization instance.
    Note On the buy page, set Source Instance and Target Instance to Redis.
  2. Log on to the DTS console.
  3. In the left-side navigation pane, click Data Synchronization.
  4. At the top of the Synchronization Tasks page, select the region where the destination instance resides.Select a region
  5. Find the data synchronization instance and click Configure Synchronization Channel in the Actions column.
  6. Configure the source and destination instances. Configure the source and destination instances
    Section Parameter Description
    None Synchronization Task Name DTS automatically generates a task name. We recommend that you specify an informative name that helps you identify the task. You do not need to use a unique task name.
    Source Instance Details Instance Type Select Redis Instance.
    Instance Region The region that you select on the buy page for the source ApsaraDB for Redis instance. You cannot change the value of this parameter.
    Instance ID Select the ID of the source ApsaraDB for Redis instance.
    Database Password Enter the database password of the source ApsaraDB for Redis instance. For more information about the permissions that must be granted to the account, see Permissions required for database accounts.
    Note The format of the database password is <user>:<password>. For example, if the username of a custom account is admin and the password is Rp829dlwa, the database password is admin:Rp829dlwa.
    Destination Instance Details Instance Type Select Redis Instance.
    Instance Region The region that you select on the buy page for the destination ApsaraDB for Redis instance. You cannot change the value of this parameter.
    Instance ID Select the ID of the destination instance.
    Database Password Enter the database password of the destination ApsaraDB for Redis instance. For more information about the permissions that must be granted to the account, see Permissions required for database accounts.
    Note The format of the database password is <user>:<password>. For example, if the username of a custom account is admin and the password is Rp829dlwa, the database password is admin:Rp829dlwa.
  7. In the lower-right corner of the page, click Set Whitelist and Next.
    Note DTS adds the CIDR blocks of DTS servers to the whitelists of the source and destination ApsaraDB for Redis instances. This ensures that DTS servers can connect to the source and destination ApsaraDB for Redis instances.
  8. Select the objects that you want to synchronize and the processing mode of duplicate tables. Select the processing mode and objects
    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 exception is returned during precheck and the data synchronization task cannot start.
    • Ignore: skips the check for empty destination databases.
      Warning If you select Ignore, the data records in the source database overwrite the data records that have the same keys in the destination database. Proceed with caution.
    Select the objects that you want to synchronize
    • Select one or more databases from the Available section and click the icon to move the databases to the Selected section.
    • You can select only databases but not keys as the objects that you want to synchronize.
  9. In the lower-right corner of the page, click Next.
  10. Configure initial synchronization. The value is set to Include full data + incremental data. Configure initial synchronization for Redis databases
    Note
    • DTS synchronizes historical data from the source ApsaraDB for Redis instance to the destination ApsaraDB for Redis instance. Then, DTS synchronizes incremental data.
    • If a version-related error message appears, upgrade the source ApsaraDB for Redis instance to a required version. For more information, see Upgrade the major version and Upgrade the minor version.
  11. In the lower-right corner of the page, click Precheck.
    Note
    • Before you can start the data synchronization task, DTS performs a precheck. The data synchronization task can be started only after the task passes the precheck.
    • If the task fails to pass the precheck, click the Hint icon next to each failed item to view the details. Troubleshoot the issues based on the causes and run the precheck again.
  12. Close the Precheck dialog box after the following message appears: The precheck is passed. Then, the data synchronization task starts.
  13. Wait until the initial synchronization is complete and the data synchronization task is in the Synchronizing state. Status of the data synchronization task
    Note You can view the data synchronization status on the Synchronization Tasks page.