aod*_*vid 4 redis redis-cluster
我有3台计算机并为Redis集群创建6个节点,我已经在几个月前成功创建了它,但是现在已删除,我尽力修复它,但是它不起作用,因此我清理所有数据并从零开始重新创建它,当我使用以下命令创建集群时,它在这里阻塞,并等待节点加入集群,我为此做了一些研究,我清理了数据,一次又一次地记录日志,一次又一次地执行,但是仍然无法正常工作。
redis-trib.rb create --replicas 1 10.2.1.208:6379 10.2.1.208:6380 10.2.1.209:6379 10.2.1.209:6380 10.2.1.15:6379 10.2.1.15:6380
Run Code Online (Sandbox Code Playgroud)
redis-trib.rb create --replicas 1 10.2.1.208:6379 10.2.1.208:6380 10.2.1.209:6379 10.2.1.209:6380 10.2.1.15:6379 10.2.1.15:6380
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
10.2.1.208:6379
10.2.1.209:6379
10.2.1.15:6379
Adding replica 10.2.1.209:6380 to 10.2.1.208:6379
Adding replica 10.2.1.208:6380 to 10.2.1.209:6379
Adding replica 10.2.1.15:6380 to 10.2.1.15:6379
M: 73b3b99bb17de63aa99eaf592376f0a06feb3d66 10.2.1.208:6379
slots:0-5460 (5461 slots) master
S: 05b33ed6691797faaf7ccec1541396472b9d2866 10.2.1.208:6380
replicates f14702ebb1462b313dd7eb4809ec50e30e4eef36
M: f14702ebb1462b313dd7eb4809ec50e30e4eef36 10.2.1.209:6379
slots:5461-10922 (5462 slots) master
S: 3a9f433a8503281b0ddfc6ec69016908735053b8 10.2.1.209:6380
replicates 73b3b99bb17de63aa99eaf592376f0a06feb3d66
M: 2fd97e8842828dba6b425b6a30e764fb06915737 10.2.1.15:6379
slots:10923-16383 (5461 slots) master
S: c46db592d49bc1e9d8b5efb27b9799929c5186a4 10.2.1.15:6380
replicates 2fd97e8842828dba6b425b6a30e764fb06915737
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...........................................................................^C/usr/local/bin/redis-trib.rb:652:in `sleep': Interrupt
from /usr/local/bin/redis-trib.rb:652:in `wait_cluster_join'
from /usr/local/bin/redis-trib.rb:1305:in `create_cluster_cmd'
from /usr/local/bin/redis-trib.rb:1695:in `<main>'
Run Code Online (Sandbox Code Playgroud)
如果这 6 个节点之间没有防火墙问题,您可以检查redis.conf 中的绑定设置。
当然,您应该在 LAN IP 上绑定 redis 服务,但还有一件事:
LAN IP后删除127.0.0.1或将127.0.0.1移到最后!
就像这样:bind 10.2.1.x 127.0.0.1或bind 10.2.1.x
当我在 3 个服务器上的 3 个节点之间创建一个集群时,我遇到了这个问题,等待集群永远加入。这可能是 redis 中的一个错误,至少在 Redis 5.0 中,当您将 127.0.0.1 放在 LAN IP 前面时。
每个Redis群集节点都需要打开两个TCP连接。用于服务客户端的常规Redis TCP端口,例如6379,再加上在数据端口上加上10000所获得的端口,因此在示例中为16379。
第二个高端口用于群集总线,即使用二进制协议的节点到节点通信通道。节点将群集总线用于故障检测,配置更新,故障转移授权等。客户端永远不要尝试与群集总线端口进行通信,而应始终与正常的Redis命令端口进行通信,但是请确保您同时打开防火墙中的两个端口,否则Redis群集节点将无法进行通信。
命令端口和集群总线端口的偏移量是固定的,并且始终为10000。
我使用过AWS,但是没有打开端口16379和16380,这是导致此问题的原因。