All Products
Search
Document Center

Data Transmission Service:Use OpenAPI Explorer to configure one-way or two-way synchronization between Tair (Redis OSS-Compatible) Enhanced Edition instances

Last Updated:Nov 19, 2024

You can call the API operations of Data Transmission Service (DTS) in OpenAPI Explorer to configure one-way or two-way synchronization between Tair (Redis OSS-Compatible) Enhanced Edition instances. This topic describes the usage notes and provides sample code.

Prerequisites

The source and destination instances are Tair (Redis OSS-Compatible) Enhanced Edition instances that run Redis 5.0.

Note
  • For one-way synchronization, the source instance cannot be a storage-optimized instance. For two-way synchronization, the source and destination instances cannot be storage-optimized instances.

  • The appendonly parameter is set to yes if the source instance is a persistent memory-optimized instance of Tair (Redis OSS-Compatible) Enhanced Edition.

  • The architecture of the instances is not limited. The architecture can be cluster, standard, or read/write splitting.

Usage notes

  • During two-way synchronization, the data synchronization task in the forward direction performs initial full data synchronization and incremental data synchronization. The data synchronization task in the reverse direction performs only incremental data synchronization.

    Warning

    To ensure data consistency, do not modify or write data to the same key in the source and destination databases when the two-way synchronization task is running.

  • DTS uses the resources of the source and destination databases during initial full data synchronization. This may increase the loads on the database servers. If you synchronize a large amount of data or if the server specifications do not 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.

  • We recommend that you do not run the FLUSHDB or FLUSHALL command in the source instance during data synchronization. If you run one of the commands, data inconsistency may occur between the source and destination instances.

  • By default, the maxmemory-policy parameter that specifies how data is evicted is set to volatile-lru for Tair (Redis OSS-compatible) instances. If the destination instance has insufficient memory, data inconsistency may occur between the source and destination instances due to data eviction. In this case, the data synchronization task does not stop running.

    To prevent data inconsistency, we recommend that you set maxmemory-policy to noeviction for the destination instance. This way, the data synchronization task fails if the destination instance has insufficient memory, but data loss can be prevented for the destination instance.

    Note

    For more information about data eviction policies, see What is the default eviction policy of Tair?

  • 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.

    Note

    The number of keys that do not have the expiration policy enabled or have not expired is the same between the source and destination databases.

  • If direct connection is disabled for the destination Tair (Redis OSS-Compatible) Enhanced Edition instance, DTS uses the proxy forwarding mode to write data to the destination instance.

    Note

    For more information about how to enable direct connection, see Enable the direct connection mode.

  • During data synchronization, if the number of shards in the source instance increases or decreases or if the instance 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 data synchronization task.

  • During data synchronization, the endpoint of the source instance may be changed. For example, the endpoint of the source instance is changed if the zone of the instance is changed or the network type is changed from classic network to Virtual Private Cloud (VPC). In this case, you must reconfigure the data synchronization task.

  • Limits on synchronizing data from a standalone Tair (Redis OSS-Compatible) instance to an Tair (Redis OSS-Compatible) cluster instance: Each command can be run only on a single slot in an Tair (Redis OSS-Compatible) cluster instance. 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. Otherwise, the data synchronization task is interrupted.

  • 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 transparent data encryption (TDE) feature is enabled for the source or destination instance, you cannot use DTS to synchronize data from the source database to the destination database.

  • The timeout period for data replication between the master and replica nodes in a Redis database is specified by the repl-timeout parameter. We recommend that you run the config set repl-timeout 600 command to set the timeout period to 600 seconds for the source instance. 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.

Billing

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

Limits

One-way cascade synchronization is not supported. For more information, see Synchronization topologies.

Commands 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, 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

  • SWAPDB (This command cannot be synchronized if the source or destination instance is deployed in the cluster architecture.)

Important
  • PUBLISH commands 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. As a result, the destination instance may contain duplicate data records.

Before you begin

Create an AccessKey pair.

Note

To protect the AccessKey pair of your Alibaba Cloud account, we recommend that you create a Resource Access Management (RAM) user, grant the RAM user the permissions to access DTS, and then use the AccessKey pair of the RAM user to call DTS SDK for Java. For more information, see Control access to resources by using RAM users.

Create a data synchronization instance

  1. Log on to OpenAPI Explorer.

  2. Configure the request parameters based on your business requirements. The following table describes the parameters.

    Parameter

    Description

    Value

    SourceRegion

    The ID of the region in which the source instance resides.

    Specify a value for these parameters based on your business requirements.

    DestRegion

    The ID of the region in which the destination instance resides.

    Topology

    The synchronization topology. Valid values:

    • oneway (default): one-way synchronization.

    • bidirectional: two-way synchronization.

    SynchronizationJobClass

    The instance class of the data synchronization instance. Valid values: micro, small, medium, and large.

    PayType

    The billing method of the data synchronization instance. Valid values:

    • PrePaid: subscription.

    • PostPaid (default): pay-as-you-go.

    SourceEndpoint.InstanceType

    The type of the source instance.

    Set the value to Redis.

    DestinationEndpoint.InstanceType

    The type of the destination instance.

    Set the value to Redis.

    Note

    For more information, see CreateSynchronizationJob.

  3. In the lower part of the page, click Initiate Call.

  4. On the Response tab, view the status of the request and the response.概览

    Important

    If the request fails, you need to modify the request parameters based on the message returned in the response and send the request again until the request is successful.

  5. Optional. Obtain the sample code of the SDK.sdk

    1. Click the SDK Sample Code tab.

    2. Specify the SDK version and programming language.

    3. Click the 复制 icon in the upper-right corner of the code section.

Configure a one-way synchronization task

In this example, the database account of the source instance has the read permissions on the source database. The database account of the destination instance has the read and write permissions on the destination database.

Note

When you configure a one-way synchronization task, you can also use a self-managed Redis database or an Tair (Redis OSS-Compatible) Community Edition instance as the source or destination database. The configuration method is similar to that described in this topic. However, you must specify the request parameters such as MigrationReserved based on your actual scenario.

  1. Log on to OpenAPI Explorer.

  2. Configure the request parameters based on your business requirements.

    Note

    You must set the SynchronizationDirection parameter to Forward. For more information, see ConfigureSynchronizationJob.

  3. In the lower part of the page, click Initiate Call.

  4. On the Response tab, view the status of the request and the response.概览

    Important

    If the request fails, you need to modify the request parameters based on the message returned in the response and send the request again until the request is successful.

  5. Optional. Obtain the sample code of the SDK.

    1. Click the SDK Sample Code tab.

    2. Specify the SDK version and programming language.

    3. Click the 复制 icon in the upper-right corner of the code section.

Configure two-way synchronization tasks

In this example, the database accounts used for data synchronization have the read and write permissions.

  1. Configure a data synchronization task in the forward direction. For more information, see the Configure a one-way synchronization task section of this topic.

  2. Wait until the state of the data synchronization task in the forward direction changes to Synchronizing.

    Note

    You can view the status of a data synchronization task in the DTS console or by calling the DescribeSynchronizationJobStatus operation.

  3. Configure the data synchronization task in the reverse direction.

    1. Optional. Log on to OpenAPI Explorer.

    2. Configure the request parameters based on your business requirements.

      Note

      You must set the SynchronizationDirection parameter to Reverse. For more information, see ConfigureSynchronizationJob.

    3. In the lower part of the page, click Initiate Call.

    4. On the Response tab, view the status of the request and the response.概览

      Important

      If the request fails, you need to modify the request parameters based on the message returned in the response and send the request again until the request is successful.

    5. Optional. Obtain the sample code of the SDK.

      1. Click the SDK Sample Code tab.

      2. Specify the SDK version and programming language.

      3. Click the 复制 icon in the upper-right corner of the code section.

References