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 12 Redis
浅谈Redis在直播场景的实践方案
Apr 27 Redis
redis三种高可用方式部署的实现
May 11 Redis
基于Redis实现分布式锁的方法(lua脚本版)
May 12 Redis
redis使用不当导致应用卡死bug的过程解析
Jul 01 Redis
Redis Cluster 集群搭建你会吗
Aug 04 Redis
Redis 的查询很快的原因解析及Redis 如何保证查询的高效
Mar 16 Redis
源码分析Redis中 set 和 sorted set 的使用方法
Mar 22 Redis
Redis如何使用乐观锁(CAS)保证数据一致性
Mar 25 Redis
Grafana可视化监控系统结合SpringBoot使用
Apr 19 Redis
Redis基本数据类型哈希Hash常用操作命令
Jun 01 Redis
Redis Lua脚本实现ip限流示例
Jul 15 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
解析php中curl_multi的应用
2013/07/17 PHP
Yii分页用法实例详解
2014/12/04 PHP
PHP利用正则表达式将相对路径转成绝对路径的方法示例
2017/02/28 PHP
Eclipse PHPEclipse 配置的具体步骤
2017/08/08 PHP
PHP实现自动发送邮件功能代码(qq 邮箱)
2017/08/18 PHP
解决laravel session失效的问题
2019/10/14 PHP
WebGame《逆转裁判》完整版 代码下载(1月24日更新)
2007/01/29 Javascript
jQuery队列控制方法详解queue()/dequeue()/clearQueue()
2010/12/02 Javascript
23个超流行的jQuery相册插件整理分享
2011/04/25 Javascript
js自执行函数的几种不同写法的比较
2012/08/16 Javascript
javascript一元操作符(递增、递减)使用示例
2013/08/07 Javascript
使用requestAnimationFrame实现js动画性能好
2015/08/06 Javascript
[01:31](回顾)杀出重围,决战TI之巅
2014/07/01 DOTA
[01:25]DOTA2自定义游戏灵园鬼域等你踏足
2015/10/30 DOTA
[50:28]2018DOTA2亚洲邀请赛 3.31 小组赛 A组 Newbee vs KG
2018/04/01 DOTA
python爬虫之验证码篇3-滑动验证码识别技术
2019/04/11 Python
Python字符串和正则表达式中的反斜杠('\')问题详解
2019/09/03 Python
python自动分箱,计算woe,iv的实例代码
2019/11/22 Python
python 实现按对象传值
2019/12/26 Python
Pytorch自己加载单通道图片用作数据集训练的实例
2020/01/18 Python
Django后台管理系统的图文使用教学
2020/01/20 Python
tensorflow对图像进行拼接的例子
2020/02/05 Python
在脚本中单独使用django的ORM模型详解
2020/04/01 Python
CSS3点击按钮实现背景渐变动画效果
2016/10/19 HTML / CSS
美国领先的个性化礼品商城:Personalization Mall
2019/07/27 全球购物
法务专员岗位职责
2014/01/02 职场文书
2014年迎新年联欢会活动策划方案
2014/02/26 职场文书
投资协议书范本
2014/04/21 职场文书
国庆节标语大全
2014/10/08 职场文书
2014年学校德育工作总结
2014/12/05 职场文书
离婚协议书范文
2015/01/26 职场文书
2015最新婚礼主持词
2015/06/30 职场文书
优秀创业计划书分享
2019/07/19 职场文书
解决Jenkins集成SonarQube遇到的报错问题
2021/07/15 Java/Android
Nginx实现负载均衡的项目实践
2022/03/18 Servers
Python各协议下socket黏包问题原理
2022/04/12 Python