The redis-cli tool allows you to use an AOF file to migrate data from self-managed Redis databases to the instances of ApsaraDB for Redis.
The redis-cli tool is a Redis-native 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 instances of ApsaraDB for Redis. You can also use Data Transmission Service (DTS) to migrate data.
- 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 is not deployed on an Alibaba Cloud ECS instance, you must copy the existing AOF file to an ECS instance before you migrate data.
- The redis-cli tool is a Redis-native command-line tool of Redis. If you cannot use the redis-cli tool on an ECS instance, you can download and install Redis.
For a self-managed Redis instance that is created on an Alibaba Cloud ECS instance, perform the following operations:
- Enable the AOF feature of the existing self-managed 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
- 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.aofNotice If your self-managed 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