Use redis-shake to migrate redis-cluster clusters
Migrate redis-cluster using redis-shake
Background:
IDC is on the cloud. Two sets of redis-cluster need to be migrated to the cloud. Here we use redis-shake to do the migration operation.
Simulate the cluster of the server room (the picture is cut off by me, and there is already a key on the picture):
Simulate the cluster on the cloud (the image is truncated by me, and there is already a key on the image):
Before migrating, redis-cluster, let's create some data and go to the computer room cluster. The script is as follows:
For i in {1... 10000}; do echo "set age$i $I" | redis-cli-c-h 172.31.1.133-p 6391done
Then, first find out the master node information of the old redis cluster, which is needed for the redis-shake migration. As follows:
Echo 'cluster nodes' | redis-cli-c-h 172.31.1.133-p 6391 | egrep master
1154ebeb83a53ad7ac09d14b49f4ec28af91e1e5 172.31.1.133connected 6392mm 16392 master-01571397581506 13 connected 4097-8193248a9d4e2ab4da9875c2ff2fb9c222be0b07deb7 172.31.1.134Ru 6393V 16393 master-01571397583018 2 connected 8194-1229094d42bffd85e4c8acf49c64b182023e9381805aa 172.31.1.134VOR 635215352 master-01571397582508 11 connected 12291-163831dd160e9fbfe4bb5d8c251053c9d7b752b23d317 172.31.1.134Rod 635315353 master-01571397582608 10 connected 0-4096
What I have here is the following four nodes master:
172.31.1.133lug 6392X 172.31.1.134R 6393X 172.31.1.134R 6352X 172.31.1.134L 6353
Then, find out the master node information for the new redis cluster, which will be used for the redis-shake migration. As follows:
Echo 'cluster nodes' | redis-cli-h 172.31.1.133-p 6394 | egrep master
9a81aecf9ad5d2bb6104134107215b528476eec6 172.31.1.134connected 6397V 16397 master-01571398028000 1 connected 8194-122902b1bf7f11258ac363962c6216d19687e2d9e6bbe 172.31.1.133V 6397V 16397 master-01571398027348 4 connected 12291-163833aec1bed303b228290886eb21af0a9907f4c22c9 172.31.1.134V 6396V 16396 master-01571398025000 5 connected 4097-8193d8173ea22c504639e3102991876edd401ec4f3d9 172.31.1.1331A 6394U 16394 myself,master-01571398027000 0 connected 0-4096
What I have here is the following four nodes master:
172.31.1.134lug 6397X 172.31.1.133R 6397umbent 172.31.1.134L 6396X 172.31.1.133L 6394
Then, edit the configuration of redis-shake
Vim redis-shake.conf modifies the contents of the source section and the target section as follows:
Source.type = clustersource.address = 172.31.1.133There is 6392There is 172.31.1.134There is source.auth_type = authtarget.type = clustertarget.address = 172.31.1.134Raw = authtarget.type = clustertarget.address = 172.31.1.134PasswordShowraw = clustertarget.address = 172.31.1.133WART 6397Trached172.31.1.134For 6396Trache172.31.1.133For 6394targepasswordraw = target.auth_type = authtarget.db =-1
Start the migration process:
. / redis-shake.linux-type sync-conf redis-shake.conf
The following figure shows the log of redis-shake during the migration (the last line is the instantaneous value of the amount of data written to the target redis cluster)