【问题标题】:Redis Pipe Breaking Down on LinuxLinux 上的 Redis 管道崩溃
【发布时间】:2019-09-02 23:01:16
【问题描述】:

我正在使用带有 Python 的 celery 库来并行处理一些相当大的数据集。但是我运行的每日 cronjob 每隔两三天就中断一次,出现以下错误。

CRITICAL/MainProcess] Unrecoverable error: ResponseError('MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.',)

redis 日志长这样

7633:M 12 Apr 07:56:28.284 * 1 changes in 900 seconds. Saving...
7633:M 12 Apr 07:56:28.288 * Background saving started by pid 9530
9530:C 12 Apr 07:56:28.372 * DB saved on disk
9530:C 12 Apr 07:56:28.373 * RDB: 2 MB of memory used by copy-on-write
7633:M 12 Apr 07:56:28.388 * Background saving terminated with success
7633:M 12 Apr 08:01:29.065 * 10 changes in 300 seconds. Saving...
7633:M 12 Apr 08:01:29.065 # Can't save in background: fork: Cannot allocate memory
7633:M 12 Apr 08:01:35.083 * 10 changes in 300 seconds. Saving...
7633:M 12 Apr 08:01:35.088 * Background saving started by pid 9998
9998:C 12 Apr 08:01:35.099 * DB saved on disk
9998:C 12 Apr 08:01:35.101 * RDB: 2 MB of memory used by copy-on-write
7633:M 12 Apr 08:01:35.188 * Background saving terminated with success

相关系统配置为

  • Python 3.6
  • 芹菜 4.2.1
  • Redis 服务器和 CLI 4.0.9
  • Ubuntu 18.04(仿生)

有趣的是,完全相同的配置和系统在另一台(开发)服务器上运行良好,另一台运行 Ubuntu 16.04。但是生产失败了。请注意,我不是 celery 和 redis 方面的专家,只是在经过大量谷歌搜索和一些教程之后才使代码正常工作。因此,请尽量保持故障排除步骤相对简单。此外,当我在 shell 上 ping redis-cli 时,我得到一个 pong 作为回报,这表明服务器正在运行。

【问题讨论】:

  • 嘿,你能不能也分享一下你的 Redis 日志的尾巴。在最终死亡之前告诉你什么?

标签: python bash redis celery message-queue


【解决方案1】:

您的内存似乎太低了,请看您从 4 月 12 日开始的日志: “无法在后台保存:fork:无法分配内存”。似乎当 REDIS 尝试保存快照时(有关更多详细信息,请参阅here)操作失败,直到它无法恢复。 假设您使用的是大型数据集,可能的解决方案可能是:

  1. 如果可能,为不再需要的数据添加过期时间。更多详情here
  2. 增加内存大小,但如果不断添加数据,它可能会在某个时候爆炸。
  3. 禁用持久性,但是,无法写入快照可能是内存不足的副产品。请记住,REDIS 可能会驱逐某些键,这在某些情况下可能不是理想的情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 2012-05-02
    • 1970-01-01
    • 2013-11-07
    • 1970-01-01
    • 2020-05-08
    相关资源
    最近更新 更多