CentOS下Redis高可用安装过程(3)

vim /etc/keepalived/scripts/redis_backup.sh

#!/bin/bash C_DATE=`date +"[%Y-%m-%d %H:%M:%S]"` REDISCLI="/opt/redis/bin/redis-cli" LOGFILE="/var/log/keepalived-redis-state.log" echo "${C_DATE} [backup]" >> $LOGFILE #当keepalived配置为"抢占式"时,打开下面注释 #echo "Being slave...." >> $LOGFILE 2>&1 #sleep 15 #延迟15秒待数据被对方同步完成之后再切换主从角色 echo "Run SLAVEOF cmd ..." >> $LOGFILE $REDISCLI SLAVEOF T1 6379 >> $LOGFILE 2>&1 [x] 在Master和Slave上,给监控脚本都加上可执行权限:

chmod +x /etc/keepalived/scripts/*.sh

[x] 启动步骤:

启动Master上的Redis
/opt/redis/bin/startRedis.sh

启动Slave上的Redis
/opt/redis/bin/startRedis.sh

启动Master上的Keepalived
service keepalived start

启动Slave上的Keepalived
service keepalived start

下面关于Redis的文章您也可能喜欢,不妨参考下:

Ubuntu 14.04下Redis安装及简单测试

Redis主从复制基本配置

Redis集群明细文档

Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis

Redis系列-安装部署维护篇

CentOS 6.3安装Redis

Redis安装部署学习笔记

Redis配置文件redis.conf 详解

Redis 的详细介绍请点这里
Redis 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8fc3f3d632349522e38d21de90c486dd.html