Redis集群等待集群加入私有VPC

问题描述

我有3个运行Redis的EC2实例,如下所示:

  • 服务器001:10.0.1.203,端口:6379
  • 服务器002:10.0.1.202,端口:6380
  • 服务器003:10.0.1.190,端口:6381

每个配置文件

# bind 127.0.0.1
protected-mode no
port PORT
pidfile /var/run/redis_PORT.pid
cluster-enabled yes
cluster-config-file nodes-PORT.conf
cluster-node-timeout 15000

我可以通过Redis连接到每个服务器上的每个服务器。

但是当我运行群集创建时,脚本永远不会在Server 001上结束。

root@ip-10-0-1-203:~/redis-stable# redis-cli --cluster create 10.0.1.203:6379 10.0.1.202:6380 10.0.1.190:6381
>>> Performing hash slots allocation on 3 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
M: 4c0b7609e5d906ff58d67ab446bbd9e20833e0db 10.0.1.203:6379
   slots:[0-5460] (5461 slots) master
M: a5dbd72815a1875b58a0cc0fd6a52dc0b76735b7 10.0.1.202:6380
   slots:[5461-10922] (5462 slots) master
M: 14d39c0876a982cadd50f301a3d35715171279c0 10.0.1.190:6381
   slots:[10923-16383] (5461 slots) master
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
....................................................................................................................................................................................................................................................................................................................................

服务器002日志:

44119:M 02 Nov 2020 13:30:03.477 * Ready to accept connections
44119:M 02 Nov 2020 13:30:45.362 # configEpoch set to 0 via CLUSTER RESET HARD
44119:M 02 Nov 2020 13:30:45.362 * Node hard reset,Now I'm a5dbd72815a1875b58a0cc0fd6a52dc0b76735b7
44119:M 02 Nov 2020 13:30:59.352 # configEpoch set to 2 via CLUSTER SET-CONfig-EPOCH 

服务器003日志:

44033:M 02 Nov 2020 13:30:50.695 # configEpoch set to 0 via CLUSTER RESET HARD
44033:M 02 Nov 2020 13:30:50.695 * Node hard reset,Now I'm 14d39c0876a982cadd50f301a3d35715171279c0
44033:M 02 Nov 2020 13:30:59.346 # configEpoch set to 3 via CLUSTER SET-CONfig-EPOCH

配置中缺少某些内容吗?

解决方法

在EC2实例上可能无法访问Redis群集端口。

来自Redis Cluster Specification

每个Redis Cluster节点都有一个额外的TCP端口,用于接收来自其他Redis Cluster节点的传入连接。此端口与用于从客户端接收传入连接的普通TCP端口处于固定偏移量。要获得Redis Cluster端口,应在常规命令端口中添加10000。例如,如果Redis节点正在端口6379上侦听客户端连接,则群集总线端口16379也将打开。