运行命令redis cli--cluster call x.x.x.x:6379 keys时出错“*”

wyyhbhjk  于 2021-06-07  发布在  Redis
关注(0)|答案(0)|浏览(452)

我在docker容器上用redis cluster设置了一个aws ec2示例,下面是docker-compose.yml,在我尝试运行命令时启动容器之后 redis-cli --cluster call x.x.x.x:6379 KEYS * 获取错误:

Could not connect to Redis at 172.18.0.12:6381: No route to host
Could not connect to Redis at 172.18.0.11:6380: No route to host
>>> Calling KEYS *
x.x.x.x:6379: backup2

但是,如果我从主机上运行相同的redis cli命令,我就会被释放。

>>> Calling KEYS *
x.x.x.x:6379: backup2
backup3
172.18.0.12:6381: a
172.18.0.11:6380: c

docker-compose.yml码:

version: "3.1"
services:
  redis-master-1:
    build: ./
    ports:
      - 6379:6379
    networks:
      redisnet:
        ipv4_address: 172.18.0.10
    command: sh -c "redis-server /usr/local/redis.conf --port 6379 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000"
  redis-master-2:
    build: ./
    ports:
      - 6380:6379
    networks:
      redisnet:
        ipv4_address: 172.18.0.11
    depends_on:
      - redis-master-1
    command: sh -c "redis-server /usr/local/redis.conf --port 6380 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000"
  redis-master-3:
    build: ./
    ports:
      - 6381:6379
    command: sh -c "redis-server /usr/local/redis.conf --port 6381 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000"
    networks:
      redisnet:
        ipv4_address: 172.18.0.12
    depends_on:
      - redis-master-2
  redis-setup:
    image: ruby
    command: sh -c "gem install redis && wget http://download.redis.io/redis-stable/src/redis-trib.rb && yes yes | ruby redis-trib.rb create --replicas 1 172.18.0.10:6379 172.18.0.11:6380 172.18.0.12:6381 && while sleep 3600; do :; done"
    networks:
      redisnet:
        ipv4_address: 172.18.0.13
    depends_on:
      - redis-master-1
      - redis-master-2
      - redis-master-3
networks:
  redisnet:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.0.0/16**strong text**

dockerfile文件:

FROM redis
COPY clusterconfig.conf /usr/local/redis.conf
CMD ["redis-server", "/usr/local/redis.conf"]

clusterconfig.conf文件:

port 6379
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题