设为首页 收藏本站
查看: 801|回复: 0

[经验分享] Redis Sentinel--运维管理

[复制链接]

尚未签到

发表于 2018-11-2 08:35:26 | 显示全部楼层 |阅读模式
  上一篇博客我们介绍了Redis Sentinel的安装配置,详情可参考链接:Redis Sentinel--安装配置,今天主要做几个简单的测试Case
  Redis Sentinel API
ping 正常会返回pong  
sentinel masters  返回被监视的所有master及状态
  
sentinel master  返回指定的master及状态
  
setntinel slaves  返回slave及状态
  
sentinel sentinels  返回sentinel及状态
  
sentinel get-master-addr-by-name mymaster 返回现在的master IP和Port
  
sentinel reset * 清理已经移除的master-slave或者sentinel信息
  
sentinel failover 手动执行故障转移
  
sentinel ckquorum  返回(OK 3 usable Sentinels. Quorum and failover authorization can be reached)
  
sentinel flushconfig 如果sentinel.conf丢失,可以使用这个命令生成新的配置文件
  添加Sentinel
  增加一个sentinel很简单,直接配置好sentinel.conf文件,开启一个sentinel即可;
  添加时最好一个添加结束后,再添加另外一个,不要同时添加,可以每隔30秒添加一个sentinel;
  通过SENTINEL MASTER mastername中的num-other-sentinels来查看是否成功添加sentinel。
[root@sht-sgmhadoopdn-04 redis]# cat sentinel.conf  
daemonize yes
  
port 26379
  
logfile "sentinel.log"
  
dir "/usr/local/redis"
  
protected-mode no
  
sentinel myid 79393e76e002cb64db92fb8bcb88d79f2d85a82b
  
sentinel monitor mymaster 172.16.101.59 6379 2
  

  
[root@sht-sgmhadoopdn-04 redis]# src/redis-sentinel sentinel.conf
  

  
172.16.101.54:26379> sentinel master mymaster
  
33) "num-other-sentinels"
  
34) "3"
  移除Sentinel
  删除一个sentinel稍微复杂一点,sentinel永远不会删除一个已经存在过的sentinel,即使它已经与组织失去联系
  Step:
  (1) Stop the Sentinel process of the Sentinel you want to remove.
  (2) Send a SENTINEL RESET * command to all the other Sentinel instances (instead of * you can use the exact master name if you want to reset just a single master). One after the other, waiting at least 30 seconds between instances.
  (3) Check that all the Sentinels agree about the number of Sentinels currently active, by inspecting the output of SENTINEL MASTER mastername of every Sentinel.
[root@sht-sgmhadoopdn-04 redis]# ps -ef|grep redis  
root     17510     1  0 18:34 ?        00:00:03 src/redis-sentinel *:26379 [sentinel]
  
[root@sht-sgmhadoopdn-04 redis]# kill -9 17510
  在其他的每个sentinel节点上,每个隔30s执行
172.16.101.54:26379> sentinel reset *  
172.16.101.55:26379> sentinel reset *
  
172.16.101.56:26379> sentinel reset *
  
172.16.101.54:26379> sentinel master mymaster
  
33) "num-other-sentinels"
  
34) "2"
  移除一个老的master或不可用的slave
[root@sht-sgmhadoopdn-01 redis]# ps -ef|grep redis  
root     15261     1  0 Aug05 ?        00:05:55 src/redis-server 172.16.101.58:6379
  
root     19768 19394  0 21:09 pts/2    00:00:00 grep --color=auto redis
  
[root@sht-sgmhadoopdn-01 redis]# kill -9 15261
  
172.16.101.54:26379> sentinel masters
  
   31) "num-slaves"
  
   32) "2"
  在每个sentinel节点上,每个隔30s执行
172.16.101.54:26379> sentinel reset mymaster  
172.16.101.55:26379> sentinel reset mymaster
  
172.16.101.56:26379> sentinel reset mymaster
  

  
172.16.101.54:26379> sentinel masters
  
   31) "num-slaves"
  
   32) "1"



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-629612-1-1.html 上篇帖子: Redis Sentinel--安装配置 下篇帖子: 如履薄冰 —— Redis懒惰删除的巨大牺牲
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表