Introduction
Redis-cli is the command line client tool of Redis, which allows users to interact with the Redis server through the command line.
This section describes how to use Redis-cli to migrate data as an AOF file from a self-hosted Redis instance to a CT-DCS instance.
Description
Before migration, it is recommended to suspend related services to avoid the loss or incompleteness of data.
It is recommended to perform migration during off-peak hours.
Step 1: Generating an AOF file
Run the following command to enable cache persistence and generate an AOF persistence file:
./redis-cli -h {redis_address} -p {redis_port} -a {password} config set appendonly yes
If the size of the AOF file does not change, it means the AOF file contains full cached data.
Description
To find out the path for storing the AOF file, use Redis-cli to access the Redis instance, and run the config get dir command. Unless otherwise specified, the file is named as appendonly.aof by default.
To disable synchronization, use Redis-cli to log in to the Redis instance and run the config set appendonly no command.
Step 2: Uploading the AOF file to eSurfing Cloud ECS
To save transmission time, compress the AOF file first.
Upload the compressed file to eSurfing Cloud ECS using an appropriate mode (for example, SFTP or SCP mode).
Description
Ensure that the ECS has sufficient disk space for data file storage, and can communicate with the DCS instance. Generally, the ECS and DCS instances are configured to belong to the same VPC and subnet, and the configured security group rules do not restrict access ports.
Step 3: Importing Data
./redis-cli -h {redis_address} -p {redis_port} -a {password} --pipe < appendonly.aof
Step 4: Verifying Migration
After the data is imported successfully, access the DCS instance and run the dbsize command to check whether the data has been successfully imported.
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.