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 相关文章推荐
Redis5之后版本的高可用集群搭建的实现
Apr 27 Redis
redis 限制内存使用大小的实现
May 08 Redis
Redis Cluster 字段模糊匹配及删除
May 27 Redis
Redis基于Bitmap实现用户签到功能
Jun 20 Redis
Redis字典实现、Hash键冲突及渐进式rehash详解
Sep 04 Redis
redis中lua脚本使用教程
Nov 01 Redis
分布式Redis Cluster集群搭建与Redis基本用法
Feb 24 Redis
Redis安装使用RedisJSON模块的方法
Mar 23 Redis
解决 Redis 秒杀超卖场景的高并发
Apr 12 Redis
Redis如何实现验证码发送 以及限制每日发送次数
Apr 18 Redis
Redis keys命令的具体使用
Jun 05 Redis
一文教你快速生成MySQL数据库关系图
Jun 28 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
一个目录遍历函数
2006/10/09 PHP
PHP备份数据库生成SQL文件并下载的函数代码
2012/02/05 PHP
修改ThinkPHP缓存为Memcache的方法
2014/06/25 PHP
destoon文章模块调用企业会员资料的方法
2014/08/22 PHP
PHP使用mysqldump命令导出数据库
2015/04/14 PHP
php实现将上传word文件转为html的方法
2015/06/03 PHP
学习thinkphp5.0验证类使用方法
2017/11/16 PHP
php实现mysql连接池效果实现代码
2018/01/25 PHP
tp5(thinkPHP5)框架数据库Db增删改查常见操作总结
2019/01/10 PHP
fix-ie5.js扩展在IE5下不能使用的几个方法
2007/08/20 Javascript
JS是否可以跨文件同时控制多个iframe页面的应用技巧
2007/12/16 Javascript
jQuery中each()方法用法实例
2014/12/27 Javascript
JQuery限制复选框checkbox可选中个数的方法
2015/04/20 Javascript
AngularJS 实现按需异步加载实例代码
2015/10/18 Javascript
轻松实现js图片预览功能
2016/01/18 Javascript
手机软键盘弹出时影响布局的解决方法
2016/12/15 Javascript
vue打包后显示空白正确处理方法
2017/11/01 Javascript
Intellij IDEA搭建vue-cli项目的方法步骤
2018/10/20 Javascript
vue19 组建 Vue.extend component、组件模版、动态组件 的实例代码
2019/04/04 Javascript
深入学习js函数的隐式参数 arguments 和 this
2019/06/24 Javascript
LayUI switch 开关监听 获取属性值、更改状态的方法
2019/09/21 Javascript
JS实现网站楼层导航效果代码实例
2020/06/16 Javascript
小程序选项卡以及swiper套用(跨页面)
2020/06/19 Javascript
Vue页面跳转传递参数及接收方式
2020/09/09 Javascript
原生JS实现相邻月份日历
2020/10/13 Javascript
[58:35]OG vs EG 2019国际邀请赛淘汰赛 胜者组 BO3 第二场 8.22
2019/09/05 DOTA
Python基于checksum计算文件是否相同的方法
2015/07/09 Python
python2.7实现邮件发送功能
2018/12/12 Python
python/golang实现循环链表的示例代码
2020/09/14 Python
芬兰设计商店美国:Finnish Design Shop US
2019/03/25 全球购物
网络公司美工设计工作个人的自我评价
2013/11/03 职场文书
口腔医学技术应届生求职信
2013/11/09 职场文书
部门活动策划方案
2014/08/16 职场文书
作风建设剖析材料
2014/10/06 职场文书
详解JS WebSocket断开原因和心跳机制
2021/05/07 Javascript
Python面向对象之内置函数相关知识总结
2021/06/24 Python