You can use Data Transmission Service (DTS) to perform one-way data synchronization between ApsaraDB for Redis instances that belong to different Alibaba Cloud accounts. This feature is applicable to scenarios such as resource migration or resource merging across Alibaba Cloud accounts and business architecture adjustment.

Prerequisites

  • If the source ApsaraDB for Redis instance is a Community Edition instance, the engine version must be 4.0 or 5.0. If the source ApsaraDB for Redis instance is an Enhanced Edition instance, the engine version must be 5.0.
    Note The engine version of the destination ApsaraDB for Redis instance can be 4.0 or 5.0. The engine version of the destination ApsaraDB for Redis instance cannot be earlier than the engine version of the source ApsaraDB for Redis instance. Before you synchronize data between two ApsaraDB for Redis instances that use different engine versions, check the compatibility of the two versions. For example, you can create a destination ApsaraDB for Redis instance based on the pay-as-you-go billing method 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 source and destination ApsaraDB for Redis instances are deployed in the cluster, standard, or read/write splitting architecture. If the source and destination ApsaraDB for Redis instances are deployed in the read/write splitting architecture, the disk type of the instances must be local disk.
  • If the source and destination ApsaraDB for Redis instances are deployed in the cluster architecture, the disk type of the instances cannot be local disk. However, if the source and destination ApsaraDB for Redis instances are deployed in the replica set architecture, the disk type of the instances can be local disk.
  • The source ApsaraDB for Redis instance is deployed in a virtual private cloud (VPC). If the source instance is deployed in the classic network, you can change the network type to VPC. For more information, see Change the network type from classic network to VPC.
  • Secure Sockets Layer (SSL) encryption is disabled for the source ApsaraDB for Redis instance. For more information, see Configure SSL encryption for an ApsaraDB for Redis instance.
  • 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.
  • ApsaraDB for Redis Enhanced Edition (Tair) is integrated with more Redis modules than ApsaraDB for Redis Community Edition. For more information, see Integration of multiple Redis modules. To ensure compatibility between the source and destination instances, the edition of the destination instance must be Enhanced if the edition of the source instance is Enhanced.

Background information

Two ApsaraDB for Redis instances are created by different Alibaba Cloud accounts. You need to synchronize data from the instance of Account A to the instance of Account B. The following figure shows the architecture of the synchronization solution. Data synchronization between ApsaraDB for Redis instances of different accounts

The following table describes how to configure a one-way data synchronization task for this scenario.

Step Description
1. Use Account A to log on to the Alibaba Cloud Management Console and grant the required permission to a RAM role. For more information, see Before you begin. When you configure the RAM role, set Account B as the trusted account, and authorize the RAM role to access the resources of Account A.
2. Use Account B to log on to the Alibaba Cloud Management Console and configure the data synchronization task. For more information, see Procedure. DTS can read information about the source ApsaraDB for Redis instance across Alibaba Cloud accounts.

Supported source and destination databases

You can use DTS to synchronize data between the following types of Redis databases across Alibaba Cloud accounts.
Source database Destination database
  • ApsaraDB for Redis instance
  • Self-managed database that is hosted on Elastic Compute Service (ECS)
  • Self-managed database that is connected over Express Connect, VPN Gateway, or Smart Access Gateway
  • Self-managed database that is connected over Cloud Enterprise Network (CEN)
  • ApsaraDB for Redis instance
  • Self-managed database that is hosted on ECS
  • Self-managed database that is connected over Express Connect, VPN Gateway, or Smart Access Gateway
  • Self-managed database that is connected over CEN

Limits

SQL operations that can be synchronized

Edition SQL operation
ApsaraDB for Redis Community Edition
  • 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 ApsaraDB for Redis instance is 4.0)
ApsaraDB for Redis Enhanced Edition (Tair)
  • 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, RPOP, RPOPLPUSH, RPUSH, and RPUSHX
  • SADD, SDIFFSTORE, SELECT, SET, SETBIT, SETEX, SETNX, SETRANGE, SINTERSTORE, SMOVE, SPOP, SREM, and SUNIONSTORE
  • UNLINK, ZADD, ZINCRBY, ZINTERSTORE, ZREM, ZREMRANGEBYLEX, ZUNIONSTORE, ZREMRANGEBYRANK, and ZREMRANGEBYSCORE
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.

Before you begin

Use the Alibaba Cloud account that owns the source ApsaraDB for Redis instance to log on to the Alibaba Cloud Management Console. Then, create a RAM role and authorize the RAM role to access the cloud resources of the Alibaba Cloud account. For more information, see Configure RAM authorization for cross-account data migration and synchronization.

Procedure

  1. Use the Alibaba Cloud account that owns the destination ApsaraDB for Redis instance to log on to the Data Synchronization page of the new DTS console
    Note You can also log on to the Data Management (DMS) console. In the top navigation bar, choose DTS > Data Synchronization.
  2. In the upper-left corner of the page, select the region where the data synchronization instance resides.
    Select a region
  3. Click Create Task. On the page that appears, configure the source and destination databases.
    Warning After you select the source and destination instances, we recommend that you read the limits displayed at the top of the page. This helps you create and run the data synchronization task.
    Section Parameter Description
    N/A Task Name

    DTS automatically generates a task name. We recommend that you specify an informative name to identify the task. You do not need to use a unique task name.

    Source Database Select Template
    If the connection settings of the instance has been saved as a template, you can select the connection name. DTS automatically applies the saved connection settings.
    Note
    • You can modify the connection settings of a template.
    • To edit the template name, you can click Edit Template Name at the bottom of the Source Database section.
    • The modified connection template will take effect the next time you select the connection template. The database instance that you have configured by using the template is not affected.
    Database Type Select Redis.
    Access Method Select Alibaba Cloud Instance.
    Instance Region Select the region where the source ApsaraDB for Redis instance resides.
    Replicate Data Across Alibaba Cloud Accounts Select Yes.
    Alibaba Cloud Account Enter the ID of the Alibaba Cloud account that owns the source ApsaraDB for Redis instance.
    Note To obtain the ID of the Alibaba Cloud account that owns the source ApsaraDB for Redis instance, you must log on to the Account Management console by using this account. The account ID is displayed on the Security Settings page.
    Obtain an Alibaba Cloud account ID
    RAM Role Name Enter the name of the RAM role that you created earlier in Before you begin.
    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. The database account that corresponds to the password must have the read permissions. If you forget the password, you can reset the password. For more information, see Change or reset the password.
    • If you use the default account, whose username is the same as the instance ID, you can enter only the password.
    • If you create a custom account, you must specify the password in the <Custom account>:<Password> format. Example: testaccount:Test1234.
    Note This parameter is optional and can be left blank if no database password is set.
    Save as Template
    Click Save as Template. In the dialog box that appears, set the name of the database connection, and click OK. The connection settings of the database instance is saved as a template.
    Note We recommend that you specify an informative name to identify the database connection. You do not need to use a unique name.
    Destination Database Select Template
    If the connection settings of the instance has been saved as a template, you can select the connection name. DTS automatically applies the saved connection settings.
    Note
    • You can modify the connection settings of a template.
    • To edit the template name, you can click Edit Template Name at the bottom of the Source Database section.
    • The modified connection template will take effect the next time you select the connection template. The database instance that you have configured by using the template is not affected.
    Database Type Select Redis.
    Access Method Select Alibaba Cloud Instance.
    Instance Region Select the region where the destination ApsaraDB for Redis instance resides.
    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. The database account that corresponds to the password must have the read permissions. If you forget the password, you can reset the password. For more information, see Change or reset the password.
    • If you use the default account, whose username is the same as the instance ID, you can enter only the password.
    • If you create a custom account, you must specify the password in the <Custom account>:<Password> format. Example: testaccount:Test1234.
    Save as Template
    Click Save as Template. In the dialog box that appears, set the name of the database connection, and click OK. The connection settings of the database instance is saved as a template.
    Note We recommend that you specify an informative name to identify the database connection. You do not need to use a unique name.
  4. In the lower part of the page, click Test Connectivity and Proceed.
  5. Select objects for the task and configure advanced settings.
    • Basic Settings
      Parameter Description
      Task Stages Incremental Data Synchronization is selected by default. You must also select Full Data Synchronization. After the precheck, DTS synchronizes the historical data of the selected objects from the source instance to the destination cluster. The historical data is the basis for subsequent incremental synchronization.
      Note Only ApsaraDB for Redis Enhanced Edition (Tair) supports full data synchronization.
      Processing Mode of Conflicting Tables
      • Precheck and Report Errors: checks whether the destination database contains tables that have the same names as tables in the source database. If the source and destination databases do not contain identical table names, the precheck is passed. Otherwise, an error is returned during precheck and the data synchronization task cannot be started.

      • Ignore Errors and Proceed: skips the precheck for identical table names in the source and destination databases.
        Warning If you select Ignore Errors and Proceed, data consistency is not guaranteed and your business may be exposed to potential risks.
        • If the source and destination databases have the same schema, and a data record has the same primary key as an existing data record in the destination database:
          • During full data synchronization, DTS does not synchronize the data record to the destination database. The existing data record in the destination database is retained.
          • During incremental data synchronization, DTS synchronizes the data record to the destination database. The existing data record in the destination database is overwritten.
        • If the source and destination databases have different schemas, data may fail to be initialized. In this case, only some columns are synchronized or the data synchronization task fails.
      Synchronization Topology Select One-way Synchronization.
      Select Objects

      Select one or more objects from the Source Objects section and click the Rightwards arrow icon to move the objects to the Selected Objects section.

      Note You can select only databases as the objects to be synchronized. You cannot select keys as the objects to be synchronized.
      Rename Databases and Tables In this scenario, you cannot rename objects.
      Select the SQL operations to be synchronized In the Selected Objects section, right-click an object. In the dialog box that appears, select the SQL operations that you want to synchronize. For more information, see SQL operations that can be synchronized.
    • Advanced Settings
      Parameter Description
      Set Alerts
      Specify whether to set alerts for the data synchronization task. If the task fails or the synchronization latency exceeds the threshold, the alert contacts will receive notifications.
      • Select No if you do not want to set alerts.
      • Select Yes to set alerts. In this case, you must also set the alert threshold and alert contacts.
      Retry Time for Failed Connection
      Specify the retry time for failed connections. Valid values: 10 to 1440. Unit: minutes. Default value: 120. We recommend that you set the retry time to more than 30 minutes. 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
      • If multiple DTS instances have the same source or destination database, the lowest value takes effect. For example, the retry time is set to 30 minutes for Instance A and 60 minutes for Instance B, DTS retries failed connections at an interval of 30 minutes.
      • 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.
  6. Click Next: Save Task Settings and Precheck in the lower part of the page.
    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.
  7. Wait until the Success Rate becomes 100%. Then, click Next: Purchase Instance.
  8. On the Purchase Instance page, specify the Billing Method and Instance Class parameters for the data synchronization instance. The following table describes the parameters.
    Section Parameter Description
    Parameters Billing Method
    • Subscription: You can pay for your subscription when you create an instance. We recommend that you select the subscription billing method for long-term use because it is more cost-effective than the pay-as-you-go billing method. You can save more costs with longer subscription periods.
    • Pay-as-you-go: A pay-as-you-go instance is billed on an hourly basis. We recommend that you select the pay-as-you-go billing method for short-term use. If you no longer require your pay-as-you-go instance, you can release it to reduce costs.
    Instance Class DTS provides several instance classes that have different performance in synchronization speed. You can select an instance class based on your business scenario. For more information, see Specifications of data synchronization instances.
    Subscription Length If you select the subscription billing method, set the subscription length and the number of instances that you want to create. The subscription length can be one to nine months or one to three years.
    Note This parameter is available only if you select the subscription billing method.
  9. Read and select Data Transmission Service (Pay-as-you-go) Service Terms.
  10. Click Buy and Start to start the data synchronization task. You can view the progress of the task in the task list.