redis哨兵模式

参考:http://blog.itpub.net/25583515/viewspace-2645084/

redis replication架构下实现自动故障切换(automatic failover)的技术--Sentinel

一.安装配置
在1个master 1个slave 的环境中加一个sentinel,
进入redis源码安装目录copy sentinel.conf文件
# cd /u01/packages/redis-3.0.6
# cp sentinel.conf   /usr/local/redis/etc/
# vi /usr/local/redis/etc/sentinel.conf
daemonize yes
sentinel monitor mymaster 127.0.0.1 6379 1
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000

 

参数解释:
sentinel monitor mymaster 127.0.0.1 6379 1
指示 Sentinel 去监视一个被命名为 mymaster 的master,可指定为任何名字
Master  IP为127.0.0.1 , 端口号为 6379 ,
这个master判断为失效至少需要 1 个 Sentinel 同意 (只要同意 Sentinel 的数量不达标,自动故障迁移就不会执行)
注意,无论你设置多少个 Sentinel 同意才能判断一个服务器失效, 一个 Sentinel 都需要获得系统中多数(majority) Sentinel 的支持, 才能发起一次自动故障迁移

 

sentinel down-after-milliseconds mymaster 30000
down-after-milliseconds 指定了 Sentinel 认为master已经断线所需的毫秒数

 

sentinel parallel-syncs mymaster 1
parallel-syncs 指定了在执行故障转移时, 最多可以有多少个slave同时对新的master进行同步, 这个数字越小, 完成故障转移所需的时间就越长

 

sentinel failover-timeout mymaster 180000
failover-timeout 指定故障切换允许的毫秒数,超过这个时间,就认为故障切换失败,默认为3分钟

 

启动sentinel
# redis-sentinel /usr/local/redis/etc/sentinel.conf

 

查看状态
# redis-cli -p 26379
127.0.0.1:26379> info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=127.0.0.1:6379,slaves=1,sentinels=1

 

至此,配置sentinel工作完成

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值