[英]Redis Error condition on socket for SYNC: Connection refused
Using celery with redis in my django app Everything was working fine until I ran into a problem.在我的 django 应用程序中使用 celery 和 redis 一切正常,直到我遇到问题。 The location of the redis files was changed and redis could not access them.
redis文件的位置被改变,redis无法访问。 After searching, it turns out that this is due to random attacks on the Inte.net, and it is necessary to add confg After I added the file, they both worked fine for a while, and then this problem appeared
查了一下,原来是内网随机攻击造成的,需要添加 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
When I rebuild the Redis container it runs for a very short time and I get the same problem当我重建 Redis 容器时,它运行的时间很短,我遇到了同样的问题
settings.py设置.py
CELERY_BROKER_URL = os.environ.get("redis://redis:6379/0")
CELERY_RESULT_BACKEND = os.environ.get("redis://redis:6379/0")
docker-compose.yml 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 redis.conf
bind 0.0.0.0
protected-mode yes
rename-command CONFIG ""
solved by change ports
config with expose
as Iain Shelvington mentioned above通过上面提到的Iain Shelvington
expose
更改ports
配置来解决
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
将此设置添加到从属<\/strong>redis.conf<\/strong>文件。
bind 0.0.0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.