redis免交互式操作

一:免交互式初始化集群

echo "yes"|redis-cli --cluster create 10.0.0.101:6380 10.0.0.102:6380 10.0.0.103:6380 10.0.0.101:6381 10.0.0.102:6381 10.0.0.103:6381 --cluster-replicas 1

二:免交互式扩容

##删除目录下相关文件并重启
rm -rf /data/redis_6390/*

rm -rf /data/redis_6391/*

redis-server /opt/redis_6391/conf/redis_6391.conf
redis-server /opt/redis_6390/conf/redis_6390.conf

1添加主节点
redis-cli --cluster add-node 10.0.0.101:6390 10.0.0.101:6380

2添加从节点
redis-cli --cluster add-node 10.0.0.101:6391 10.0.0.101:6380 --cluster-slave --cluster-master-id $(redis-cli -c -h 10.0.0.101 -p 6380 cluster nodes|awk ‘/101:6390/{print $1}‘)

3重新分配槽
redis-cli --cluster reshard 10.0.0.101:6380 --cluster-from all --cluster-to $(redis-cli -c -h 10.0.0.101 -p 6380 cluster nodes|awk ‘/101:6390/{print $1}‘) --cluster-slots 4096 --cluster-yes

4查看

redis-cli --cluster info 10.0.0.101:6380

redis免交互式操作

 

 

三:免交互式缩容

迁移槽
redis-cli --cluster rebalance 10.0.0.101:6380 --cluster-weight $(redis-cli -c -h 10.0.0.101 -p 6390 cluster nodes|awk ‘/101:6390/{print $1}‘)=0

##
--cluster-weight $(redis-cli -c -h 10.0.0.101 -p 6390 cluster nodes|awk ‘/101:6390/{print $1}‘)=0 #将下线节点ID设置为0

下线节点
redis-cli --cluster del-node 10.0.0.101:6391 $(redis-cli -c -h 10.0.0.101 -p 6380 cluster nodes|awk ‘/101:6391/{print $1}‘)
redis-cli --cluster del-node 10.0.0.101:6390 $(redis-cli -c -h 10.0.0.101 -p 6380 cluster nodes|awk ‘/101:6390/{print $1}‘)

redis免交互式操作

上一篇:【玩转 WordPress】Serverless 搭建 WordPress = 2 分钟


下一篇:CentOS-7安装GNOME桌面