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 27 Redis
详解redis分布式锁的这些坑
May 19 Redis
浅谈Redis位图(Bitmap)及Redis二进制中的问题
Jul 15 Redis
Redis分布式锁Redlock的实现
Aug 07 Redis
Redis入门教程详解
Aug 30 Redis
Redis字典实现、Hash键冲突及渐进式rehash详解
Sep 04 Redis
linux下安装redis图文详细步骤
Dec 04 Redis
redis调用二维码时的不断刷新排查分析
Apr 01 Redis
Redis 限流器
May 15 Redis
Redis基本数据类型哈希Hash常用操作命令
Jun 01 Redis
Redis+AOP+自定义注解实现限流
Jun 28 Redis
Redis实战之Lettuce的使用技巧详解
Dec 24 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+mysql扎实个人基本功
2008/03/27 PHP
php项目中百度 UEditor 简单安装调试和调用
2015/07/15 PHP
Yii调试查看执行SQL语句的方法
2016/07/15 PHP
php常用字符串查找函数strstr()与strpos()实例分析
2019/06/21 PHP
gearman中任务的优先级和返回状态实例分析
2020/02/27 PHP
一个加载js文件的小脚本
2007/06/28 Javascript
gridview生成时如何去掉style属性中的border-collapse
2014/09/30 Javascript
JSON字符串和对象之间的转换详解
2015/05/26 Javascript
jquery自定义表单验证插件
2016/10/12 Javascript
jQuery使用bind函数实现绑定多个事件的方法
2017/10/11 jQuery
mui框架 页面无法滚动的解决方法(推荐)
2018/01/25 Javascript
JS几个常用的函数和对象定义与用法示例
2020/01/15 Javascript
用js限制网页只在微信浏览器中打开(或者只能手机端访问)
2020/12/24 Javascript
Vue.js桌面端自定义滚动条组件之美化滚动条VScroll
2020/12/01 Vue.js
vue实现简易的双向数据绑定
2020/12/29 Vue.js
Vue中引入svg图标的两种方式
2021/01/14 Vue.js
[48:27]EG vs Liquid 2018国际邀请赛淘汰赛BO3 第二场 8.25
2018/08/29 DOTA
[27:08]完美世界DOTA2联赛PWL S2 SZ vs Rebirth 第二场 11.21
2020/11/23 DOTA
Python二分法搜索算法实例分析
2015/05/11 Python
Cython编译python为so 代码加密示例
2019/12/23 Python
python topk()函数求最大和最小值实例
2020/04/02 Python
Python3将ipa包中的文件按大小排序
2020/04/17 Python
Python如何使用vars返回对象的属性列表
2020/10/17 Python
Python识别处理照片中的条形码
2020/11/16 Python
HTML文本属性&amp;颜色控制属性的实现
2019/12/17 HTML / CSS
Lulu & Georgia官方网站:购买地毯、家具、抱枕、壁纸、床上用品等
2018/03/19 全球购物
阿联酋最好的手机、电子产品和家用电器网上商店:Eros Digital Home
2020/08/09 全球购物
自荐信范文
2013/12/10 职场文书
法人授权委托书格式
2014/04/08 职场文书
汉语专业毕业生自荐信
2014/07/06 职场文书
党员干部批评与自我批评反四风思想汇报
2014/09/21 职场文书
欢迎词怎么写
2015/01/23 职场文书
财务稽核岗位职责
2015/04/13 职场文书
雾霾停课通知
2015/04/24 职场文书
《槐乡的孩子》教学反思
2016/02/20 职场文书
光之国的四大叛徒:第一贝利亚导致宇宙毁灭,赛文奥特曼在榜
2022/03/18 日漫