redis-trib.rb reshard problem
Redis 跟 redis-trib.rb 遷移工具有版本不相容, 這邊紀錄解決過程.
Redis 版本問題
We also used redis-cluster ver3.0.6, but redis.trib.rb reshard did not work as 3.0.6 MIGRATE command returns an ASK response. redis.trib.rb reshard would always fail, and nodes.conf would be corrupted at that time. This problem has been fixed in 3.0.7. In redis-cluster ver 3.0.7, redsi-trib.rb works fine at all.
在做slot轉移時,碰到異常,網路上說v3.0.6會出現這錯誤,需要做升級. 之後決定升級到4.0版本, 下面為升級過程.
1# 碰到error,先做下面加入ARRAY
2# W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
3sudo vim /etc/mdadm/mdadm.conf
4# add line : ARRAY <ignore> devices=/dev/sda
5
6sudo add-apt-repository ppa:chris-lea/redis-server
7sudo apt-get update
8sudo apt-get upgrade redis-server
9# 裡面有個選擇
10# Y保留正在運行的服務,並將redis.conf複製成redis.blk.conf
11# N終止服務,並直接將新的設定檔覆蓋redis.conf
Redis 釋出版本 4.0.8
官方釋出版本 4.0.8, 但 apt 套件安裝工具並未更新的這麼即時. 所以選擇自行編譯原始碼來安裝 redis-cli 4.0.8.
1wget -c http://download.redis.io/releases/redis-4.0.8.tar.gz
2tar -xvf redis-4.0.8.tar.gz
3cd redis-4.0.8
4mv redis-4.0.8 /etc/
5make
6sudo make install
7cd utils/
8sudo ./install_server.sh
9sudo systemctl status redis
10redis-cli -v
gem 版本問題
在做 reshard 的 slot 遷移時碰到錯誤 [ERR] Calling MIGRATE: ERR Syntax error, try CLIENT (LIST | KILL | GETNAME | SETNAME | PAUSE | REPLY)
Fix:
Just installing an earlier version of redis.rb fixes the issue. This worked for me: gem install redis -v 3.3.3
1# install redis.rb
2sudo gem install redis -v 3.3.3
3
4# list all package
5sudo gem list |grep redis
6
7# uninstall old version of redis.rb
8sudo gem uninstall redis --version 4.0.1
其他指令
1# 加入slave節點
2./redis-trib.rb add-node --slave --master-id 38ad774c7edaff3e93cf1a07926cd00312b93db7 10.0.2.12:6380 10.0.2.12:6379