Invalid configuration for cluster creation.Redis Cluster requires at least 3 master nodes.

前提:

跟着网上的教程创建好6个进程分别是7001-7006,并且安装好高版本的ruby。创建集群时输入如下命令:

./bin/redis-trib.rb create --replicas 192.168.132.100:7001 192.168.132.100:7002 192.168.132.100:7003 192.168.132.100:7004 192.168.132.100:7005 192.168.132.100:7006

报错:

*** ERROR: Invalid configuration for cluster creation.
*** Redis Cluster requires at least 3 master nodes.
*** This is not possible with 5 nodes and 192 replicas per node.
*** At least 579 nodes are required.

错误原因

1、replicas和参数都没有加,当前所有结点默认都是master结点 ,结点数不足报错。

2、只加了replicas没加参数,当前所有结点默认都是master结点,结点数不足报错。

错误解析:

  1. 错误说当前集群创建是无效的。Redis集群创建时需要至少3个主节点。对于每个节点有5个节点和192个副本,这是不可能的。至少需要579个节点。
  2. 原来 replicas后面是要加一个数字作为参数,表示一个主结点几个从结点,例如我当前是总共6个节点,3个主节点,剩下的3个都是从结点,所以我只能每个主结点分配一个从结点,所以参数的值为1,当然假如我总结点数有9个结点也可是每个主节点分配2个从结点。
  3. replicas的作用让redis自动地分配主从。

正确姿势:

./bin/redis-trib.rb create --replicas 1 192.168.132.100:7001 192.168.132.100:7002 192.168.132.100:7003 192.168.132.100:7004 192.168.132.100:7005 192.168.132.100:7006

结果:

>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.132.100:7001
192.168.132.100:7002
192.168.132.100:7003
Adding replica 192.168.132.100:7005 to 192.168.132.100:7001
Adding replica 192.168.132.100:7006 to 192.168.132.100:7002
Adding replica 192.168.132.100:7004 to 192.168.132.100:7003
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 8c99e9495e6ce41f9f6c65c89db98c51e485baa9 192.168.132.100:7001
   slots:0-5460 (5461 slots) master
M: 6b4dd9d548bd137b6a3fa9f0c2141f07ade6735f 192.168.132.100:7002
   slots:5461-10922 (5462 slots) master
M: 66c2fc4287156eff85be2f509c7d93b262ef5c59 192.168.132.100:7003
   slots:10923-16383 (5461 slots) master
S: 100ea728a4fa57b7e3987f951073fbdd05cbb18d 192.168.132.100:7004
   replicates 6b4dd9d548bd137b6a3fa9f0c2141f07ade6735f
S: ab0e58a60488e5bbf4f19f666ea2de0c9c5aed58 192.168.132.100:7005
   replicates 66c2fc4287156eff85be2f509c7d93b262ef5c59
S: d66beb82f594d62872e5f8b57939b762bbc79904 192.168.132.100:7006
   replicates 8c99e9495e6ce41f9f6c65c89db98c51e485baa9
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 192.168.132.100:7001)
M: 8c99e9495e6ce41f9f6c65c89db98c51e485baa9 192.168.132.100:7001
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
M: 6b4dd9d548bd137b6a3fa9f0c2141f07ade6735f 192.168.132.100:7002
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 100ea728a4fa57b7e3987f951073fbdd05cbb18d 192.168.132.100:7004
   slots: (0 slots) slave
   replicates 6b4dd9d548bd137b6a3fa9f0c2141f07ade6735f
S: d66beb82f594d62872e5f8b57939b762bbc79904 192.168.132.100:7006
   slots: (0 slots) slave
   replicates 8c99e9495e6ce41f9f6c65c89db98c51e485baa9
S: ab0e58a60488e5bbf4f19f666ea2de0c9c5aed58 192.168.132.100:7005
   slots: (0 slots) slave
   replicates 66c2fc4287156eff85be2f509c7d93b262ef5c59
M: 66c2fc4287156eff85be2f509c7d93b262ef5c59 192.168.132.100:7003
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
发布了46 篇原创文章 · 获赞 75 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_38875300/article/details/96733239
今日推荐