redis-cli is the command line tool of Redis, which can be used after you install the Redis server.
Run the following command to download Redis:
wget http://download.redis.io/releases/redis-5.0.8.tar.gz
This section describes how to use redis-cli to migrate a data from a self-hosted Redis instance to a DCS instance.
Run the following command to enable cache persistence and obtain an AOF persistence file:
redis-cli -h {source_redis_address} -p 6379 -a {password} config set appendonly yes
If the size of the AOF file does not change after you have enabled persistence, the AOF file contains full cached data.
Ensure that the ECS has sufficient disk space for data file decompression, and can communicate with the DCS instance. Generally, the ECS and DCS instance are configured to belong to the same VPC and subnet, and the configured security group rules do not restrict access ports. For details about how to configure a security group, see Security Group Configurations.
redis-cli -h {dcs_instance_address} -p 6379 -a {password} --pipe < appendonly.aof
After the data is imported successfully, access the DCS instance and run the info command to check whether the data has been successfully imported as required.
If the data import fails, analyze the cause, modify the data import statement, run the flushall or flushdb command to clear the cached data in the instance, and import the data again.
An AOF file can be generated quickly. It applies to scenarios where you can access the Redis server and modify the configurations, such as scenarios with self-built Redis servers.
It takes 4s to 10s to import 1 million data records (20 bytes per data record) in a VPC.