【问题标题】:Redis Error condition on socket for SYNC: Connection refusedSYNC 套接字上的 Redis 错误条件:连接被拒绝
【发布时间】:2021-06-25 01:33:58
【问题描述】:

在我的 django 应用程序中使用 celery 和 redis 一切正常,直到我遇到问题。 redis 文件的位置已更改,redis 无法访问它们。查了一下,原来是网上随机攻击造成的,需要加上confg 我添加文件后,它们都工作了一段时间,然后出现了这个问题

1:S 25 Jun 2021 00:48:12.029 # Error condition on socket for SYNC: Connection refused
1:S 25 Jun 2021 00:48:12.901 * Connecting to MASTER 194.38.20.199:8886
1:S 25 Jun 2021 00:48:12.902 * MASTER <-> REPLICA sync started
1:S 25 Jun 2021 00:48:13.034 # Error condition on socket for SYNC: Connection refused
1:S 25 Jun 2021 00:48:13.907 * Connecting to MASTER 194.38.20.199:8886
1:S 25 Jun 2021 00:48:13.908 * MASTER <-> REPLICA sync started
1:S 25 Jun 2021 00:48:14.041 # Error condition on socket for SYNC: Connection refused

当我重建 Redis 容器时,它运行了很短的时间,我遇到了同样的问题

settings.py

CELERY_BROKER_URL = os.environ.get("redis://redis:6379/0")
CELERY_RESULT_BACKEND = os.environ.get("redis://redis:6379/0")

docker-compose.yml

     redis:
      image: 'redis:alpine'
      restart: unless-stopped
      command: redis-server /usr/local/etc/redis/redis.conf
      volumes:
        - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
      ports:
        - '6379:6379'


  celery:
    restart: unless-stopped
    build:
      context: .
      dockerfile: ./docker/backend/Dockerfile_celery
    entrypoint: /app/docker/backend/celery-entrypoint.sh
    environment:
      - some env vars
    depends_on:
      - asgiserver
      - redis

redis.conf

    bind 0.0.0.0 
    protected-mode yes
    rename-command CONFIG ""

【问题讨论】:

  • 您认为这是有人恶意连接您的redis实例并更改设置造成的?
  • 我不是说上面提到的错误是这里提到的错误github.com/redis/redis/issues/3594Error condition on socket for SYNC: Connection refused这个错误我不知道原因
  • 除了您的其他撰写服务之外,您的 redis 实例是否需要可供其他任何东西访问?如果没有,那么您可以将 ports 配置替换为 expose,以便它只能被 compose 网络中的其他服务访问
  • 我不认为此错误是由于有人更改了任何设置,因为我禁用了 CONFIG 命令,即使对于本地用户也是如此。无论如何我会试试这个

标签: python django redis celery


【解决方案1】:

将此设置添加到 slave redis.conf 文件中。

bind 0.0.0.0

【讨论】:

【解决方案2】:

通过将expose 更改为ports 配置解决,如上述Iain Shelvington

   redis:
      image: 'redis:alpine'
      restart: unless-stopped
      command: redis-server /usr/local/etc/redis/redis.conf
      volumes:
        - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
      expose:
        - 6379

【讨论】:

    猜你喜欢
    • 2021-11-28
    • 1970-01-01
    • 2019-12-22
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    • 2015-08-26
    • 2013-12-19
    相关资源
    最近更新 更多