redis-cluster-从永久挂起的远程机器到现有集群的添加节点从属

时间:2018-10-25 00:26:12

标签: redis redis-cluster

我试图将一个地址上有8个副本的群集连接到另一个地址上的现有群集。

副本服务器全部以群集模式运行。

当我尝试执行任一操作时:

./redis-trib.rb add-node --slave REPLICA_IP:6380 MASTER_IP:6380

./redis-cli --cluster add-node REPLICA_IP:6380 MASTER_IP:6380 --cluster-slave

我得到相同的结果;

Waiting for the cluster to join...........................

无限期挂起。

两台服务器肯定可以互相看到,我可以从任一台服务器连接到任何相关的Redis节点(副本服务器或主服务器)。发现/通信端口(16830等)也都是开放且可联系的。这些命令的输出还表明已找到集群,因为它显示了每个节点及其正确的节点ID。

这是两个add-node命令的完整输出:

>>> Adding node REPLICA_IP:6380 to cluster MASTER_IP:6380
>>> Performing Cluster Check (using node MASTER_IP:6380)
M: 043a5fa4fdca929d3d87f953906dc7c1f030926c MASTER_IP:6380
   slots:[0-2047] (2048 slots) master
M: e104777d31630eef11a01e41c7d3a6c98e14ab64 MASTER_IP:6386
   slots:[12288-14335] (2048 slots) master
M: 9c807d6f57a9634adcdf75fa1943c32c985bda1c MASTER_IP:6384
   slots:[8192-10239] (2048 slots) master
M: 0f7ec07deff97ca23fe67109da2365d916ff1a67 MASTER_IP:6383
   slots:[6144-8191] (2048 slots) master
M: 974e8b4051b7a8e33db62ba7ad62c7e54abe699d MASTER_IP:6382
   slots:[4096-6143] (2048 slots) master
M: b647bb9d732ff2ee83b097ffb8b49fb2bccd366f MASTER_IP:6387
   slots:[14336-16383] (2048 slots) master
M: a86ac1d5e783bed133b153e471fdd970c17c6af5 MASTER_IP:6381
   slots:[2048-4095] (2048 slots) master
M: 6f859b03f86eded0188ba493063c5c2114d7c11f MASTER_IP:6385
   slots:[10240-12287] (2048 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Automatically selected master MASTER_IP:6380
>>> Send CLUSTER MEET to node REPLICA_IP:6380 to make it join the cluster.
Waiting for the cluster to join
............................

如果手动运行CLUSTER MEET,然后CLUSTER NODES,我可以暂时看到状态为“握手”的另一个节点,状态为“断开”,然后它消失了。它显示的节点ID与实际的ID不同。

2 个答案:

答案 0 :(得分:2)

我知道了:

使用tcpdump,我确认两台服务器都在redis服务器端口和握手端口上相互通信,而add-slave命令始终挂起。

但在我拥有的每个节点的redis配置中:

bind 0.0.0.0

但是在主服务器和副本服务器上,配置必须读取:

bind SERVER_IP

为了使CLUSTER MEET正常工作。

答案 1 :(得分:1)

在我的情况下,每个节点都具有相同的MMID,因此它一直在等待。

我在做什么,我配置了一个EC2 ami,并从中启动了3台服务器 AMI和使用用户数据,我确实通过外壳重新配置了redis集群 脚本并重新启动服务器,每个服务器都有与之相同的ID。 我创建了AMI的服务器。

M: b29aff425cdfa94272cdce1816939a9692c71e12 10.0.134.109:6379
   slots:[0-5460] (5461 slots) master
M: b29aff425cdfa94272cdce1816939a9692c71e12 10.0.175.235:6379
   slots:[5461-10922] (5462 slots) master
M: b29aff425cdfa94272cdce1816939a9692c71e12 10.0.155.10:6379
   slots:[10923-16383] (5461 slots) master
Can I set the above configuration? (type 'yes' to accept): yes

因此,在每个节点上我都做了CLUSTER RESET HARD;它有效

out of cluster

Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
M: 36a129fab85d2aed310bfd7cc141035de420fa92 10.0.134.109:6379
   slots:[0-5460] (5461 slots) master
M: 773bc76e903da27efbd965bca26366fa20878397 10.0.175.235:6379
   slots:[5461-10922] (5462 slots) master
M: 10a79173d1f7a9c568bdfa3b955b6e133d2dceaa 10.0.155.10:6379
   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
..
>>> Performing Cluster Check (using node 10.0.134.109:6379)
M: 36a129fab85d2aed310bfd7cc141035de420fa92 10.0.134.109:6379
   slots:[0-5460] (5461 slots) master
M: 773bc76e903da27efbd965bca26366fa20878397 10.0.175.235:6379
   slots:[5461-10922] (5462 slots) master
M: 10a79173d1f7a9c568bdfa3b955b6e133d2dceaa 10.0.155.10:6379
   slots:[10923-16383] (5461 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.