After Redis data is migrated, you can check whether the data is consistent between the source and destination Redis instances.
- Redis data is migrated.
- An Elastic Compute Service (ECS) instance is created to run the redis-full-check tool.
- The IP address of the ECS instance is added to the whitelists of both the source and destination Redis instances.
- The ECS instance is running the Linux operating system.
- Git and Golang are installed in the ECS instance.
If an exception occurs during Redis data migration, the data is inconsistent between the source and destination Redis instances. You can use the redis-full-check tool to locate abnormal data, which provides a reliable basis for data alignment.
The redis-full-check tool is a Redis data verification tool developed by Alibaba Cloud. It can extract data from the source and destination instances, compare them for multiple times, and then record the comparison results in a SQLite3 database. This tool can be used to verify full data.
- Log on to the ECS instance that can access the destination Redis instance.
- Clone the redis-full-check tool to the ECS instance.
# git clone https://github.com/alibaba/RedisFullCheck.git
- Go to the RedisFullCheck directory and set the environment variable.
# cd RedisFullCheck # export GOPATH=`pwd`
- Go to the vendor directory, download the govendor file, and then grant the owner of
this file the execution permission.
# cd src/vendor # wget http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/94155/cn_zh/1556268861235/govendor # chmod u+x govendorNote If you have downloaded govendor, skip this step.
- Run the
- After the synchronization is completed, go to the RedisFullCheck directory to compile
# cd .. /.. / # ./build.sh
- Run the following command to verify data:
# ./bin/redis-full-check -s <Source Redis address>:<Source port> -p <Source Redis password> -t <Destination Redis address>:<Destination port> -p <Destination Redis password>
Table 1. Common parameters of redis-full-check Parameter Description Example -s The connection address and port of the source Redis instance.
-p The password of the source Redis instance.
-t The connection address and port of the destination Redis instance.
-a The password of the destination Redis instance.
TargetPwd233Note After the verification is completed, the comparison result is displayed on the CLI. The following result indicates that two keys are inconsistent between the source and destination Redis instances. If the number of inconsistent keys is 0, the data is consistent between the source and destination Redis instances.
all finish successfully, totally 2 keys or fields conflict
- Check the SQLite3 database that stores the inconsistent keys.
- Run the
sqlite3 result.db. 3command.Note The list of inconsistent keys is stored in result.db. 3 by default.
- Run the
SELECT * FROM key;command.Note The SQLite3 database includes the key and field tables.
- The inconsistent keys are stored in the key table.
- Details of inconsistent data of the hash, set, zset, and list types are stored in the field table.
- Run the