Redis Sentinel--运维管理
admin
2023-02-07 13:40:02
0

上一篇博客我们介绍了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"



相关内容

热门资讯

【第一财经】“全民内蒙古麻将怎... 家人们!今天小编来为大家解答全民内蒙古麻将透视挂怎么安装这个问题咨询软件客服徽9752949的挂在哪...
【第一消息】“四川游戏家园有挂... 有 亲,根据资深记者爆料四川游戏家园是可以开挂的,确实有挂(咨询软件无需...
最新引进“天蝎牛牛辅助器?”(... 有 亲,根据资深记者爆料天蝎牛牛是可以开挂的,确实有挂(咨询软件无需打开...
终于了解“陕西三带辅助器?”(... 终于了解“陕西三带辅助器?”(太坑了原来有挂)您好,陕西三带这个游戏其实有挂的,确实是有挂的,需要了...
今日重大通报“微乐福建麻将到底... 您好:微乐福建麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款...
【第一消息】“欢喜麻将真的有挂... 家人们!今天小编来为大家解答欢喜麻将透视挂怎么安装这个问题咨询软件客服徽9752949的挂在哪里买很...
成都人跨年有多积极:距离零点五... 极目新闻记者 谢茂12月31日晚7时许,位于四川成都交子大道的天府双塔已亮起灯光,与此同时,在塔下道...
终于懂了“新蜜瓜大厅拼三张怎么... 网上科普关于“新蜜瓜大厅拼三张有没有挂”话题很是火热,小编也是针对新蜜瓜大厅拼三张作*弊开挂的方法以...
可装进背包!稚晖君发布首款个人... 深圳商报·读创客户端首席记者 袁静娴 2025年12月31日,久未更新的B站up主稚晖君(本名彭志辉...
破防了?罗永浩与豆包吵架上热搜... 12月30日晚,在上海举办的“罗永浩的十字路口”年度科技创新分享大会上,锤子科技创始人罗永浩与字节跳...