Migrate data from Tair (Redis OSS-compatible) to ApsaraMQ for Kafka

Updated at:

Data Transmission Service (DTS) supports migrating data from Redis to Kafka. This topic describes how to migrate data from an Tair (Redis OSS-Compatible) instance to a ApsaraMQ for Kafka instance.

Important

This feature is in beta testing and is available only to select users.

Prerequisites

  • Create a destination ApsaraMQ for Kafka instance.

    Note

    For more information about the database versions supported by the source and destination databases, see Migration scenarios.

  • In the destination ApsaraMQ for Kafka instance, create a topic.

Precautions

Type

Description

Source database limitations

  • The source server must have sufficient outbound bandwidth. Insufficient bandwidth slows migration.

  • If you perform only full data migration (select only Full Data Migration for Migration Types), do not write new data to the source during migration. Otherwise, source and destination data becomes inconsistent. For real-time consistency, select both full and incremental data migration.

  • In a migration scenario that involves only Full Data Migration, DTS runs the INFO Keyspace command on the source to identify databases (DBs) with data. Only DBs in the INFO Keyspace result are migrated.

    Important

    Some third-party Redis services may not correctly list all DBs in the INFO Keyspace output, causing those DBs to be skipped. Before configuring the migration, run INFO Keyspace on the source to verify all required DBs are listed.

  • DTS inserts a key prefixed with DTS_REDIS_TIMESTAMP_HEARTBEAT into the source to track update timestamps (one per shard in cluster mode). This key is filtered during migration and expires after the task completes.

  • If the source instance is read-only or the DTS account does not have write (SETEX) permissions, the reported latency may be inaccurate.

  • To ensure a stable migration link, increase the repl-backlog-size parameter in redis.conf.

  • If some source keys have expiration policies, the target Kafka topic may have fewer records because expired keys may not yet be deleted from the source.

    Note

    The number of non-expiring keys remains consistent between the source and target.

  • If a Tair (Redis OSS-Compatible) instance has Transport Layer Security (TLS) encryption enabled, you must connect to it by using the SSL-encrypted method in DTS. TLSv1.3 is not supported. You cannot connect to an SSL-enabled Tair (Redis OSS-Compatible) instance by setting the Alibaba Cloud Instance to Alibaba Cloud Instance.

  • DTS does not support migration if Transparent Data Encryption (TDE) is enabled on the source instance.

  • If the source instance is a Tair (Enterprise Edition) instance whose Storage Medium is Persistent Memory, ensure that the appendonly parameter is set to yes as described in Steps.

  • If the source is a self-managed Redis instance:

    • If the self-managed Redis connection address changes during migration, reconfigure the task.

    • Set repl-timeout (replication timeout between slave and master) to 600 seconds using config set repl-timeout 600. Increase the repl-timeout value if the source contains a large amount of data.

    • When the Access Method for a Redis instance is Public IP Address, the Instance Mode does not support Cluster.

  • The following events during migration may cause full data migration to restart, leading to data inconsistency:

    • A transient connection interruption on the source Redis instance causes resumable transmission to fail.

    • A primary/secondary switchover or failover occurs on the source Redis instance.

    • The connection address of the source Redis instance changes.

  • Scaling (adding or removing shards), instance specification change (memory increase, spec change, or zone migration), or connection address and port changes during migration interrupt the task because DTS loses continuous log data. If this occurs, clear the data migrated to the target Redis instance before reconfiguring the task.

  • DTS migrates data only from the selected child instance in a Tair (Enterprise Edition) Global Distributed Cache. Data from other child instances is not migrated.

    Note

    If you need to migrate data from other child instances in the group, for assistance, join the DTS User Group on DingTalk (ID: 116655009709). The DingTalk client is available for download.

Other limitations

  • If the target Kafka instance is scaled (broker nodes added or removed) while DTS is running, restart the DTS instance.

  • Ensure DTS can connect to the source and destination. Security settings of the database instance, the bind parameter in redis.conf, and the listeners and advertised.listeners parameters in server.properties must allow DTS access.

  • Full migration increases load on the source and target. Evaluate performance beforehand and run during off-peak hours (for example, when CPU utilization is below 30%).

  • If data is written to the target from a source other than DTS while the instance is running, data inconsistency may occur and the DTS instance may fail.

  • For Lua scripts called by EVAL or EVALSHA, DTS cannot confirm whether the scripts were successfully executed during incremental data migration. This is because the target does not explicitly return an execution result.

  • List data may be duplicated because DTS does not Flush existing destination data when using psync or sync.

  • DTS auto-resumes failed instances for up to seven days. Before switching to the target, end or release the instance to prevent data overwriting.

  • If a task includes both full and incremental migration, DTS may re-run both after the migration instance restarts.

  • Restarting the migration instance may re-execute commands, causing data inconsistency—especially with non-idempotent commands like INCRBY or LPUSH, or if the restart triggers a new full data migration.

  • If a task fails, DTS support staff will attempt to restore it within eight hours. During restoration, they may restart the task or adjust its parameters.

    Note

    Only DTS task parameters are modified—not database parameters. Parameters that may be adjusted include those listed in Modify instance parameters.

Note

The current migration link does not support the ETL feature.

Billing

Migration type

Instance configuration fee

Internet traffic fee

Full data migration

Free of charge.

When the Access Method parameter of the destination database is set to Public IP Address, you are charged for Internet traffic. For more information, see Billing overview.

Incremental data migration

Charged. For more information, see Billing overview.

Supported commands for incremental data migration

DTS supports the following Redis commands during incremental data migration:

  • APPEND

  • BITOP, BLPOP, BRPOP, BRPOPLPUSH

  • DECR, DECRBY, DEL

  • EVAL, EVALSHA, EXEC, EXPIRE, EXPIREAT

  • FLUSHALL, FLUSHDB

  • GEOADD, GETSET

  • HDEL, HINCRBY, HINCRBYFLOAT, HMSET, HSET, HSETNX

  • INCR, INCRBY, INCRBYFLOAT

  • LINSERT, LPOP, LPUSH, LPUSHX, LREM, LSET, LTRIM

  • MOVE, MSET, MSETNX, MULTI

  • PERSIST, PEXPIRE, PEXPIREAT, PFADD, PFMERGE, PSETEX, PUBLISH

  • RENAME, RENAMENX, RESTORE, RPOP, RPOPLPUSH, RPUSH, RPUSHX

  • SADD, SDIFFSTORE, SELECT, SET, SETBIT, SETEX, SETNX, SETRANGE, SINTERSTORE, SMOVE, SPOP, SREM, SUNIONSTORE

  • ZADD, ZINCRBY, ZINTERSTORE, ZREM, ZREMRANGEBYLEX, ZUNIONSTORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE

  • XADD, XCLAIM, XDEL, XAUTOCLAIM, XGROUP CREATECONSUMER, XTRIM

Permissions required for database accounts

Database

Required permissions

Method to create and grant permissions

Source Tair (Redis OSS-Compatible) instance

Read permission

Create and manage accounts

Procedure

  1. Navigate to the migration task list page for the destination region using one of the following methods.

    From the DTS console

    1. Log on to the Data Transmission Service (DTS) console.

    2. In the navigation pane on the left, click Data Migration.

    3. In the upper-left corner of the page, select the region where the migration instance is located.

    From the DMS console

    Note

    The actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.

    1. Log on to the Data Management (DMS) console.

    2. In the top menu bar, choose Data + AI > Data Transmission (DTS) > Data Migration.

    3. To the right of Data Migration Tasks, select the region where the migration instance is located.

  2. Click Create Task to navigate to the task configuration page.

  3. Configure the source and destination databases.

    Category

    Configuration

    Description

    None

    Task Name

    DTS automatically generates a task name. We recommend that you specify a descriptive name for easy identification. The name does not need to be unique.

    Source Database

    Select Existing Connection

    • To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.

      Note

      In the DMS console, this parameter is named Select a DMS database instance..

    • If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.

    Database Type

    Select Tair/Redis.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region where the source Tair (Redis OSS-Compatible) instance resides.

    Replicate Data Across Alibaba Cloud Accounts

    This example describes migration between instances that belong to the same Alibaba Cloud account. Select No.

    Instance ID

    Select the ID of the source Tair (Redis OSS-Compatible) instance.

    Authentication Method

    Select an authentication method based on your requirements. In this example, Password Login is selected.

    Note
    • Only Redis 6.0 and later support Account + Password Login.

    • If you select Secret-free login, make sure that password-free access is enabled for the Redis database. For information about how to enable password-free access for a Tair (Redis OSS-Compatible) instance, see Enable password-free access over a VPC.

    Database Password

    Enter the password of the database account that is used to connect to the source Tair (Redis OSS-Compatible) instance. The account must have the read permission.

    • Default account: Enter the password.

    • New account: Enter the password in the <custom_account>:<password> format. For example, if the custom username of the Redis instance is admin and the password is Rp829dlwa, enter admin:Rp829dlwa.

    Encryption

    Select Non-encrypted or SSL-encrypted based on your database instance requirements.

    Note

    If you are using a self-managed Redis instance (the Access Method is not Alibaba Cloud Instance) and you select SSL-encrypted, you must also upload a CA Certificate and enter the CA Certificate Password.

    Destination Database

    Select Existing Connection

    • To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.

      Note

      In the DMS console, this parameter is named Select a DMS database instance..

    • If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.

    Database Type

    Select Kafka.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region where the destination Kafka instance resides.

    Kafka Instance ID

    Select the ID of the destination Kafka instance.

    Encryption

    Select Non-encrypted or SCRAM-SHA-256.

    Topic

    Select the topic that is used to receive data from the drop-down list.

    Use Kafka Schema Registry

    Kafka Schema Registry is a metadata service layer that provides a RESTful interface to store and retrieve Avro schemas.

    • No: Do not use Kafka Schema Registry.

    • Yes: Use Kafka Schema Registry. You must enter the URL or IP address that is used to register the Avro schema in Kafka Schema Registry.

  4. After you complete the configuration, click Test Connectivity and Proceed at the bottom of the page.

    Note
    • Ensure that the IP address segment of the DTS service is automatically or manually added to the security settings of the source and destination databases to allow access from DTS servers. For more information, see Add DTS server IP addresses to a whitelist.

    • If the source or destination database is a self-managed database (the Access Method is not Alibaba Cloud Instance), you must also click Test Connectivity in the CIDR Blocks of DTS Servers dialog box that appears.

  5. Configure the task objects.

    1. On the Configure Objects page, configure the objects that you want to migrate.

      Configuration

      Description

      Migration Types

      Select both Full Data Migration and Incremental Data Migration (or select Full Data Migration + Incremental Data Migration). If the account that you use to configure the DTS instance does not have the SYNC or PSYNC permission on the source database, select Full Data Migration.

      Processing Mode of Conflicting Tables

      No configuration is required. Keep the default value.

      Data Format in Kafka

      Select the storage format for data migrated to the Kafka instance.

      Kafka Data Compression Format

      Select a compression format for Kafka messages based on your requirements.

      • LZ4 (default): low compression ratio, high compression speed.

      • GZIP: high compression ratio, low compression speed.

        Note

        High CPU consumption.

      • Snappy: medium compression ratio, medium compression speed.

      Policy for Shipping Data to Kafka Partitions

      Select a policy.

      Message acknowledgement mechanism

      Select a Message acknowledgement mechanism.

      Topic That Stores DDL Information

      Select the topic for storing DDL information.

      Note

      If no topic is selected, DTS stores DDL information in the data topic by default.

      Source Objects

      In the Source Objects box, click the objects to migrate, and then click Right arrow to move them to the Selected Objects box.

      Note

      Source objects are selected by databases. If you want to migrate only partial data that matches specific keys, use the data filtering feature in the Selected Objects field.

      Selected Objects

      No additional configuration is required in this example.

      You can use the mapping feature to set the topic name, number of partitions, and additional columns for each source database (DB 0 to DB 255) in the destination Kafka instance. For more information, see Configure mapping information.

    2. Click Next: Advanced Settings.

      Configuration

      Description

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules tasks on a shared cluster. You do not need to select one. If you want more stable tasks, you can purchase a dedicated cluster to run DTS migration tasks.

      Retry Time for Failed Connections

      After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately begins to retry the connection. The default retry duration is 720 minutes. You can customize the retry time to a value from 10 to 1440 minutes. We recommend that you set the duration to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified duration, the migration task automatically resumes. Otherwise, the task fails.

      Note
      • For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.

      • Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.

      Retry Time for Other Issues

      After the migration task starts, if a non-connectivity issue, such as a DDL or DML execution exception, occurs in the source or destination database, DTS reports an error and immediately begins to retry the operation. The default retry duration is 10 minutes. You can customize the retry time to a value from 1 to 1440 minutes. We recommend that you set the duration to more than 10 minutes. If the related operations succeed within the specified retry duration, the migration task automatically resumes. Otherwise, the task fails.

      Important

      The value of Retry Time for Other Issues must be less than the value of Retry Time for Failed Connections.

      Enable Throttling for Full Data Migration

      During full migration, DTS consumes read and write resources on the source and destination databases, which may increase the database load. If required, you can enable throttling for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the load on the destination database.

      Note

      This option is available only when the values of Migration Types include Full Data Migration.

      Enable Throttling for Incremental Data Migration

      If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.

      Note

      This option is available only when the values of Migration Types include Full Data Migration.

      Use Slave Node

      No configuration is required in this example.

      If the source database is a self-managed Redis database and the Instance Mode is Cluster, you can choose to read data from the primary or secondary node. The default value is No, which means data is read from the primary node.

      Environment Tag

      You can select an environment tag to identify the instance as needed. No selection is required in this example.

      Configure ETL

      The current migration link does not support the ETL feature. No configuration is required.

      Monitoring and Alerting

      Select whether to set alerts and receive alert notifications based on your business needs.

      • No: Does not set an alert.

      • Yes: Configure alerts by setting an alert threshold and an alert contact. If a migration fails or the latency exceeds the threshold, the system sends an alert notification.

  6. Save the task and run a precheck.

    • To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.

    • If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.

    Note
    • Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.

    • If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.

    • If a warning is reported during the precheck:

      • For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.

      • For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.

  7. Purchase the instance.

    1. When the Success Rate reaches 100%, click Next: Purchase Instance.

    2. On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.

      Category

      Parameter

      Description

      New Instance Class

      Resource Group Settings

      Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?

      Instance Class

      DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.

    3. After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.

    4. Click Purchase And Start, and then click OK in the OK dialog box.

      You can view the progress on the data migration page.

      Note

      If the DTS instance that you configure contains both full and incremental migration tasks (Migration Types includes both Full Data Migration and Incremental Data Migration), the tasks are merged and displayed as Incremental Data Migration.

Configure mapping information

  1. In the Selected Objects box, right-click the selected migration object.

  2. In the Edit Schema dialog box, configure the mapping information.

    Configuration

    Description

    Name of target Topic

    The name of the topic that receives data in the destination Kafka instance. By default, this is the Topic that you selected in the Destination Database section during the Configurations for Source and Destination Databases step.

    Important
    • The specified topic name must exist in the destination Kafka instance. Otherwise, the data migration fails.

    • If you modify the Name of target Topic, the data is written to the topic that you specify.

    Number of Partitions

    The number of partitions for the destination topic to which data is written.

    Prefixes of Keys to Be Synchronized

    For more information, see Filter task data with an SQL condition.

    Prefixes of Keys to Be Filtered Out

    Additional Columns

    For more information, see Add additional columns.

  3. Click OK.