redis哨兵常用命令和監(jiān)控示例詳解
sentinel monitor advertise 192.168.0.5 28001 2
sentinel set advertise client-reconfig-script /etc/redis/reconfig.sh
sentinel flushconfig
sentinel啟動(dòng)后需要手動(dòng)將配置文件對(duì)應(yīng)的調(diào)整為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
查看所有監(jiān)控master及其配置信息
sentinel master monitor_name
查看指定監(jiān)控master及其配置信息
sentinel failover monitor_name
手動(dòng)進(jìn)行swithover切換主從,如果有多個(gè)slave會(huì)選擇哪個(gè)slave做為新的master,待測(cè)試?
sentinel moniotr <name> <ip> <port> <quorum>
添加監(jiān)視的master
sentinel remove monitor_name
將監(jiān)視的為name的master移除監(jiān)視
sentinel set <mastername> [<option> <value>]
修改監(jiān)視的master的一些屬性
down-after-milliseconds 過(guò)了這個(gè)時(shí)間考慮master go down
failover-timeout 刷新故障轉(zhuǎn)移狀態(tài)的最大時(shí)間
parallel-syncs slave同時(shí)reconfigure的個(gè)數(shù)
notification-script 設(shè)置通知腳本
client-reconfig-script 設(shè)置通知腳本
auth-pass 執(zhí)行auth的密碼
quorum 修改master的quorum
sentinel flushconfig
將sentinel信息寫(xiě)入到配置文件中
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" #填寫(xiě)自己正確的機(jī)器人鏈接 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哨兵常用命令和監(jiān)控的詳細(xì)內(nèi)容,更多關(guān)于redis哨兵常用命令的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Java實(shí)現(xiàn)多級(jí)緩存的方法詳解
對(duì)于高并發(fā)系統(tǒng)來(lái)說(shuō),有三個(gè)重要的機(jī)制來(lái)保障其高效運(yùn)行,它們分別是:緩存、限流和熔斷,所以本文就來(lái)和大家探討一下多級(jí)緩存的實(shí)現(xiàn)方法,希望對(duì)大家有所幫助2024-02-02Centos7 Redis主從搭建配置的實(shí)現(xiàn)
這篇文章主要介紹了Centos7 Redis主從搭建配置的實(shí)現(xiàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-06-06如何通過(guò)redis減庫(kù)存的秒殺場(chǎng)景實(shí)現(xiàn)
本文通過(guò)解決秒殺系統(tǒng)中的一個(gè)場(chǎng)景即數(shù)據(jù)預(yù)加載,即把庫(kù)存數(shù)據(jù)事先加載到緩存,然后通過(guò)緩存來(lái)更新庫(kù)存,簡(jiǎn)單介紹了如何通過(guò)redis減庫(kù)存的秒殺場(chǎng)景實(shí)現(xiàn),感興趣的可以了解一下2022-06-06redis中hiredis-API函數(shù)的調(diào)用方法
這篇文章主要介紹了redis中hiredis-API函數(shù)的調(diào)用,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-09-09Redis禁用命令、危險(xiǎn)命令及規(guī)避方法
這篇文章主要介紹了Redis禁用命令、危險(xiǎn)命令及規(guī)避方法,本文介紹了個(gè)非常致命的兩個(gè)命令以及用配置文件禁用這些命令的方法,需要的朋友可以參考下2015-06-06基于Redis實(shí)現(xiàn)分布式鎖的方法(lua腳本版)
這篇文章主要介紹了基于Redis實(shí)現(xiàn)分布式鎖的方法(lua腳本版),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-05-05基于Redis實(shí)現(xiàn)分布式單號(hào)及分布式ID(自定義規(guī)則生成)
一些業(yè)務(wù)背景下,業(yè)務(wù)要求單號(hào)需要有區(qū)分不同的前綴,那么在分布式的架構(gòu)下如何自定義單號(hào)而且還能保證唯一呢?本文就來(lái)詳細(xì)的介紹一下2021-09-09