【问题标题】:Using redis with docker-compose: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk将 redis 与 docker-compose 一起使用:MISCONF Redis 配置为保存 RDB 快照,但目前无法持久保存在磁盘上
【发布时间】:2020-05-23 09:55:13
【问题描述】:

我相信这个问题在这里有些答案:MISCONF Redis is configured to save RDB snapshots

我目前正在运行一个 Redis docker 容器,它时不时返回以下错误:

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_1        | 4410:C 06 Feb 2020 23:50:57.045 # Failed opening the RDB file crontab (in server root dir /etc) for saving: Permission denied

这是因为 redis 空间不足吗?我可以做些什么来清理redis吗?我只是使用redis作为消息代理层,所以数据并不是真的需要持久化...

我还看到以下 WARNINGS 从 redis 容器中出现:

# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

我觉得也许这个问题是向 redis/devops 专家请教也许概述使用 docker-compose 配置 redis 的最佳方法的绝佳机会,我目前有:

  redis:
    build:
      context: ./redis
      dockerfile: Dockerfile
    ports:
      - '6379:6379'
    volumes:
        - ./redis.conf:/usr/local/etc/redis/redis.conf
    sysctls:
      net.core.somaxcomm: '511'
    restart: on-failure

如果有更好的事情可以做,那将是惊人的和感激的。

【问题讨论】:

  • 如果 redis 认为它​​的 RDB 文件应该命名为 /etc/crontab,那么事情就搞砸了。
  • 我确定它搞砸了,但是如何 - 它只是 docker-compose 中的标准 redis 设置?
  • 好吧,这里有点危险,但我想说你已经让你的 redis 对互联网开放,并且有人正在连接它并试图使用它来破坏它正在运行的服务器上,通过写入 crontab。看起来他们可能失败了,但您仍有一些安全问题需要处理。
  • 这只是一个 docker-compose 设置,就像数百个教程中给出的那样?
  • 如果有像你这样有名望的人,如果这是你选择的主题,也许会概述如何正确配置 redis 实例......

标签: docker redis


【解决方案1】:

更新: 使用expose 而不是ports,因此该服务仅对链接服务可用

公开端口而不将它们发布到主机 - 它们会 只能被链接的服务访问。只有内部端口可以 指定的。

expose
 - 6379

原答案: 您的 redis 实例可能已对 Internet 开放。您可以使用redis.confbind 127.0.0.1 只允许本地连接。

查看详细解答here

【讨论】:

    猜你喜欢
    • 2018-01-09
    • 2019-01-02
    • 2013-11-21
    • 1970-01-01
    • 2020-06-29
    • 2013-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多