问题:

搭建Redis集群的过程中,执行到cluster create : … 的时候,发现程序发生阻塞,显示:Waiting for the cluster to join 的字样,然后就无休无尽的等待…
搭建Redis集群遇到的问题:Waiting for the cluster to join~~~
遇到这种情况大部分是因为集群总线的端口没有开放!

集群总线
每个Redis集群中的节点都需要打开两个TCP连接。一个连接用于正常的给Client提供服务,比如6379,还有一个额外的端口(通过在这个端口号上加10000)作为数据端口,例如:redis的端口为6379,那么另外一个需要开通的端口是:6379 + 10000, 即需要开启 16379。16379端口用于集群总线,这是一个用二进制协议的点对点通信信道。这个集群总线(Cluster bus)用于节点的失败侦测、配置更新、故障转移授权,等等。

解决方案:
知道了问题所在, 自然就知道如何去解决了, 只需要将开启Redis端口对应的 集群总线端口即可。例如: 6379 + 10000 = 16379。所以开放每个集群节点的客户端端口和集群总线端口才能成功创建集群!

[root@TR src]# ./redis-cli --cluster create 106.14.157.48:6379 49.232.112.117:6381 101.34.253.57:6383 106.14.157.48:6380 49.232.112.117:6382 101.34.253.57:6384 --cluster-replicas 1
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 49.232.112.117:6382 to 106.14.157.48:6379
Adding replica 101.34.253.57:6384 to 49.232.112.117:6381
Adding replica 106.14.157.48:6380 to 101.34.253.57:6383
M: 2d9ab9c1c95c13478758ae6ec45434fdb620688c 106.14.157.48:6379
   slots:[0-5460] (5461 slots) master
M: edd1856f57ffbb50ee5ce690964b5e780118608e 49.232.112.117:6381
   slots:[5461-10922] (5462 slots) master
M: 5998783763f617cc7ff40dd2d55ad0cbce72ea66 101.34.253.57:6383
   slots:[10923-16383] (5461 slots) master
S: f0fdd2cd69c1e37ff510cf990ae381005609fc81 106.14.157.48:6380
   replicates 5998783763f617cc7ff40dd2d55ad0cbce72ea66
S: b2893c8a996c726264096a49b84df367509b9ceb 49.232.112.117:6382
   replicates 2d9ab9c1c95c13478758ae6ec45434fdb620688c
S: 560ef0cd7c6799a12a75c930cb0063cc2d613cb4 101.34.253.57:6384
   replicates edd1856f57ffbb50ee5ce690964b5e780118608e
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

>>> Performing Cluster Check (using node 106.14.157.48:6379)
M: 2d9ab9c1c95c13478758ae6ec45434fdb620688c 106.14.157.48:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: edd1856f57ffbb50ee5ce690964b5e780118608e 49.232.112.117:6381
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: f0fdd2cd69c1e37ff510cf990ae381005609fc81 106.14.157.48:6380
   slots: (0 slots) slave
   replicates 5998783763f617cc7ff40dd2d55ad0cbce72ea66
S: b2893c8a996c726264096a49b84df367509b9ceb 49.232.112.117:6382
   slots: (0 slots) slave
   replicates 2d9ab9c1c95c13478758ae6ec45434fdb620688c
M: 5998783763f617cc7ff40dd2d55ad0cbce72ea66 101.34.253.57:6383
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: 560ef0cd7c6799a12a75c930cb0063cc2d613cb4 101.34.253.57:6384
   slots: (0 slots) slave
   replicates edd1856f57ffbb50ee5ce690964b5e780118608e
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐