我正在将docker-compose与四个postgres容器一起使用redis_master容器和redis_slave容器。 Redis服务器正常启动,但是从站启动后大约每8个小时无法到达主服务器进行复制。 docker-compose日志重复显示以下来自redis_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不是私有(private)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,用于克隆Signal应用程序的服务器。我用以下命令启动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
还有其他人有同样的复制问题吗?寻找有关解决此问题的建议。

最佳答案

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

关于docker - 使用docker-compose时redis_slave无法到达redis_master,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62922782/

10-16 01:47
查看更多