Data Transmission Service (DTS) allows you to perform one-way synchronization between cluster instances across Alibaba Cloud accounts. This feature is applicable to scenarios such as resource migration or merging, and business architecture adjustment across Alibaba Cloud accounts.

Prerequisites

  • If the source ApsaraDB for Redis instance is a Community Edition instance, the engine version is 4.0 or 5.0. If the source ApsaraDB for Redis instance is an Enhanced Edition (Tair) instance, the engine version is 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 must be later than that 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 that adopts 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.
  • Cluster, standard, or read/write splitting instances with local disks are configured as the source and destination instances.
  • For instances with cloud disks, standard instances are configured.
  • The source instance is deployed in a virtual private cloud (VPC). If the source ApsaraDB for Redis 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.
  • SSL encryption is disabled for the source instance. For more information, see Configure SSL encryption.
  • The available storage space of the destination instance is larger than the total size of the data in the source instance.
  • To ensure compatibility between the source and destination instances, if an ApsaraDB for Redis Enhanced Edition (Tair) instance is configured as the source instance, the destination instance must be an ApsaraDB for Redis Enhanced Edition (Tair) instance. This is because ApsaraDB for Redis Enhanced Edition (Tair) is integrated with more Redis modules than ApsaraDB for Redis Community Edition.
  • The appendonly parameter is set to yes if a persistent memory-optimized instance is configured as the source instance.
  • The source instance is not a storage-optimized ApsaraDB for Redis Enhanced Edition (Tair) instance. A storage-optimized ApsaraDB for Redis Enhanced Edition (Tair) instance can be used only as the destination instance.
  • The timeout period for data replication between the master and replica nodes in the source instance is specified by the repl-timeout parameter. By default, this parameter is set to 60 seconds. We recommend that you run the config set repl-timeout 600 command to set this parameter to 600 seconds. If the source instance stores a large amount of data, you can increase the value of the repl-timeout parameter based on your business requirements.

Background information

Assume that two ApsaraDB for Redis instances are created by different Alibaba Cloud accounts. You want 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 across Alibaba Cloud accounts

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

ProcedureDescription
1. Use Account A that owns the source instance to log on to the Resource Access Management (RAM) console and grant the required permissions to a RAM role. For more information, see the Preparations section of this topic. When you configure the RAM role, set Account B as the trusted account and authorize Account B to access the cloud resources of Account A.
2. Use Account B that owns the destination instance to log on to the DTS console and configure the data synchronization task. For more information, see the Procedure section of this topic. DTS can read information about the source ApsaraDB for Redis instance across Alibaba Cloud accounts.

Supported source and destination databases

The following table describes the supported types of databases when you use DTS to perform one-way synchronization between ApsaraDB for Redis databases across Alibaba Cloud accounts.
Source databaseDestination database
  • ApsaraDB for Redis instance
  • Self-managed database that is hosted on Elastic Compute Service (ECS)
  • Self-managed database 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 connected over Express Connect, VPN Gateway, or Smart Access Gateway
  • Self-managed database that is connected over CEN

Limits

CategoryDescription
Limits on the source database
  • The collections to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • To ensure the synchronization quality, Data Transmission Service (DTS) adds a key prefixed with DTS_REDIS_TIMESTAMP_HEARTBEAT to the source database. This key is used to record the time when data is synchronized to the destination database. If the source database is deployed in a cluster architecture, DTS adds this key on each shard. The key is filtered out during data synchronization. After the data synchronization task is complete, the key expires.
  • If the source database is a read-only database or the source database account that is used to run the data synchronization task does not have the permissions to run the SETEX command, the reported latency may be inaccurate.
  • To ensure the stability of data synchronization, we recommend that you increase the value of the repl-backlog-size parameter in the redis.conf file.
  • You must enable the append-only file (AOF) logging feature for the source database.
  • If an expiration policy is enabled for specific keys in the source database, these keys may not be deleted at the earliest opportunity after they expire. 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.
  • Limits on synchronizing data from a standalone Redis instance to a Redis cluster: Each command can be run only on a single slot in a Redis cluster. If you perform operations on multiple keys in the source database and the keys belong to different slots, the following 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. This prevents the data synchronization task from being interrupted.
  • The timeout period for data replication between the master and replica nodes in the source instance is specified by the repl-timeout parameter. By default, this timeout period is set to 60 seconds. We recommend that you run the config set repl-timeout 600 command to set this timeout period to 600 seconds. If the source database stores a large amount of data, you can increase the value of the repl-timeout parameter based on your business requirements.
  • A Tair ESSD-based instance cannot be configured as the source database.
  • A Tair enhanced SSD (ESSD)-based instance cannot be configured as the source database.
  • If the source database is a Tair persistent memory-optimized instance, you must set the appendonly parameter to yes for the instance.
Other limits
  • During data synchronization, if the number of shards in the source Redis database is increased or decreased, or if you change the database specifications, such as scaling up the memory capacity, 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 Redis database before you reconfigure the data synchronization task.
  • During data synchronization, if the endpoint of the source Redis database is changed, you must reconfigure the data synchronization task.
  • To ensure compatibility, the version of the destination database must be the same as or later than that of the source database. If the version of the destination database is earlier than that of the source database, database compatibility issues may occur.
  • During initial full data synchronization, DTS uses the read and write resources of the source and destination databases. This may increase the loads on the database servers. 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.
  • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases.
  • If the destination instance is deployed in a cluster architecture and the amount of memory used by a shard in the destination instance reaches the upper limit, or if the available storage space of the destination instance is insufficient, the data synchronization task fails due to out of memory (OOM).
  • If the data eviction policy (maxmemory-policy) of the destination database is not set to noeviction, data inconsistency may occur between the source and destination databases. For more information about data eviction policies, see How does ApsaraDB for Redis evict data by default?

Billing

Synchronization typeTask configuration fee
Schema synchronization and full data synchronizationFree of charge.
Incremental data synchronizationCharged. For more information, see Billing overview.

Redis commands that can be synchronized

EditionRedis command
ApsaraDB for Redis Community Edition instance
  • 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 (These two commands can be synchronized only if the engine version of the source instance is Redis 4.0.)
ApsaraDB for Redis Enhanced Edition (Tair) instance
  • 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
  • The PUBLISH command 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 database. This is because the destination database 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 database. As a result, the destination database may contain duplicate data records.

Preparations

  1. Required:Obtain the IDs of the Alibaba Cloud accounts to which the source and destination instances belong.
    Note Skip the step if you have obtained the IDs of the Alibaba Cloud accounts to which the source and destination instances belong.
    1. Log on to the Account Management console by using the Alibaba Cloud account to which the source or destination instance belongs.
    2. Optional:In the left-side navigation pane, click Basic Information.
    3. View and record the value of the Account ID parameter.
  2. Create a RAM role.
    1. Log on to the RAM console by using the Alibaba Cloud account to which the source instance belongs.
    2. In the left-side navigation pane, choose Identities > Roles.
    3. On the Roles page, click Create Role.
    4. In the Create Role panel, select Alibaba Cloud Account for the Select Trusted Entity parameter and click Next. Create a role
    5. In the Configure Role step, configure parameters for the RAM role. Select Trusted Entity
      ParameterDescription
      RAM Role NameThe name of the RAM role. In this example, ram-for-dts is used.
      Note The role name must be 1 to 64 characters in length and can contain letters, digits, and hyphens (-).
      NoteOptional. The description for the RAM role.
      Select Trusted Alibaba Cloud AccountSelect Other Alibaba Cloud Account and enter the ID of the Alibaba Cloud account to which the destination instance belongs.
    6. Click OK.
  3. Click Input and Attach to grant permissions to the created RAM role. Create Role
    1. In the Add Permissions panel, select System Policy as Type.
    2. In the Policy Name field, enter AliyunDTSRolePolicy. Add Permissions
    3. Click OK.
    4. After you grant the permissions, click Close.
  4. Modify the trust policy.
    1. On the Roles page, find the RAM role that you created and click the role name to view details. Roles
    2. On the Basic Information page of the RAM role, click the Trust Policy Management tab. Trust Policy Management
    3. On the Trust Policy Management tab, click Edit Trust Policy.
    4. Copy the following code to the code editor:
      {
          "Statement": [
              {
                  "Action": "sts:AssumeRole",
                  "Effect": "Allow",
                  "Principal": {
                      "RAM": [
                          "acs:ram::ID of the Alibaba Cloud account to which the destination instance belongs:root"
                      ],
                      "Service": [
                          "ID of the Alibaba Cloud account to which the destination instance belongs@dts.aliyuncs.com"
                      ]
                  }
              }
          ],
          "Version": "1"
      }
    5. In the preceding code, replace ID of the Alibaba Cloud account to which the destination instance belongs with the Alibaba Cloud account ID that you specified when you configure the RAM role information.
    6. Click OK.

Procedure

  1. Use the Alibaba Cloud account that owns the destination ApsaraDB for Redis instance to log on to the new DTS console and go to the Data Synchronization page.
    1. Log on to the Data Management (DMS) console.
    2. In the top navigation bar, click DTS.
    3. In the left-side navigation pane, choose DTS (DTS) > Data Synchronization.
  2. From the drop-down list to the right of Data Synchronization Tasks, select the region in which your data synchronization instance resides.
    Note If you use the new DTS console, select the region in which your data synchronization instance resides in the top navigation bar.
  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 in the upper part of the page. This helps you create and run the data synchronization task.
    SectionParameterDescription
    N/ATask 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 DatabaseSelect Instance
    The instance that you want to use. You can choose whether to use an existing instance based on your business requirements.
    • If you use an existing instance, DTS automatically applies the parameter settings of the instance.
    • If you do not use an existing instance, you must configure parameters for the source database.
    Database TypeThe type of the source database. Select ApsaraDB for Redis Enhanced Edition (Tair).
    Access MethodThe access method of the source database.Select Alibaba Cloud Instance.
    Instance RegionThe region in which the source ApsaraDB for Redis instance resides.
    Replicate Data Across Alibaba Cloud AccountsSpecifies whether to synchronize data across Alibaba Cloud accounts. In this example, Yes is selected.
    Note The two accounts can be an Alibaba Cloud account on the China site (aliyun.com) and an Alibaba Cloud account on the International site (alibabacloud.com).
    Alibaba Cloud AccountThe ID of the Alibaba Cloud account that owns the source ApsaraDB for Redis instance.
    Note To obtain the ID of the Alibaba Cloud account, you can log on to the Account Management console by using this account. The account ID is displayed on the Basic Information page.
    Alibaba Cloud account ID
    RAM Role NameThe name of the RAM role that you created by following the instructions in Preparations section of this topic.
    Instance IDThe ID of the source ApsaraDB for Redis instance.
    Database PasswordThe 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 use a custom account, specify the password in the <Custom account username>:<Password> format. Example: testaccount:Test1234.
    Note This parameter is optional and can be left empty if no database password is set for the source Redis database.
    Destination DatabaseSelect Instance
    The instance that you want to use. You can choose whether to use an existing instance based on your business requirements.
    • If you use an existing instance, DTS automatically applies the parameter settings of the instance.
    • If you do not use an existing instance, you must configure parameters for the destination database.
    Database TypeThe type of the destination database. Select ApsaraDB for Redis Enhanced Edition (Tair).
    Access MethodThe access method of the destination database. Select Alibaba Cloud Instance.
    Instance RegionThe region in which the destination ApsaraDB for Redis instance resides.
    Instance IDThe ID of the destination ApsaraDB for Redis instance.
    Database PasswordThe 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 use a custom account, specify the password in the <Custom account username>:<Password> format. Example: testaccount:Test1234.
  4. In the lower part of the page, click Test Connectivity and Proceed.
    Note
    • If the source or destination database is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers to the whitelist of the instance. If the source or destination database is a self-managed database hosted on an Elastic Compute Service (ECS) instance, DTS automatically adds the CIDR blocks of DTS servers to the security group rules of the ECS instance. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases. If the source or destination database is a self-managed database that is deployed in a data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers to the whitelist of the database to allow DTS to access the database.
    • After data synchronization is complete, we recommend that you remove the CIDR blocks of DTS servers from the allowlists or security groups. You must remove the IP address whitelist group whose name contains dts from the whitelist of the ApsaraDB instance or the security rules of the ECS instance. For more information about the CIDR blocks that you must remove from the whitelist of the self-managed databases that are deployed in data centers or databases that are hosted on third-party cloud services, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
  5. Select objects for the task and configure advanced settings.
    ParameterDescription
    Synchronization TypesBy default, Incremental Data Synchronization is selected. You must also select Full Data Synchronization. After the precheck, DTS synchronizes all the existing data of the selected objects from the source database to the destination database. The data is the basis for subsequent incremental synchronization.
    Note Full data synchronization is supported only for ApsaraDB for Redis Enhanced Edition (Tair) instances.
    Processing Mode of Conflicting Tables
    • Precheck and Report Errors: checks whether the destination cluster contains tables that have the same names as tables in the source database. If the source and destination databases do not contain tables that have identical table names, the precheck is passed. Otherwise, an error is returned during the 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 inconsistency may occur and your business may be exposed to potential risks.
      • If the source and destination databases have the same schemas, and a data record has the same primary key value 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 TopologySelect One-way Synchronization.
    Source Objects

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

    Note You can select databases as the objects to be synchronized. Keys cannot be selected as the objects to be synchronized.
    Selected ObjectsIn 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 the SQL operations that can be synchronized section of this topic.
    Note In this scenario, you cannot rename objects.
  6. Click Next: Advanced Settings to configure advanced settings.
    ParameterDescription
    Set Alerts
    Specifies whether to configure alerting for the data synchronization task. If the task fails or the synchronization latency exceeds the specified threshold, alert contacts will receive notifications. Valid values:
    Retry Time for Failed Connection
    The retry time range for failed connections. If the source or destination database fails to be connected after the data synchronization task is started, DTS immediately retries a connection within the time range. Valid values: 10 to 1440. Unit: minutes. Default value: 720. We recommend that you set the parameter to a value greater than 30. If DTS reconnects to the source and destination databases within the specified time range, DTS resumes the data synchronization task. Otherwise, the data synchronization task fails.
    Note
    • If you set different retry time ranges for multiple DTS tasks that have the same source or destination database, the shortest retry time range that is set takes precedence.
    • When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time range based on your business requirements. You can also release the DTS instance at the earliest opportunity after the source and destination instances are released.
    Configure ETL
    Specifies whether to configure the extract, transform, and load (ETL) feature. For more information, see What is ETL? What is ETL? Valid values:
  7. 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, click View Details next to each failed item. After you analyze the causes based on the check results, troubleshoot the issues. Then, run a precheck again.
    • If an alert is generated for an item during the precheck, perform the following operations based on the scenario:
      • In scenarios where you cannot ignore the alert item, click View Details next to the failed item. After you analyze the causes based on the check results, troubleshoot the issues. Then, run a precheck again.
      • In scenarios where you can ignore the alert item, click Confirm Alert Details next to the failed item. In the View Details dialog box, click Ignore. In the message that appears, click OK. Then, click Precheck Again to run a precheck again. If you ignore the alert item, data inconsistency may occur and your business may be exposed to potential risks.
  8. Wait until the success rate becomes 100%. Then, click Next: Purchase Instance.
  9. On the Purchase Instance page, configure the Billing Method and Instance Class parameters for the data synchronization instance. The following table describes the parameters.
    SectionParameterDescription
    New Instance ClassBilling Method
    • Subscription: You pay for the instance when you create an instance. The subscription billing method is more cost-effective than the pay-as-you-go billing method for long-term use.
    • Pay-as-you-go: A pay-as-you-go instance is charged on an hourly basis. The pay-as-you-go billing method is suitable for short-term use. If you no longer require a pay-as-you-go instance, you can release the pay-as-you-go instance to reduce costs.
    Instance ClassDTS 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 DurationIf you select the subscription billing method, set the subscription duration and the number of instances that you want to create. The subscription duration can be one to nine months or one to three years.
    Note This parameter is displayed only if you select the subscription billing method.
  10. Read and select the check box for Data Transmission Service (Pay-as-you-go) Service Terms.
  11. Click Buy and Start to start the data synchronization task. You can view the progress of the task in the task list.