redis\u slave在使用docker compose时无法访问redis\u master

dphi5xsq  于 2021-06-10  发布在  Redis
关注(0)|答案(1)|浏览(373)

我使用docker compose和四个postgres容器一个redis\u主容器和一个redis\u从容器。redis服务器正常启动,但大约每8小时启动一次,从服务器就无法到达主服务器进行复制。docker compose日志显示redis\u master的以下错误日志:

redis_master               | 1:S 15 Jul 2020 11:39:05.338 * Connecting to MASTER UNKNOWN.IP:58270
redis_master               | 1:S 15 Jul 2020 11:39:05.338 * MASTER  REPLICA sync started
redis_master               | 1:S 15 Jul 2020 11:39:05.497 # Error condition on socket for SYNC: Connection refused
redis_master               | 1:S 15 Jul 2020 11:39:06.341 * Connecting to MASTER UNKNOWN.IP:58270
redis_master               | 1:S 15 Jul 2020 11:39:06.341 * MASTER  REPLICA sync started
redis_master               | 1:S 15 Jul 2020 11:39:06.506 # Error condition on socket for SYNC: Connection refused

unknown.ip不是私有ip地址,不是我的服务器ip,也不是访问服务器的任何客户端的ip。该ip地址首先在以下日志中使用:

redis_master               | 1:S 15 Jul 2020 11:37:50.127 * REPLICAOF UNKNOWN.IP:58270 enabled (user request from 'id=525 addr=UNKNOWN.IP:35762 fd=13 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=48 qbuf-free=32720 obl=0 oll=0 omem=0 events=r cmd=slaveof')

这似乎会在尝试与redis服务器交互时触发错误。

WARN  [2020-07-15 13:58:42,036] org.eclipse.jetty.server.HttpChannel: /v1/websocket/
! redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a read only replica.

服务器还受到了一个加密挖掘恶意软件“kdevtmpfsi”的攻击,该软件似乎进入了redis服务器,可能导致了其中一些问题。恶意软件占用了大约400%的cpu和1gb内存。我还没有能够完全摆脱它,我尝试在一个新的服务器上关闭更多的端口,试图阻止恶意软件再次进入进程。关于阻止恶意软件再次入侵有什么建议吗?或者是什么导致了redis复制问题。我的docker compose配置文件取自这个github repo,用于克隆信号应用程序的服务器。我启动docker环境

sudo docker-compose up

我使用redis的所有默认配置。
docker-compose.yml公司

version: '2.2'
services:
  signal_account_database:
    image:          postgres:11
    container_name: postgres_account_database
    restart:        always
    environment:
      POSTGRES_USER:     postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB:       signal
      PGDATA:            /var/lib/postgresql/data/pgdata
    ports:
      - '5431:5432'
    volumes:
      - ./postgres_database:/var/lib/postgresql/data
  signal_keys_database:
    image:          postgres:11
    container_name: postgres_keys_database
    restart:        always
    environment:
      POSTGRES_USER:     postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB:       signal
      PGDATA:            /var/lib/postgresql/data/pgdata
    ports:
      - '5432:5432'
    volumes:
      - ./postgres_keys_database:/var/lib/postgresql/data
  signal_message_database:
    image:          postgres:11
    container_name: postgres_message_database
    restart:        always
    environment:
      POSTGRES_USER:     postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB:       signal
      PGDATA:            /var/lib/postgresql/data/pgdata
    ports:
      - '5433:5432'
    volumes:
      - ./postgres_message_store:/var/lib/postgresql/data
  signal_abuse_database:
    image:          postgres:11
    container_name: postgres_abuse_database
    restart:        always
    environment:
      POSTGRES_USER:     postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB:       signal
      PGDATA:            /var/lib/postgresql/data/pgdata
    ports:
      - '5434:5432'
    volumes:
      - ./postgres_abuse_database:/var/lib/postgresql/data
  redis_main:
    image: redis:5
    container_name: redis_master
    ports:
      - '6379:6379'
    volumes:
      - ./redis_main:/data
  redis_replication:
    image: redis:5
    container_name: redis_slave
    command: redis-server --port 6380
    ports:
      - '6380:6380'
    volumes:
      - ./redis_replication:/data

其他人也有同样的复制问题吗?正在寻找解决此问题的建议

mrphzbgm

mrphzbgm1#

redis_main:
    image: redis:5
    container_name: redis_master
    restart: always
    command: redis-server --port 6379
    ports:
      - '6379:6379'
    volumes:
      - ./redis_main:/data
  redis_replication:
    image: redis:5
    container_name: redis_slave
    command: redis-server --slaveof 127.0.0.1 6379 --port 6380 --slave-announce-ip 127.0.0.1
    ports:
      - '6380:6380'
    volumes:
      - ./redis_replication:/data

  sentinel:
    build: ./sentinel
    container_name: redis_sentinel
    restart: always
    command: redis-sentinel --port 26379
    ports:
      - '26379:26379'
    environment:
      - SENTINEL_NAME=mysentinel
      - HOST_IP=127.0.0.1
    volumes:
      - ./redis_slave:/data

相关问题