Data Transmission Service (DTS) supports one-way data synchronization 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 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. For more information about the architecture types, see https://www.alibabacloud.com/help/zh/doc-detail/86132.htm.

Prerequisites

  • The engine versions of the source and destination instances are supported by DTS. For more information, see Overview of data synchronization scenarios.
    Note The version of the destination instance must be the same as or later than that of the source instance. If you want to synchronize data between different versions of instances, make sure that the versions of the source and destination instances are compatible. For example, you can create a destination pay-as-you-go instance to verify the compatibility between the source and destination instances. Then, you can release this instance or change the billing method of the instance 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.
  • If the source instance is a persistent memory-optimized instance of the ApsaraDB for Redis Enhanced Edition (Tair), the appendonly parameter must be set to ON.
  • The source instance cannot be a storage-optimized instance of the ApsaraDB for Redis Enhanced Edition (Tair). In this scenario, a storage-optimized instance of ApsaraDB for Redis Enhanced Edition (Tair) can be used only as the destination 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 migrate a large amount 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 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 engine version of the source instance is 2.8, incremental data synchronization is not supported.
  • 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 inconsistency may occur between the source and destination instances.
  • If the data eviction policy (maxmemory-policy) of the destination instance is not set to noeviction, data inconsistency may occur between the source and destination instances. 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 instance is changed or if the database specifications are changed (for example, the memory capacity is scaled up), you must reconfigure the data synchronization task. To ensure data consistency, we recommend that you clear the data that has been synchronized to the destination instance before you reconfigure the task.
  • During data synchronization, if the endpoint of the source instance is changed, you must submit a ticket to update the endpoint change. Instance operations that may cause endpoint changes include zone changes and network type changes from classic network to virtual private cloud (VPC). Otherwise, the append-only files (AOFs) of the source instance may be reset. For this reason, you must reconfigure the task.
  • Limits on synchronizing a standalone ApsaraDB for Redis instance to an ApsaraDB for Redis cluster instance: Each command can be run only on a single slot in an ApsaraDB for Redis cluster instance. If you perform operations on multiple keys in the source database and the keys belong to different slots, an error occurs.
    CROSSSLOT Keys in request don't hash to the same slot
    We recommend that you perform operations on only one key during data synchronization. Otherwise, the synchronization task will be interrupted.

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.

SQL 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, and PSETEX
  • 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 engine version of the source instance is 4.0)
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.

Permissions required for database accounts

Database Permission and authorization method
Source ApsaraDB for Redis instance The database account must have read permissions. For more information about how to grant the required permissions to an account, see Create and manage database accounts.
Destination ApsaraDB for Redis instance The database account must have read and write permissions. For more information about how to grant the required permissions to an 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.
  5. Find the data synchronization instance and click Configure Task 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 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 Redis Instance.
    Instance Region The source region that you selected on the buy page. The value of this parameter cannot be changed.
    Instance ID The ID of the source instance.
    Database Password The database password of the source 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. The value of this parameter cannot be changed.
    Instance ID The ID of the destination instance.
    Database Password The database password of the destination 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.
  7. In the lower-right corner of the page, click Set Whitelist and Next.
    Note
    • You do not need to modify the security settings for ApsaraDB instances (such as ApsaraDB RDS for MySQL and ApsaraDB for MongoDB) and databases that are hosted on Elastic Compute Service (ECS). DTS automatically adds the CIDR blocks of DTS servers to the whitelists of ApsaraDB instances or the security group rules of ECS instances. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
    • After data synchronization is complete, we recommend that you remove the CIDR blocks of DTS servers from the whitelists or security groups.
  8. Select the processing mode of conflicting tables and the objects to synchronize. Select the processing mode and objects to synchronize
    Setting Description
    Select the processing mode of conflicting tables
    • Pre-check and Intercept: checks whether the destination instance is empty. If the destination instance is empty, the precheck is passed. If the instance 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 instances.
      Warning If you select Ignore, data records in the source instance overwrite the data records that have the same keys in the destination instance. Proceed with caution.
    Select the objects to synchronize
    • Select one or more databases from the Available section and click the icon to add the databases to the Selected section.
    • You can select only databases as objects to synchronize. Keys cannot be selected as objects to synchronize.
    Rename Databases and Tables In this scenario, you cannot rename objects.
    Replicate Temporary Tables When DMS Performs DDL Operations
    If you use Data Management (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.
  9. In the lower-right corner of the page, click Next.
  10. Select initial synchronization types. The value is set to Include full data + incremental data and cannot be changed. Select initial synchronization types
    Note
    • DTS synchronizes historical data from the source instance to the destination instance. Then, DTS synchronizes incremental data.
    • If a version-related error message is displayed, you must upgrade the source instance to a specified version. For more information about how to upgrade the version, see Upgrade the major version and Update 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. 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 Info icon icon next to each failed item to view details.
      • You can troubleshoot the issues based on the causes and run a precheck again.
      • If you do not need to troubleshoot the issues, you can ignore failed items and run a precheck again.
  12. Close the Precheck dialog box after the The precheck is passed. message is displayed in the Precheck dialog box. Then, the data synchronization task starts.
  13. Wait until initial synchronization is complete and the data synchronization task enters the Synchronizing state. State of the data synchronization task
    Note You can view the state of the data synchronization task on the Synchronization Tasks page.