当前位置:网站首页>Redis 哨兵机制
Redis 哨兵机制
2022-07-04 08:02:00 【Mar丶流年】
文章目录
作用
解决主从模式下,主实例故障后的主从切换(将从实例提升
为主实例),以保证系统可用
监控主从实例运行状态
在主从实例运行的同时,也有一个特殊的redis进程在运行(哨兵)
它负责监控主,从实例的运行状态(心跳检测:在规定时间内响应哨兵)
如果从实例没在规定时间内响应,则将其标记为下线
如果主实例没在规定时间内响应,则开始进行主从切换流程
由于单个哨兵可能由于自身网络波动或者当时主实例压力较大造成超时应答,将主实例误判为下线(主观下线)。从而执行不必要的主从切换逻辑。故一般都将哨兵做成集群,通过少数服从多数来判断主实例是否下线(客观下线)
选主流程
当判断主实例下线后,运行打分机制
1.先将已下线从实例排除
2.将从实例运行期间和主实例断线达到一定次数的节点排除掉
3.判断从实例的优先级(优先级可以通过:slave-priority 配置),优先级高的,打高分
4.比较从库的环形缓冲区的slave_repl_offset(这个参数是用来记录和主实例的复制度差异,当主实例挂掉以后,master_repl_offset 将不会增加,故从实例的slave_repl_offset 越大,就和主实例的差异越小),slave_repl_offset越大,分数越高
5.执行redis的默认规则: runID 越小,分数越高
经过上面的打分过程,选出主以后
哨兵将主的信息告诉其它从实例
从实例通过 replicaof 与新主实例同步
哨兵通知客户端和新主实例连接
边栏推荐
- Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
- PHP session variable passed from form - PHP
- L2-013 red alarm (C language) and relevant knowledge of parallel search
- Convert datetime string to datetime - C in the original time zone
- How to write a summary of the work to promote the implementation of OKR?
- Leetcode 23. 合并K个升序链表
- PCIE知识点-010:PCIE 热插拔资料从哪获取
- Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
- Activiti常見操作數據錶關系
- [real case] how to deal with the failure of message consumption?
猜你喜欢
Blog stop statement
Thesis learning -- time series similarity query method based on extreme point characteristics
[gurobi] establishment of simple model
【性能測試】一文讀懂Jmeter
How to improve your system architecture?
[performance test] read JMeter
Distributed transaction management DTM: the little helper behind "buy buy buy"
Oceanbase is the leader in the magic quadrant of China's database in 2021
With excellent strength, wangchain technology, together with IBM and Huawei, has entered the annual contribution list of "super ledger"!
深入浅出:了解时序数据库 InfluxDB
随机推荐
【性能测试】一文读懂Jmeter
Advanced MySQL: Basics (5-8 Lectures)
L1-024 the day after tomorrow (5 points)
Take you to master the formatter of visual studio code
OKR vs. KPI 一次搞清楚这两大概念!
Amd RX 7000 Series graphics card product line exposure: two generations of core and process mix and match
R language uses cforest function in Party package to build random forest based on conditional inference trees, uses varimp function to check feature importance, and uses table function to calculate co
Convert datetime string to datetime - C in the original time zone
Text processing function sorting in mysql, quick search of collection
L1-023 output gplt (20 points)
L1-030 one gang one (15 points)
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
BUUCTF(3)
Leetcode 146. LRU cache
ZABBIX 5.0 monitoring client
墨者学院-PHPMailer远程命令执行漏洞溯源
Common components of flask
Tri des fonctions de traitement de texte dans MySQL, recherche rapide préférée
System architecture design of circle of friends
Set and modify the page address bar icon favicon ico