redis集群维护脚本

redis集群维护:

一、启动100\101上的6个节点
主机 192.168.199.101 
 
cd  /home/redis-cluster/nodes-7001/  , 执行: nohup /home/redis-4.0.14/src/redis-server    ./redis.conf  &
cd  /home/redis-cluster/nodes-7002/  , 执行:nohup /home/redis-4.0.14/src/redis-server     ./redis.conf  & 
cd  /home/redis-cluster/nodes-7003/  , 执行:nohup /home/redis-4.0.14/src/redis-server     ./redis.conf  &
 
 主机 192.168.199.100 

cd  /home/redis-cluster/nodes-7001/  ,执行: nohup /home/redis-4.0.14/src/redis-server    ./redis.conf  &
cd  /home/redis-cluster/nodes-7002/  ,执行:nohup /home/redis-4.0.14/src/redis-server     ./redis.conf  & 
cd  /home/redis-cluster/nodes-7003/  ,执行:nohup /home/redis-4.0.14/src/redis-server     ./redis.conf  &

二、启动redis集群(注意命令写在一样,不要换行)
 
./redis-trib.rb  create --replicas 1  192.168.199.101:7001  192.168.199.101:7002   192.168.199.101:7003   192.168.199.100:7001  192.168.199.100:7002  192.168.199.100:7003

如启动报错:Node 192.168.199.101:7001 is not empty. 
                   Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0

解决方案:
1、将每个节点下aof、rdb、nodes.conf本地备份文件删除;
2、172.168.63.201:7001> flushdb #清空当前数据库(可省略)
3、之后再执行脚本,成功执行;

参考: https://blog.csdn.net/wudalang_gd/article/details/52153571

 

发布了69 篇原创文章 · 获赞 54 · 访问量 11万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章