首页>>帮助中心>>香港VPS的redis集群宕机后怎么重启

香港VPS的redis集群宕机后怎么重启

2023/5/24 614次

香港VPS的redis集群宕机后重启的示例:

centos下的redis无数据启动和持久化重启脚本:

1.redis_clear_restart.sh,代码:

for p in `ps -ef|grep /usr/local/bin/redis-server | awk '{print $2"_"$3}'`

do

a=`echo $p |awk -F _ '{print $1}'`

b=`echo $p |awk -F _ '{print $2}'`

if [ $b == "1" ]; then

echo "kill -9 $a `kill -9 $a` "

fi

done

echo "rm -rf appendonly_*.aof dump_*.rdb nodes-2000*.conf"

rm -rf appendonly_*.aof dump_*.rdb nodes-2000*.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20000.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20001.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20002.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20003.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20004.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20005.conf

/usr/local/bin/redis-cli -a 123456 --cluster create --cluster-replicas 1 127.0.0.1:20000 127.0.0.1:20001 127.0.0.1:20002 127.0.0.1:20003 127.0.0.1:20004 127.0.0.1:20005 <F

yes

EOF

2.redis_dump_restart.sh,代码:

for p in `ps -ef|grep /usr/local/bin/redis-server | awk '{print $2"_"$3}'`

do

a=`echo $p |awk -F _ '{print $1}'`

b=`echo $p |awk -F _ '{print $2}'`

if [ $b == "1" ]; then

echo "kill -9 $a `kill -9 $a` "

fi

done

echo "rm -rf appendonly_*.aof dump_*.rdb nodes-2000*.conf"

rm -rf appendonly_*.aof dump_*.rdb nodes-2000*.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20000.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20001.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20002.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20003.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20004.conf

/usr/local/bin/redis-server /home/sysusr/redis/redis-cluster/redis-20005.conf

/usr/local/bin/redis-cli -a 123456 --cluster check 127.0.0.1:20000

/usr/local/bin/redis-cli -a 123456 --cluster check 127.0.0.1:20001

/usr/local/bin/redis-cli -a 123456 --cluster check 127.0.0.1:20002

/usr/local/bin/redis-cli -a 123456 --cluster check 127.0.0.1:20003

/usr/local/bin/redis-cli -a 123456 --cluster check 127.0.0.1:20004

/usr/local/bin/redis-cli -a 123456 --cluster check 127.0.0.1:20005

一诺网络香港免备案专区,提供「香港增强VPS」和「香港特惠VPS」两种类型的高可用弹性计算服务,搭载新一代英特尔®至强®铂金处理器,接入CN2低延时高速回国带宽线路,网络访问顺滑、流畅。机房网络架构采用了BGP协议的解决方案可提供多线路互联融合网络,使得不同网络运营商线路的用户都能通过最佳路由实现快速访问。香港云VPS低至29元/月,购买链接:https://www.enuoidc.com/vps.html?typeid=2

版权声明

    声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们996811936@qq.com进行处理。