Data Transmission Service (DTS) supports one-way data synchronization between ApsaraDB for Redis instances. This feature is applicable to scenarios such as active geo-redundancy and geo-disaster recovery. This topic describes how to configure one-way data synchronization 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. For example, if you change the master-replica architecture to the cluster architecture, data synchronization fails.

Prerequisites

  • The database versions of the source and destination ApsaraDB for Redis instances are supported by DTS. For more information, see Supported databases, synchronization types, and synchronization topologies.
    Note 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. You can create a pay-as-you-go ApsaraDB for Redis instance to verify database compatibility. Then, you can release the instance or change the billing method to subscription.
  • The available storage space of the destination ApsaraDB for Redis instance is larger than the total size of the data in the source ApsaraDB for Redis instance.
  • The source instance is not an ApsaraDB for Redis Enhanced Edition instance (storage-optimized instance).
  • The disk type of the source or destination ApsaraDB for Redis instance is local disk rather than cloud disk.

Precautions

  • DTS uses the resources of the source and destination databases during full data synchronization. This may increase the loads of the database servers. If you synchronize a large volume 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, these 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 database version of the source ApsaraDB for Redis instance is 2.8, DTS does not synchronize incremental data.
  • We recommend that you do not run the FLUSHDB or FLUSHALL command on the source database during data synchronization. If you run one of the two commands, data may become inconsistent between the source and destination databases.
  • If the data eviction policy (maxmemory-policy) of the destination database is not set to noeviction, data may become inconsistent between the source and destination databases. For more information about data eviction policies, see How does ApsaraDB for Redis evict data by default?
  • During data synchronization, if the number of shards in the source ApsaraDB for Redis instance is increased or decreased, or if the database specifications are changed (for example, the memory capacity is scaled up), you must reconfigure the task. To ensure data consistency, we recommend that you clear the data that has been synchronized to the destination Redis database before you reconfigure the task.
  • During data synchronization, if the endpoint of the source ApsaraDB for Redis instance is changed (for example, the zone of the instance is changed or the network type is changed from classic network to VPC), you must submit a ticket to update the change. Otherwise, the append-only files (AOF) of the source ApsaraDB for Redis instance may be reset. In this case, you must reconfigure the task.

Supported synchronization topologies

  • One-way one-to-one synchronization
  • One-way one-to-many synchronization
  • One-way cascade synchronization

For more information, see Synchronization topologies.

Operations that can be synchronized

  • 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 (supported only if the database version of the source ApsaraDB for Redis instance is 4.0)
Note
  • If you run 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 DTS calls the SYNC or PSYNC command to transfer data of the LIST type, DTS does not clear the existing data. In this case, the destination database may contain duplicate data records.

Permissions required for database accounts

Database Permissions and authorization method
Source ApsaraDB for Redis instance The database account must have the 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 both Source Instance and Destination 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
    N/A Synchronization Task Name DTS automatically generates a task name. We recommend that you specify an informative name for easy identification. You do not need to use a unique task name.
    Source Instance Details Instance Type Select Redis Instance.
    Instance Region The source region that you selected on the buy page. 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 information about the permissions that are required for the database account, see Permissions required for database accounts.
    Note The database password is in the <user>:<password> format. 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 destination region that you selected on the buy page. You cannot change the value of this parameter.
    Instance ID Select the ID of the destination ApsaraDB for Redis instance.
    Database Password Enter the database password of the destination ApsaraDB for Redis instance. For information about the permissions that are required for the account, see Permissions required for database accounts.
    Note The database password is in the <user>:<password> format. 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 processing mode of conflicting tables, and the objects to be synchronized. Select the processing mode and the objects to be synchronized
    Setting Description
    Select the processing mode of conflicting tables
    • 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 the precheck and the data synchronization task cannot be started.
    • 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 to be synchronized
    • 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 as the objects to be synchronized. You cannot select keys as the objects to be synchronized.
  9. In the lower-right corner of the page, click Next.
  10. Select the initial synchronization types. The value is set to Include full data + incremental data. Select the initial synchronization types
    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 specified version. For more information, see Upgrade the major version and Upgrade the minor version.
  11. Click Precheck in the lower-right corner.
    Note
    • A precheck is performed before the synchronization task starts. The synchronization task only starts after the precheck succeeds.
    • If the precheck fails, click the Note icon next to each failed check item to view the related details. Fix the issues as instructed 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 initial synchronization is completed and the data synchronization task is in the Synchronizing state. Status of the data synchronization task
    Note You can view the status of the data synchronization task on the Synchronization Tasks page.