一主二从三哨兵高可用集群启停脚本

①:我们先将 redis6380.conf 复制为 redis6380.conf.bak 备份起来,同时 redis6381.conf,redis6382.conf 也这样做

-rw-r--r-- 1 root root    169 Nov 13 14:27 redis6380.conf
-rw-r--r-- 1 root root    169 Nov 13 13:52 redis6380.conf.bak
-rw-r--r-- 1 root root    168 Nov 13 14:27 redis6381.conf
-rw-r--r-- 1 root root    168 Nov 13 13:53 redis6381.conf.bak
-rw-r--r-- 1 root root    168 Nov 13 14:27 redis6382.conf
-rw-r--r-- 1 root root    168 Nov 13 14:02 redis6382.conf.bak
-rw-r--r-- 1 root root 107512 Nov  7 20:44 redis.conf

②:我们将 sentinel26380.conf 复制为 sentinel26380.conf.bak 备份起来,同时 sentinel26381.conf,sentinel26382.conf 也这样做

-rw-r--r-- 1 root root    767 Nov 13 14:27 sentinel26380.conf
-rw-r--r-- 1 root root    175 Nov 13 14:19 sentinel26380.conf.bak
-rw-r--r-- 1 root root    766 Nov 13 14:27 sentinel26381.conf
-rw-r--r-- 1 root root    171 Nov 13 14:19 sentinel26381.conf.bak
-rw-r--r-- 1 root root    767 Nov 13 14:27 sentinel26382.conf
-rw-r--r-- 1 root root    173 Nov 13 14:19 sentinel26382.conf.bak
-rw-r--r-- 1 root root  14717 Nov 13 14:14 sentinel.conf

③:然后创建脚本文件 vim start-redis-sentinel.sh

写入

#!/bin/bash
/bin/cp -f redis6380.conf.bak redis6380.conf
/bin/cp -f redis6381.conf.bak redis6381.conf
/bin/cp -f redis6382.conf.bak redis6382.conf

redis-server redis6380.conf
redis-server redis6381.conf
redis-server redis6382.conf

redis-cli -p 6381 -a hx801219 slaveof 127.0.0.1 6380
redis-cli -p 6382 -a hx801219 slaveof 127.0.0.1 6380

/bin/cp -f sentinel26380.conf.bak sentinel26380.conf
/bin/cp -f sentinel26381.conf.bak sentinel26381.conf
/bin/cp -f sentinel26382.conf.bak sentinel26382.conf
 
redis-sentinel sentinel26380.conf
redis-sentinel sentinel26381.conf
redis-sentinel sentinel26382.conf

④:然后创建脚本文件 vim shutdown-redis-sentinel.sh

写入

#!/bin/sh
redis-cli -a hx801219 -p 26380 shutdown
redis-cli -a hx801219 -p 26381 shutdown
redis-cli -a hx801219 -p 26382 shutdown
redis-cli -a hx801219 -p 6380 shutdown
redis-cli -a hx801219 -p 6381 shutdown
redis-cli -a hx801219 -p 6382 shutdown

ps -ef|grep redis
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值