当前位置:网站首页>Redis集群主备缓存区满了导致主备频繁倒换
Redis集群主备缓存区满了导致主备频繁倒换
2022-07-17 16:39:00 【zeekling】
问题现象
Redis 频繁进行主备倒换,通过查看主实例的日志:redis.log发现下面报错:
Client id=1317049445 addr=192.168.2.45:8004 fd=40 name= age=314 idle=0 flags=S db=0 sub=0
psub=0 multi=-1 qbuf=0 qbuf-free=32568 obl=0 oll=4430 omem=761143439 events=rw cmd=psync
scheduled to be closed ASAP for overcoming of output buffer limits其中:psync scheduled to be closed ASAP for overcoming of output buffer limits 明显就是问题所在,那是什么问题呢。
解决思路
于是我在源码中搜索了scheduled to be closed ASAP for overcoming of output buffer limits(psync明显是一个命令,就不用在代码里面搜索了)。
于是,我找到了下面代码:
/* If the source client contains a partial response due to client output
* buffer limits, propagate that to the dest rather than copy a partial
* reply. We don't wanna run the risk of copying partial response in case
* for some reason the output limits don't reach the same decision (maybe
* they changed) */
if (src->flags & CLIENT_CLOSE_ASAP) {
sds client = catClientInfoString(sdsempty(),dst);
freeClientAsync(dst);
serverLog(LL_WARNING,"Client %s scheduled to be \
closed ASAP for overcoming of output buffer limits.", client);
sdsfree(client);
return;
}单从代码来看,看不出啥,但是代码上面存在注释,我使用我那四级水平翻译了下,可以看出缓存区满了,于是可以想到可能主备同步的时候可能会限制缓存区大小,并且这个缓存区被占满了。
于是我又在redis.conf中找了缓冲区的相关配置,找到了下面是三个:
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60配置格式为:
client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>具体含义:
- class:我理解就是缓冲区的类型,目前Redis的缓冲区分为三个:
- 普通客户端:
normal - 主备同步:
replica - 发布订阅:
pubsub
- 普通客户端:
- hard limit: 缓冲区大小的硬性限制。当达到这个限制之后,连接就会断开。
- soft limit: 缓冲去大小的软性限制。
- soft seconds: 缓冲区大小达到了(超过)soft limit值的持续时间。
因此我们可以将client-output-buffer-limit replica 256mb 64mb 60作出简单调整,重启Redis服务之后解决这个问题。
边栏推荐
- In 2022, how to choose cross end technology solutions?
- ATT&CK实战系列——红队实战(—)
- Detailed explanation of SQL blind annotation
- Acwing786. 第k个数
- MySQL learning notes - constraints
- Li Hongyi machine learning 1 Introduction of this course
- Leetcode 20. Valid parentheses
- MIHA tour 2023 autumn recruitment officially begins ~ early approval has the opportunity to avoid written examination!
- Pytorch version: yolov4 integrating attention and mobilenet
- Machine learning Assignment 1
猜你喜欢

Acwing4405. 统计子矩阵

psd. JS parsing PSD file

ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec(); Calculate program execution time

超声波传感器(CH101&ch201) - Ⅰ

C # from introduction to mastery Part II: C # basic grammar

脉冲函数、阶跃函数和斜坡函数及脉冲响应

字符串相关函数(二)

数据库每日一题---第25天:银行账户概要 II

MATLAB(4)函数及文件

Example of C language drawing - 20 examples of chromatic diagram
随机推荐
Talk about the redis cache penetration scenario and the corresponding solutions
三分钟了解mysql中主键、外键、非空、唯一、默认约束是什么,以及如何创建表
JS chain call sleep function ------ "autumn trick punch in Chapter 2"
2022-07-07:Spire. Office 7.7.2 for net debuted
My favorite 10 machine learning official account
Li Hongyi machine learning 1 Introduction of this course
How to run SH script file
Linux下MySQL的安装与使用
Hcip fourth day notes
Microcomputer principle and technical interface experiment five basic IO operation temperature control experiment
ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec(); Calculate program execution time
C # from introduction to mastery Part II: C # basic grammar
Acwing785. 快速排序
MyCat2搭建mysql主从分离
Leetcode 239. 滑动窗口最大值
机器学习作业1
第二天实验
What is the relationship between softmax and cross enterprise?
若依excel合并单元格导出ExcelUtils
Mysql-1366 - Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘userName‘ at row 1