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>
具体含义:
normal
replica
pubsub
因此我们可以将client-output-buffer-limit replica 256mb 64mb 60
作出简单调整,重启Redis服务之后解决这个问题。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。