参考: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工作完成
584

被折叠的 条评论
为什么被折叠?



