水平擴容和移除節點沒有實際操做過,只作記錄,下次再進行本次實驗性操做:
1.加入新的master
mkdir -p /var/redis/7007
修改配置文件信息 /etc/redis/7007.conf
port 7007
cluster-enabled yes
cluster-config-file /etc/redis-cluster/node-7007.conf
cluster-node-timeout 15000
daemonize yes
pidfile /var/run/redis_7007.pid
dir /var/redis/7007
logfile /var/log/redis/7007.log
bind 192.168.31.227
appendonly yes
啓動腳本 /etc/init.d/redis_7007
redis-trib.rb add-node 192.168.1.107:7007 192.168.1.107:7001
redis-trib check 192.168.1.107:7001node
2.reshared數據,slot從一些master移動到新的master,達到擴容減輕其餘主節點的壓力
redis-trib.rb reshared 192.168.1.107:7001redis
3.加入新的slave
新增一個redis實例,如上192.168.1.105:7008
redis-trib.rb add-node --slave --master-id <master-id> 192.168.1.105:7008 192.168.1.107:7001app
4.刪除node
先用resharding 將數據移到其餘主節點,確保node爲空後才remove
redis-trib.rb del-node 192.168.1.107:7001 <master-id>
2個是1365,1個是1366
當你清空了一個master的hashslot,redis cluster自動將slave掛載到其餘master上去ide