redis哨兵常用命令和监控示例详解


Posted in Redis onMay 27, 2021

sentinel monitor advertise 192.168.0.5 28001 2
sentinel set advertise client-reconfig-script /etc/redis/reconfig.sh
sentinel flushconfig

sentinel启动后需要手动将配置文件对应的调整为sentinel deny-scripts-reconfig no,否则不支持命令行runtime修改client-reconfig-script
# SECURITY
#
# By default SENTINEL SET will not be able to change the notification-script
# and client-reconfig-script at runtime. This avoids a trivial security issue
# where clients can set the script to anything and trigger a failover in order
# to get the program executed.

#sentinel deny-scripts-reconfig yes

role命令
查看sentinel monitor的master names名字

sentinel masters
查看所有监控master及其配置信息

sentinel master monitor_name
查看指定监控master及其配置信息

sentinel failover monitor_name
手动进行swithover切换主从,如果有多个slave会选择哪个slave做为新的master,待测试?

sentinel moniotr <name> <ip> <port> <quorum>
添加监视的master

sentinel remove monitor_name
将监视的为name的master移除监视

sentinel set <mastername> [<option> <value>]
修改监视的master的一些属性
down-after-milliseconds 过了这个时间考虑master go down
failover-timeout 刷新故障转移状态的最大时间
parallel-syncs slave同时reconfigure的个数
notification-script 设置通知脚本
client-reconfig-script 设置通知脚本
auth-pass 执行auth的密码
quorum 修改master的quorum

sentinel flushconfig

将sentinel信息写入到配置文件中

sentinel配置文件示例:

daemonize yes
pidfile "/home/redis/sentinel/25000/redis.pid"
loglevel notice
protected-mode yes
bind 192.168.100.5
logfile "/home/redis/sentinel/25000/redis.log"
port 25000
dir "/home/redis/sentinel/25000"
# Generated by CONFIG REWRITE
sentinel myid 0338c4ceb7cf39a8037a22fa17d0f7a76923b5a0
sentinel deny-scripts-reconfig no
sentinel monitor advertise 192.168.100.5 28001 2
sentinel client-reconfig-script advertise /etc/redis/reconfig.sh
sentinel config-epoch advertise 4
sentinel leader-epoch advertise 4
sentinel known-replica advertise 192.168.100.6 28001
sentinel known-sentinel advertise 192.168.100.7 25000 06f937e1d35496dc66d2899e3b25e286ff91d658
sentinel known-sentinel advertise 192.168.100.6 25000 ede86ac0b7d2ff7b532d0e5352ba6e33dd36670e
 
sentinel monitor mymaster1 192.168.100.6 28002 2
sentinel client-reconfig-script mymaster1 /etc/redis/reconfig.sh
sentinel config-epoch mymaster1 5
sentinel leader-epoch mymaster1 1
sentinel known-replica mymaster1 192.168.100.5 28002
sentinel known-sentinel mymaster1 192.168.100.7 25000 06f937e1d35496dc66d2899e3b25e286ff91d658
sentinel known-sentinel mymaster1 192.168.100.6 25000 ede86ac0b7d2ff7b532d0e5352ba6e33dd36670e
sentinel current-epoch 5

sentinel client-reconfig-script脚本示例

#!/bin/bash
 
check_time=$(date +"%F-%T")
master_name="$1"
from_ip="$4"
from_port="$5"
to_ip="$6"
to_port="$7"
 
 
#填写自己正确的机器人链接
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxx' \
   -H 'Content-Type: application/json' \
   -d '
   {
        "msgtype": "text",
        "text": {
            "content": "【'$check_time' '$master_name' redis failover】\nfrom\n'$from_ip:$from_port'\nto\n'$to_ip:$to_port'",
            "mentioned_list":["xiaodongl"]
        }
   }'

以上就是redis哨兵常用命令和监控的详细内容,更多关于redis哨兵常用命令的资料请关注三水点靠木其它相关文章!

Redis 相关文章推荐
redis配置文件中常用配置详解
Apr 14 Redis
使用Redis实现秒杀功能的简单方法
May 08 Redis
Redis延迟队列和分布式延迟队列的简答实现
May 13 Redis
详解Redis集群搭建的三种方式
May 31 Redis
SpringBoot 集成Redis 过程
Jun 02 Redis
springboot使用Redis作缓存使用入门教程
Jul 25 Redis
Redis如何实现分布式锁
Aug 23 Redis
Jedis操作Redis实现模拟验证码发送功能
Sep 25 Redis
详解Redis在SpringBoot工程中的综合应用
Oct 16 Redis
面试分析分布式架构Redis热点key大Value解决方案
Mar 13 Redis
Redis入门基础常用操作命令整理
Jun 01 Redis
Redis全局ID生成器的实现
Jun 05 Redis
Java Socket实现Redis客户端的详细说明
May 26 #Redis
redis实现共同好友的思路详解
详解Redis瘦身指南
May 26 #Redis
Redis高级数据类型Hyperloglog、Bitmap的使用
May 24 #Redis
redis实现排行榜功能
May 24 #Redis
分布式锁为什么要选择Zookeeper而不是Redis?看完这篇你就明白了
May 21 #Redis
Redis 配置文件重要属性的具体使用
May 20 #Redis
You might like
2020年4月新番动漫目录 官方宣布4月播出的作品一览
2020/03/08 日漫
两种php实现图片上传的方法
2016/01/22 PHP
PHP中如何防止外部恶意提交调用ajax接口
2016/04/11 PHP
jQuery示例收集
2010/11/05 Javascript
Microsfot .NET Framework4.0框架 安装失败的解决方法
2013/08/14 Javascript
jQuery插件jQuery-JSONP开发ajax调用使用注意事项
2013/11/22 Javascript
jquery判断小数点两位和自动删除小数两位后的数字
2014/03/19 Javascript
5款JavaScript代码压缩工具推荐
2014/07/07 Javascript
常用原生js自定义函数总结
2016/11/20 Javascript
jQuery Tree Multiselect使用详解
2017/05/02 jQuery
angularjs+bootstrap实现自定义分页的实例代码
2017/06/19 Javascript
微信小程序wx.request拦截器使用详解
2019/07/09 Javascript
Vue 动态路由的实现及 Springsecurity 按钮级别的权限控制
2019/09/05 Javascript
Python爬虫框架Scrapy实战之批量抓取招聘信息
2015/08/07 Python
解决Python出现_warn_unsafe_extraction问题的方法
2016/03/24 Python
Python遍历目录中的所有文件的方法
2016/07/08 Python
Python实现获取磁盘剩余空间的2种方法
2017/06/07 Python
Python使用sklearn实现的各种回归算法示例
2019/07/04 Python
python输出数组中指定元素的所有索引示例
2019/12/06 Python
TFRecord格式存储数据与队列读取实例
2020/01/21 Python
TensorFlow自定义损失函数来预测商品销售量
2020/02/05 Python
如何编写python的daemon程序
2021/01/07 Python
迪士尼西班牙官方网上商店:ShopDisney西班牙
2020/02/02 全球购物
英国领先的餐饮折扣俱乐部:Gourmet Society
2020/07/26 全球购物
Unix如何在一行中运行多个命令
2015/05/29 面试题
高级方案规划工程师岗位职责
2013/11/29 职场文书
史学专业毕业生求职信
2014/05/09 职场文书
2014企业领导班子四风对照检查材料思想汇报
2014/09/17 职场文书
公司委托书格式范文
2014/10/09 职场文书
工作失误检讨书范文
2015/01/26 职场文书
婚宴邀请函
2015/01/30 职场文书
毕业实习感受与体会
2015/05/26 职场文书
妇产科护理心得体会
2016/01/22 职场文书
网络安全倡议书(3篇)
2019/09/18 职场文书
详解MySQL集群搭建
2021/05/26 MySQL
详解JavaScript中Arguments对象用途
2021/08/30 Javascript