The redis-cli tool allows you to use append-only files (AOFs) to migrate data from self-managed Redis databases to ApsaraDB for Redis instances.

The redis-cli tool is a command-line tool of Redis. ApsaraDB for Redis allows you to use the redis-cli tool to seamlessly migrate existing data in Redis databases to ApsaraDB for Redis instances. You can also use Data Transmission Service (DTS) to migrate data. For more information, see Migrate data from a self-managed Redis database to an ApsaraDB for Redis instance.

Precautions

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

Procedure

For a self-managed Redis instance that is hosted on an ECS instance, perform the following operations:

  1. Enable the AOF feature for the existing self-managed Redis instance. You can skip this step if the AOF feature is enabled. Sample command:
    redis-cli -h old_instance_ip -p old_instance_port config set appendonly yes
  2. Use an AOF file to import data from the existing Redis instance to a new ApsaraDB for Redis instance. Sample command:
    redis-cli -h aliyun_redis_instance_ip -p 6379 -a password --pipe < appendonly.aof
    Notice If your self-managed Redis instance does not need the AOF feature enabled all the time, you can disable the feature after data is imported. Sample command:
    redis-cli -h old_instance_ip -p old_instance_port config set appendonly no

FAQ

  • Q: What do I do if the ERR Protocol error: too big inline request error message is returned when I import data?
    A: Run the config get aof-use-rdb-preamble command to check whether the aof-use-rdb-preamble instance parameter is set to yes. If the parameter is set to yes, run the config set aof-use-rdb-preamble no command to set the parameter to no and then create another AOF file to re-import data.
    Note If the aof-use-rdb-preamble parameter is set to yes, some data of an AOF file is compressed and cannot be parsed and imported by using redis-cli commands. For more information, see Redis persistence.