当前位置:网站首页>Redis集群(主从)脑裂及解决方案
Redis集群(主从)脑裂及解决方案
2022-07-05 11:31:00 【我们一直在路上】
1 集群脑裂
redis 的集群脑裂是指因为网络问题,导致 redis master 节点跟 redis slave 节点和 sentinel 集群处于不同的网络分区,此时因为 sentinel 集群无法感知到 master 的存在,所以将 slave 节点提升为master 节点。此时存在两个不同的 master 节点,就像一个大脑分裂成了两个。
集群脑裂问题中,如果客户端还在基于原来的 master 节点继续写入数据,那么新的 master 节点将无法同步这些数据,当网络问题解决之后,sentinel 集群将原先的master节点降为 slave 节点,此时再从新的 master 中同步数据,将会造成大量的数据丢失。
2 解决方案
redis的配置文件中,存在两个参数:
min-slaves-to-write 3 min-slaves-max-lag 10
- 第一个参数表示连接到master的最少slave数量
- 第二个参数表示slave连接到master的最大延迟时间
按照上面的配置,要求至少3个slave节点,且数据复制和同步的延迟不能超过10秒,否则的话master就会拒绝写请求,配置了这两个参数之后,如果发生集群脑裂,原先的master节点接收到客户端的写入请求会拒绝,就可以减少数据同步之后的数据丢失。
注意:较新版本的 redis.conf 文件中的参数变成了
min-replicas-to-write 3 min-replicas-max-lag 10
redis中的异步复制情况下的数据丢失问题也能使用这两个参数。
</article>
边栏推荐
- 2048游戏逻辑
- SLAM 01. Modeling of human recognition Environment & path
- 2048 game logic
- Redis如何实现多可用区?
- 龙蜥社区第九次运营委员会会议顺利召开
- Cron expression (seven subexpressions)
- COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
- In the last process before the use of the risk control model, 80% of children's shoes are trampled here
- 阻止瀏覽器後退操作
- Implementation of array hash function in PHP
猜你喜欢
Harbor image warehouse construction
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
[crawler] Charles unknown error
How to introduce devsecops into enterprises?
11.(地图数据篇)OSM数据如何下载使用
中非 钻石副石怎么镶嵌,才能既安全又好看?
Codeforces Round #804 (Div. 2)
7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
Three suggestions for purchasing small spacing LED display
技术管理进阶——什么是管理者之体力、脑力、心力
随机推荐
基于Lucene3.5.0怎样从TokenStream获得Token
c#操作xml文件
-26374 and -26377 errors during coneroller execution
FreeRTOS 中 RISC-V-Qemu-virt_GCC 的调度时机
Evolution of multi-objective sorting model for classified tab commodity flow
Pytorch training process was interrupted
AutoCAD -- mask command, how to use CAD to locally enlarge drawings
Codeforces Round #804 (Div. 2)
Technology sharing | common interface protocol analysis
2048游戏逻辑
Unity Xlua MonoProxy Mono代理类
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
Stop saying that microservices can solve all problems!
CDGA|数据治理不得不坚持的六个原则
In the last process before the use of the risk control model, 80% of children's shoes are trampled here
【Office】Excel中IF函数的8种用法
技术分享 | 常见接口协议解析
以交互方式安装ESXi 6.0
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
XML parsing