This topic describes how to migrate data from a self-managed Redis database to an ApsaraDB for Redis instance by using Data Transmission Service (DTS). DTS supports full data migration and incremental data migration. When you migrate data from a self-managed Redis database to Alibaba Cloud, you can select full data migration and incremental data migration at the same time to ensure service continuity.

Prerequisites

Precautions

  • DTS consumes resources of the source and destination databases during full data migration. This may increase the loads on database servers. If the data volume is large or the server specifications do not meet your requirements, the database services may become unavailable. Before you migrate data, evaluate the performance of the source and destination databases. We recommend that you migrate data during off-peak hours.
  • If the data eviction policy (maxmemory-policy) of the destination instance is not set to noeviction, data between the source and destination instances may become inconsistent. For more information about the data eviction policy, see How does ApsaraDB for Redis evict data by default?
  • Some keys in the source database are configured with eviction policies, but these keys may not be immediately deleted after they are expired. In this case, the number of keys in the destination database may be less than the number of keys in the source database. You can run the info command to view the number of keys in the destination database.
    Note The source and destination databases have the same number of keys that are not configured with eviction policies or have not expired.
  • If you run the EVAL or EVALSHA command to execute Lua scripts, the destination database does not explicitly return the execution results of Lua scripts during incremental data migration. Therefore, DTS cannot identify whether the Lua scripts are executed on the destination database.
  • If you run the PSYNC or SYNC command to transmit data of the LIST type, DTS does not perform the flush operation on the existing data. Therefore, duplicate data may exist in the destination database.
  • If a data migration task fails, DTS automatically resumes the task. Before you switch your workloads to the destination instance, stop or release the data migration task. If you do not stop or release the data migration task, the data in the source database overwrites the data in the destination instance after the task is resumed.

Billing

Migration type Instance configuration fee Internet traffic fee
Schema migration and full data migration Free of charge Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Pricing.
Incremental data migration Charged. For more information, see Pricing.

Migration types

  • Support for full data migration
    DTS migrates existing data of the specified objects from the self-managed Redis database to the destination ApsaraDB for Redis instance.
    Note To ensure data consistency, do not write new data to the self-managed Redis database during full data migration.
  • Support for incremental data migration

    After the full data migration task is completed, DTS synchronizes incremental data from the self-managed Redis database to the destination ApsaraDB for Redis instance. Incremental data migration helps you ensure service continuity when you migrate data from a self-managed Redis database to Alibaba Cloud.

Operations that can be synchronized during incremental data migration

  • APPEND
  • BITOP, BLPOP, BRPOP, and BRPOPLPUSH
  • DECR, DECRBY, and DEL
  • EVAL, EVALSHA, EXEC, EXPIRE, and EXPIREAT
  • FLUSHALL and FLUSHDB
  • 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, PSETEX, and PUBLISH
  • 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

Preparations before incremental data migration

To ensure that incremental data migration tasks run as expected, we recommend that you remove the limit on the replication output buffer. In this example, the server runs Linux.

Note If you perform only full data migration, skip this step.
  1. Use redis-cli to connect to the self-managed Redis database.
    Note You can use redis-cli after you install Redis. For more information, see Redis community official website.
    redis-cli -h <host> -p <port> -a <password>
    Note
    • <host>: the endpoint that is used to connect to the self-managed Redis database. If the self-managed Redis database is deployed on the Linux server, you can use 127.0.0.1.
    • <port>: the service port number of the self-managed Redis database. The default port number is 6379.
    • <password>: the password of the self-managed Redis database.

    Example:

    redis-cli -h 127.0.0.1 -p 6379 -a Test123456
  2. Run the following command to remove the limit on the replication output buffer:
    config set client-output-buffer-limit 'slave 0 0 0'

Procedure

  1. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration.
  3. At the top of the Migration Tasks page, select the region where the destination RDS instance resides.Select a region
  4. In the upper-right corner of the page, click Create Migration Task.
  5. Configure the information about the source and destination databases. Configure the source and destination databases for the data migration task
    Section Parameter Description
    None Task Name DTS automatically generates a task name. To identify your business, we recommend that you specify a name that describes your business. You do not need to use a unique task name.
    Source Database Instance Type Select an instance type based on the location where the source database is deployed. In this example, select Self-managed Database with Public IP Address.
    Note If you select other instance types, you must prepare the environment that is required by the source database. For more information, see Preparation overview.
    Instance Region If the instance type is set to Self-managed Database with Public IP Address, you do not need to specify the instance region.
    Note If a whitelist is configured for the self-managed Redis database, you must add the CIDR blocks of the DTS servers to the whitelist of the self-managed Redis database. To obtain the IP addresses of the DTS servers, you can click Get IP Address Segment of DTS next to Instance Region.
    Database Type Select Redis.
    Instance Mode The value of this parameter is set to Standalone and cannot be changed to Cluster.
    Hostname or IP Address Enter the endpoint that is used to connect to the self-managed Redis database. In this example, the public endpoint is entered.
    Port Number Enter the service port number of the self-managed Redis database. The default port number is 6379.
    Note The service port of the self-managed Redis database must be accessible over the Internet.
    Database Password Enter the password of the self-managed Redis database.
    Note After you specify the source database parameters, click Test Connectivity next to Database Password to verify whether the specified parameters are valid. If the specified parameters are valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Modify the source database parameters based on the check results.
    Destination Database Instance Type Select Redis Instance.
    Instance Region Select the region where the destination instance is deployed.
    Redis Instance ID Select the ID of the destination ApsaraDB for Redis instance.
    Database Password Enter the password of the destination database account.
    Note After you specify the destination database parameters, click Test Connectivity next to Database Password to verify whether the parameters are valid. If the specified parameters are valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Modify the destination database parameters based on the check results.
  6. In the lower-right corner of the page, click Set Whitelist and Next.
    Note The IP addresses of DTS servers are automatically added to the whitelist of the destination ApsaraDB for Redis instance. This ensures that DTS servers can connect to the destination ApsaraDB for Redis instance.
  7. Select the migration types and the objects to be migrated. Select the migration types and the objects to be migrated
    Parameter Description
    Migration Types
    • To perform only full data migration, select only Full Data Migration.
    • To ensure service continuity during data migration, select Full Data Migration and Incremental Data Migration.
    Note If Incremental Data Migration is not selected, do not write data to the self-managed Redis database during full data migration. This ensures data consistency between the source and destination databases.
    Select the objects to be migrated

    Select objects from the Available section and click the Rightwards arrow icon to move the objects to the Selected section.

    Note You can select databases as the objects to be migrated.
  8. In the lower-right corner of the page, click Precheck.
    Note
    • Before you can start the data migration task, a precheck is performed. You can start the data migration task only after the task passes the precheck.
    • If the task fails to pass the precheck, click the Info icon icon next to each failed item to view details. Troubleshoot the issues based on the causes and run the precheck again.
  9. After the task passes the precheck, click Next.
  10. In the Confirm Settings dialog box, specify the Channel Specification and select Data Transmission Service (Pay-As-You-Go) Service Terms.
  11. Click Buy and Start to start the migration task.
    • Full data migration

      Do not manually stop a task during full data migration. Otherwise, data migrated to the destination database will be incomplete. Wait until the migration task automatically stops.

    • Incremental data migration

      An incremental data migration task does not automatically stop. You must manually stop the migration task.

      Note Select an appropriate time to manually stop the migration task. For example, you can stop the migration task during off-peak hours or before you switch your workloads to the destination instance.
      1. Wait until Incremental Data Migration and The migration task is not delayed appear in the progress bar of the migration task. Then, stop writing data to the source database for a few minutes. The delay time of incremental data migration may be displayed in the progress bar.
      2. After the status of incremental data migration changes to The migration task is not delayed, manually stop the migration task.The migration task is not delayed
  12. Switch your workloads to the destination ApsaraDB for Redis instance.

What to do next

The database accounts that are used for data migration have the read and write permissions. After the data migration task is completed, you must change the passwords of the self-managed Redis database and the ApsaraDB for Redis instance to ensure data security.