【Redis】slaveof 报错 Background transfer error

发布时间:2020-08-16 16:19:19 作者:神谕丶
来源:ITPUB博客 阅读:180
在slave上执行slaveof到master上,迟迟未成功。
检查master的redis进程日志输出如下:

  1. 427:S 03 May 20:32:07.320 * Slave 10.9.95.71:6379 asks for synchronization
  2. 427:S 03 May 20:32:07.320 * Unable to partial resync with slave $slaveip:6379 for lack of backlog (Slave request was: 5974421660).
  3. 427:S 03 May 20:32:07.320 * Delay next BGSAVE for SYNC
  4. 427:S 03 May 20:32:13.350 * Starting BGSAVE for SYNC with target: slaves sockets
  5. 427:S 03 May 20:32:14.333 * Background RDB transfer started by pid 478
  6. 427:S 03 May 20:35:04.136 # Connection with slave $slaveip lost.
  7. 427:S 03 May 20:35:04.912 # Background transfer error

手动通过stat检查了一下rdb文件,确认bgsave成功。
报错也显示为transfer error,大致判定为rdb文件在transfer到slave的时候报错。
 
google了一下发现应该是client-output-buffer-limit设置过小。
 
〇 client-output-buffer-limit 
在文档中指出,该参数用于限制client缓冲区的限制。
redis的client被分为三种类型:normal、slave、pubsub。
normal:正常的客户端并包括MONITOR客户端
slave:slave客户端
pubsub:pub/sub客户端
 
其设置方式为:
client-output-buffer-limit [class] [hard limit] [soft limit] [soft seconds]
[class]为client的类型。
[hard limit]硬限制,即超过[hard limit]值的缓冲区客户端会被强制中断。
[soft limit] [soft seconds]为软限制,即持续[soft seconds]时间内,超过[soft limit]的缓冲区客户端会被强制中断。
 
当然,默认情况下普通client不受限制(设置为0),因为如果以推送的方式(不询问),在请求之后才接收到数据,那么只有异步客户端可能会创建一个请求数据的速度超过其读取速度的情况。

而slave和pubsub client有一个默认限制,因为他们以推送的方式接收数据。

此处将slave的hard limit设置为32G。
 
config set client-output-buffer-limit "normal 0 0 0 slave 34359738368 268435456 600 pubsub 33554432 8388608 60" 

重新slaveof后,观察info replication和主库redis进程日志,创建复制成功:

  1. 427:S 03 May 21:41:16.962 * Slave $slaveip:6379 asks for synchronization
  2. 427:S 03 May 21:41:16.984 * Full resync requested by slave $slaveip:6379
  3. 427:S 03 May 21:41:16.984 * Delay next BGSAVE for SYNC
  4. 427:S 03 May 21:41:22.712 * Starting BGSAVE for SYNC with target: slaves sockets
  5. 427:S 03 May 21:41:23.679 * Background RDB transfer started by pid 568
  6. 568:C 03 May 21:51:14.107 * RDB: xxxxx MB of memory used by copy-on-write
  7. 427:S 03 May 21:51:15.012 * Background RDB transfer terminated with success
  8. 427:S 03 May 21:51:15.012 # Slave $slaveip:6379 correctly received the streamed RDB file.
  9. 427:S 03 May 21:51:15.012 * Streamed RDB transfer with slave $slaveip:6379 succeeded (socket). Waiting for REPLCONF ACK from slave to enable streaming

复制建立好后,将client-output-buffer-limit改为默认值。



作者微信公众号:
【Redis】slaveof 报错 Background transfer error




推荐阅读:
  1. redis 配置文件说明
  2. Redis 配置

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

background redis error

上一篇:疫情阻击战AI显身手 安企如何添油加力?

下一篇:【DG】利用闪回数据库(flashback)修复Failover后的DG环境

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》