(Docker compose)Redis Error condition on socket for SYNC:连接被拒绝

8fsztsew  于 2023-08-02  发布在  Redis
关注(0)|答案(1)|浏览(122)

类似的问题
我想知道为什么我可以通过将ports配置更改为expose来解决这个问题?如果Redis示例需要可访问,则需要在docker compose文件中设置端口。
在这种情况下,如何解决问题:SYNC套接字上的错误条件:拒绝连接?
redis.conf

# Redis configuration file
bind 0.0.0.0
databases 16
# Disable replication
replicaof no one
# Other Redis settings...
save ""
appendonly no

字符串
Docker编写文件:

api:
    build:
      context: apps/api
      dockerfile: apps/api/Dockerfile
    env_file:
      - apps/api/.env.development
    ports:
      - 12710:3000
    networks:
      - api_network
    depends_on:
      - redis

  redis:
    image: redis
    restart: always
    expose:
      - 6379
    volumes:
      - redis:/data
      - ./data/redis/redis.conf:/usr/local/etc/redis/redis.conf
    command: redis-server /usr/local/etc/redis/redis.conf
    networks:
      - api_network

networks:
  api_network:
volumes:
  redis:


如果我添加ports: - 6379:6379,Redis会正常工作一段时间,然后出现这个问题:

app-redis-1  | 1:S 24 Apr 2023 13:59:22.947 * Before turning into a replica, using my own master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
app-redis-1  | 1:S 24 Apr 2023 13:59:22.947 * Connecting to MASTER 194.38.20.225:8886
app-redis-1  | 1:S 24 Apr 2023 13:59:22.950 * MASTER <-> REPLICA sync started
app-redis-1  | 1:S 24 Apr 2023 13:59:22.950 * REPLICAOF 194.38.20.225:8886 enabled (user request from 'id=33 addr=109.237.96.251:34384 laddr=172.18.0.2:6379 fd=8 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=47 qbuf-free=20427 argv-mem=24 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22320 events=r cmd=slaveof user=default redir=-1 resp=2')
app-redis-1  | 1:S 24 Apr 2023 13:59:23.186 # Error condition on socket for SYNC: Connection refused
app-redis-1  | 1:S 24 Apr 2023 13:59:23.436 * Connecting to MASTER 194.38.20.225:8886
app-redis-1  | 1:S 24 Apr 2023 13:59:23.436 * MASTER <-> REPLICA sync started
app-redis-1  | 1:S 24 Apr 2023 13:59:23.673 # Error condition on socket for SYNC: Connection refused
app-redis-1  | 1:S 24 Apr 2023 13:59:24.440 * Connecting to MASTER 194.38.20.225:8886
app-redis-1  | 1:S 24 Apr 2023 13:59:24.440 * MASTER <-> REPLICA sync started

6yt4nkrj

6yt4nkrj1#

redis-slave:
        image: redis:latest
        container_name: redis-slave
        ports:
            - "8001:8001"
        volumes:
            - /path/redis-slave.conf:/etc/redis/redis.conf
        command: redis-server /etc/redis/redis.conf --replicaof master 6379
        links: 
            - redis-master:master

字符串
redis-master是主容器,使用docker可以通过内网找到ipaddress的链接

docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' redis-master

相关问题