使用 redis-shake 遷移 redis-cluster
node
背景:linux
IDC上雲, 有2套redis-cluster須要遷移到雲上。 這裏咱們使用 redis-shake 來作遷移操做。redis
模擬機房集羣(圖是我後截的,圖上已經有key了): vim
模擬雲上集羣(圖是我後截的,圖上已經有key了): bash
遷移前, redis-cluster 咱們先造點數據進去到機房集羣去。腳本以下:ide
for i in {1..10000}; do echo "set age$i $i" | redis-cli -c -h 172.31.1.133 -p 6391 done
而後,先找出老的redis cluster的master節點信息, redis-shake遷移要用到。以下:3d
echo 'cluster nodes' | redis-cli -c -h 172.31.1.133 -p 6391 | egrep master 日誌
1154ebeb83a53ad7ac09d14b49f4ec28af91e1e5 172.31.1.133:6392@16392 master - 0 1571397581506 13 connected 4097-8193 248a9d4e2ab4da9875c2ff2fb9c222be0b07deb7 172.31.1.134:6393@16393 master - 0 1571397583018 2 connected 8194-12290 94d42bffd85e4c8acf49c64b182023e9381805aa 172.31.1.134:6352@16352 master - 0 1571397582508 11 connected 12291-16383 1dd160e9fbfe4bb5d8c251053c9d7b752b23d317 172.31.1.134:6353@16353 master - 0 1571397582608 10 connected 0-4096
我這裏的是以下4個節點爲master:blog
172.31.1.133:6392;172.31.1.134:6393;172.31.1.134:6352;172.31.1.134:6353進程
而後,找出 新的redis cluster 的master節點信息,redis-shake遷移要用到。以下:
echo 'cluster nodes' | redis-cli -h 172.31.1.133 -p 6394 | egrep master
9a81aecf9ad5d2bb6104134107215b528476eec6 172.31.1.134:6397@16397 master - 0 1571398028000 1 connected 8194-12290 2b1bf7f11258ac363962c6216d19687e2d9e6bbe 172.31.1.133:6397@16397 master - 0 1571398027348 4 connected 12291-16383 3aec1bed303b228290886eb21af0a9907f4c22c9 172.31.1.134:6396@16396 master - 0 1571398025000 5 connected 4097-8193 d8173ea22c504639e3102991876edd401ec4f3d9 172.31.1.133:6394@16394 myself,master - 0 1571398027000 0 connected 0-4096
我這裏的是以下4個節點爲master:
172.31.1.134:6397;172.31.1.133:6397;172.31.1.134:6396;172.31.1.133:6394
而後,編輯 redis-shake 的配置
vim redis-shake.conf 修改source部分和target部分的內容以下:
source.type = cluster source.address = 172.31.1.133:6392;172.31.1.134:6393;172.31.1.134:6352;172.31.1.134:6353 source.password_raw = source.auth_type = auth target.type = cluster target.address = 172.31.1.134:6397;172.31.1.133:6397;172.31.1.134:6396;172.31.1.133:6394 target.password_raw = target.auth_type = auth target.db = -1
啓動遷移進程:
./redis-shake.linux -type sync -conf redis-shake.conf
下圖是遷移過程當中,redis-shake的日誌(最後一行就是寫入到目標redis cluster的數據量瞬時值)