The redis-cli tool allows you to use an AOF file to migrate data from on-premises Redis to ApsaraDB for Redis.

The redis-cli tool is a native command-line tool of Redis. ApsaraDB for Redis allows you to use the redis-cli tool to seamlessly migrate existing Redis data to ApsaraDB for Redis. You can also use DTS to migrate data.

Precautions

  • ApsaraDB for Redis can be accessed only from the Alibaba Cloud network. Therefore, you can use this migration solution only in Alibaba Cloud Elastic Compute Service (ECS) instances. If your on-premises Redis instance is not created in an Alibaba Cloud ECS instance, you must copy the existing AOF file to an ECS instance before importing data.
  • The redis-cli tool is a native command-line tool of Redis. If you cannot use the redis-cli tool in an ECS instance, you can download and install Redis.

Procedure

For an on-premises Redis instance created in Alibaba Cloud ECS, migrate data as follows:

  1. Enable the AOF feature of the existing on-premises Redis instance. You can skip this step if the AOF feature is enabled. Run the following command:
    # redis-cli -h old_instance_ip -p old_instance_port config set appendonly yes
  2. Run the following command to import data from the AOF file, for example, the appendonly.aof file, into a new ApsaraDB for Redis instance:
    # redis-cli -h aliyun_redis_instance_ip -p 6379 -a password --pipe < appendonly.aof
    Notice

    If your on-premises Redis instance does not need the AOF feature, you can run the following command to disable the feature after data is imported:

    # redis-cli -h old_instance_ip -p old_instance_port config set appendonly no

You can also watch the following video to learn how to migrate data from on-premises Redis deployed in ECS to ApsaraDB for Redis. The video lasts about 4 minutes.