这篇文章将为大家详细讲解有关redis哨兵常用命令和监控的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。sentinel monitor advertise 192.168.0.5 28001 2
这篇文章将为大家详细讲解有关redis哨兵常用命令和监控的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
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 yespidfile "/home/redis/sentinel/25000/redis.pid"loglevel noticeprotected-mode yesbind 192.168.100.5logfile "/home/redis/sentinel/25000/redis.log"port 25000dir "/home/redis/sentinel/25000"# Generated by CONFIG REWRITEsentinel myid 0338c4ceb7cf39a8037a22fa17d0f7a76923b5a0sentinel deny-scripts-reconfig nosentinel monitor advertise 192.168.100.5 28001 2sentinel client-reconfig-script advertise /etc/redis/reconfig.shsentinel config-epoch advertise 4sentinel leader-epoch advertise 4sentinel known-replica advertise 192.168.100.6 28001sentinel known-sentinel advertise 192.168.100.7 25000 06f937e1d35496dc66d2899e3b25e286ff91d658sentinel known-sentinel advertise 192.168.100.6 25000 ede86ac0b7d2ff7b532d0e5352ba6e33Dd36670e sentinel monitor mymaster1 192.168.100.6 28002 2sentinel client-reconfig-script mymaster1 /etc/redis/reconfig.shsentinel config-epoch mymaster1 5sentinel leader-epoch mymaster1 1sentinel known-replica mymaster1 192.168.100.5 28002sentinel known-sentinel mymaster1 192.168.100.7 25000 06f937e1d35496dc66d2899e3b25e286ff91d658sentinel known-sentinel mymaster1 192.168.100.6 25000 ede86ac0b7d2ff7b532d0e5352ba6e33dd36670esentinel 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哨兵常用命令和监控的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
--结束END--
本文标题: redis哨兵常用命令和监控的示例分析
本文链接: https://lsjlt.com/news/278202.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0