首页 > 其他 > 详细

架构师养成记--33.Redis哨兵

时间:2017-03-06 01:30:41      阅读:229      评论:0      收藏:0      [点我收藏+]

  有了主从复制,如果我想想对主从服务器进行监控,在redis2.6后提供了哨兵机制,2.6有哨兵1.0版本,并不稳定。2.8以后的哨兵功能才稳定起来。

  顾名思义,哨兵就是监控Redis系统的运行状况,其主要功能有两点:

  1. 监控主数据库和从数据库是否正常运行
  2. 主数据库出现故障时,可以自动将从数据转换为主数据,实现自动切换

实现步骤:

  1. 在其中一台从服务器配置sentinel.conf
  2. copy文件sentinel.conf文件到/usr/local/redis/etc/中
  3. 修改sentinel.conf文件
        sentinel monitor mymaster 192.168.1.17 6379 1 #名称 ip 端口 选票次数
        sentinel down-after-milliseconds mymaster 5000 #默认1s检测一次,这里配置超时5000毫秒
        sentinel failover-timeout mymater 800000
        sentinel parallel-syncs mymaster 2
        sentinel can-failover mymaster yes
  4. 启动sentinel哨兵 :/usr/local/redis/bin/redis-server /usr/local/redis/etc/sentinel.conf --sentinel &
  5. 查看哨兵相关信息命令
        /usr/local/redis/bin/redis-cli -h 192.168.17 -p 26379 info sentinel
  6. 关闭主服务器查看集群信息
        /usr/local/redis/bin/redis-cli -h 192.168.1.17 -p 6379 shutdown

架构师养成记--33.Redis哨兵

原文:http://www.cnblogs.com/sigm/p/6507545.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!