线上预警主从中断: 查看线上复制信息:

# Replication
role:slave
master_host:master_host
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:1
slave_repl_offset:1
master_sync_left_bytes:713983940
master_sync_last_io_seconds_ago:0
master_link_down_since_seconds:248
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

状态为DOWN.主从失败,查看主节点相关日志

[374] 15 Oct 16:41:28.146 # Connection with slave 10.72.26.55:6379 lost.
[374] 15 Oct 16:41:28.999 * Slave asks for synchronization
[374] 15 Oct 16:41:28.999 * Unable to partial resync with the slave for lack of backlog (Slave request was: 152340118946214).
[374] 15 Oct 16:41:28.999 * Starting BGSAVE for SYNC
[374] 15 Oct 16:41:29.447 * Background saving started by pid 11357
[11357] 15 Oct 16:41:57.325 * DB saved on disk
[11357] 15 Oct 16:41:57.555 * RDB: 231 MB of memory used by copy-on-write
[374] 15 Oct 16:41:57.980 * Background saving terminated with success
[374] 15 Oct 16:42:31.739 * Synchronization with slave succeeded
[374] 15 Oct 16:43:01.021 # Client id=6082455 addr=slave_host:55308 fd=329 name= age=93 idle=1 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=10657 omem=2504780296 events=rw cmd=replconf scheduled to be closed ASAP for overcoming of output buffer limits.

查看从节点日志:

[372] 15 Oct 16:43:01.141 # Connection with master lost.
[372] 15 Oct 16:43:01.141 * Caching the disconnected master state.
[372] 15 Oct 16:43:01.213 * Connecting to MASTER masterhost:6379
[372] 15 Oct 16:43:01.213 * MASTER <-> SLAVE sync started
[372] 15 Oct 16:43:01.213 * Non blocking connect for SYNC fired the event.
[372] 15 Oct 16:43:01.572 * Master replied to PING, replication can continue...
[372] 15 Oct 16:43:01.599 * Trying a partial resynchronization (request cbc213a279fde141211f65d436595e4ed64198fa:152342150944513).
[372] 15 Oct 16:43:01.602 * Full resync from master: cbc213a279fde141211f65d436595e4ed64198fa:152344338348685
[372] 15 Oct 16:43:01.602 * Discarding previously cached master state.
[372] 15 Oct 16:43:30.326 * MASTER <-> SLAVE sync: receiving 1308737462 bytes from master
[372] 15 Oct 16:43:59.846 * MASTER <-> SLAVE sync: Flushing old data
[372] 15 Oct 16:44:01.534 * MASTER <-> SLAVE sync: Loading DB in memory
[372] 15 Oct 16:44:22.590 * MASTER <-> SLAVE sync: Finished with success
[372] 15 Oct 16:44:22.600 # Connection with master lost.
[372] 15 Oct 16:44:22.600 * Caching the disconnected master state.

从主库的日志我们可以看到slave的链接由于超过了output buffer limits的设置值所以被强行中断了。看一下redis2.8的自描述文件

# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
# A client is immediately disconnected once the hard limit is reached, or if
# the soft limit is reached and remains reached for the specified number of
# seconds (continuously).
# So for instance if the hard limit is 32 megabytes and the soft limit is
# 16 megabytes / 10 seconds, the client will get disconnected immediately
# if the size of the output buffers reach 32 megabytes, but will also get
# disconnected if the client reaches 16 megabytes and continuously overcomes
# the limit for 10 seconds.
#
# By default normal clients are not limited because they don't receive data
# without asking (in a push way), but just after a request, so only
# asynchronous clients may create a scenario where data is requested faster
# than it can read.
#
# Instead there is a default limit for pubsub and slave clients, since
# subscribers and slaves receive data in a push fashion.
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

我们主要看slave的限制:

256mb 是一个硬性限制,当output-buffer的大小大于256mb之后就会断开连接
64mb 60 是一个条件限制,当output-buffer的大小大于64mb并且超过了60秒的时候就会断开连接

当我们链接暴增,数据量大的情况下默认参数已经不能满足主从同步,从库会不停的向主库发起同步,主库就会不停的bgsave,发送文件给从库,这样就会造成一个死循环。我们必须依据从库的使用来调整client-output-buffer-limit slave 的值。调整以后就可以正常同步了。

redis主从中断异常处理的更多相关文章

  1. redis集群主从中断,报io过高 不错

    问题原因:1.由于这个集群redis操作非常频繁,1分钟操作数据达到1-2G,所有自动aof非常频繁,主从复制打包rdb也非常频繁,之前配置已经无法满足要求报异常如下6943:M 19 Jul 20: ...

  2. Redis 主从配置和参数详解

    安装redis 下载redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解压redis tar -xvf redis-.ta ...

  3. Redis主从是否生效的特殊测试方法

    Redis主从的特殊测试方法 配置主从 Redis的主从设定,相较于MySQL的主从,配置起来非常简单,不必像MySQL数据库一样手动记录bin log的位置再配置,但又可以像MySQL一样,一主带多 ...

  4. 关于redis主从|哨兵|集群模式

    关于redis主从.哨兵.集群的介绍网上很多,这里就不赘述了. 一.主从 通过持久化功能,Redis保证了即使在服务器重启的情况下也不会损失(或少量损失)数据,因为持久化会把内存中数据保存到硬盘上,重 ...

  5. Redis主从同步要深入理解?一篇文章足矣!

    前言: 今天想和大家分享有关 Redis 主从同步(也称「复制」)的内容. 我们知道,当有多台 Redis 服务器时,肯定就有一台主服务器和多台从服务器.一般来说,主服务器进行写操作,从服务器进行读操 ...

  6. 一文让你明白Redis主从同步

    今天想和大家分享有关 Redis 主从同步(也称「复制」)的内容. 我们知道,当有多台 Redis 服务器时,肯定就有一台主服务器和多台从服务器.一般来说,主服务器进行写操作,从服务器进行读操作. 那 ...

  7. redis主从|哨兵|集群模式

    关于redis主从.哨兵.集群的介绍网上很多,这里就不赘述了. 一.主从 通过持久化功能,Redis保证了即使在服务器重启的情况下也不会损失(或少量损失)数据,因为持久化会把内存中数据保存到硬盘上,重 ...

  8. redis(二)集群 redis-cluster & redis主从同步

    参考文档: http://geek.csdn.net/news/detail/200023 redis主从复制:https://blog.csdn.net/imxiangzi/article/deta ...

  9. Redis主从,集群部署及迁移

    工作中有时会遇到需要把原Redis集群下线,迁移到另一个新的Redis集群的需求(如机房迁移,Redis上云等原因).此时原Redis中的数据需要如何操作才可顺利迁移到一个新的Redis集群呢? 本节 ...

随机推荐

  1. 磁盘性能指标--IOPS与吞吐量

    磁盘性能指标--IOPS----------------------------------------------------------        IOPS (Input/Output Per ...

  2. 001 centos7中的安装

    以前学习过centos6.4的安装使用,然后新使用centos7,发现有些修改配置变化了,记录一下. 1.修改主机名 查看主机名: 修改: 二:ip的固定 1.参考文章 https://www.jia ...

  3. Python之Django之views中视图代码重复查询的优化

    Django框架中views视图中如果多个函数都有同样的查询语句,例如: allcategory = Category.objects.all() remen = Article.objects.fi ...

  4. shell编程系列17--文本处理三剑客之awk动作中的表达式用法

    shell编程系列17--文本处理三剑客之awk动作中的表达式用法 awk动作表达式中的算数运算符 awk动作中的表达式用法总结: 运算符 含义 + 加 - 减 * 乘 / 除 % 模 ^或** 乘方 ...

  5. Python3基础 print 格式化输出 %f %d 保留浮点数的位数 整数的位数不够零来凑

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  6. 003——angular 组件 以及组件里面的模板

    创建组件: ng g component components/news 一.创建 angualr 组件................................................ ...

  7. 算法习题---5.3字典(Uva10815)

    一:题目 给出一段英文,里面包含一些单词,空格和标点,单词不区分大小写,默认都为小写.按照字典序输出这些单词(这些单词不能有重复,字母全部变成小写) (一)样例输入 Adventures in Dis ...

  8. 【Tomcat】Tomcat 配置开机启动

    参考:[Linux]开机自动启动脚本 环境:Linux环境(CentOS 7.4) 步骤 1.在/etc/rc.d/rc.local文件底部,添加内容: # apache-tomcat- /data/ ...

  9. ANSI转义序列

    http://ascii-table.com/ansi-escape-sequences.php 制作控制台程序时, 要实现一些特殊效果, 需要了解一下 [ANSI转义序列] . ANSI转义序列是一 ...

  10. RabbitMQ 入门教程(PHP版) 使用rabbitmq-delayed-message-exchange插件实现延迟功能

    延迟任务应用场景 场景一:物联网系统经常会遇到向终端下发命令,如果命令一段时间没有应答,就需要设置成超时. 场景二:订单下单之后30分钟后,如果用户没有付钱,则系统自动取消订单. 场景三:过1分钟给新 ...