redis集群宿主机故障forget故障节点
cat ./redis_cluster_forget_node.sh
#echo "usage: host port"
nodes_addrs=$(redis-cli -h $1 -p $2 -a password cluster nodes|grep -v handshake| awk '{print $2}')
echo $nodes_addrs
for addr in ${nodes_addrs[@]}; do
host=${addr%:*}
port=${addr#*:}
del_nodeids=$(redis-cli -h $host -p $port -a password cluster nodes|grep -E 'handshake|fail'| awk '{print $1}')
for nodeid in ${del_nodeids[@]}; do
echo $host $port $nodeid
redis-cli -h $host -p $port -a password cluster forget $nodeid
done
done
#password 替换为具体集群密码
#执行参数 为任意一个可用节点 端口 ip
#执行脚本,通知所有集群主节点 遗忘(forget)故障、无法修复节点
sh ./redis_cluster_forget_node.sh 127.0.0.1 6379
#执行成功后,在补齐节点、均衡节点等