当前位置: 首页 > 工具软件 > redis-rb > 使用案例 >

使用"redis-trib.rb"搭建redis5.0集群“redis-trib.rb is not longer available!”问题

昝唯
2023-12-01

网上不少文章都说需要先安装Ruby来执行这个文件以创建集群,如下:

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

但是在执行创建集群的时候会提示:

WARNING: redis-trib.rb is not longer available!You should use redis-cli instead.

很明显,这是一个过时已不再支持的方式,在Redis5.0中创建集群已经使用“redis-cli”来实现。

./redis-cli --cluster create 192.168.0.2:7001 192.168.0.2:7002 192.168.0.2:7003 192.168.0.2:7004 192.168.0.2:7005  192.168.0.2:7006 --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 192.168.0.2:7004 to 192.168.0.2:7001
Adding replica 192.168.0.2:7005 to 192.168.0.2:7002
Adding replica 192.168.0.2:7006 to 192.168.0.2:7003
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 26e122abaece6999ab1b483986ea67fdacd318a8 192.168.0.2:7001
   slots:[0-5460] (5461 slots) master
M: ce0ec5a1b10eca668d9dccf3525a2c508ad8ca16 192.168.0.2:7002
   slots:[5461-10922] (5462 slots) master
M: 0b7743a9971fdd541375a9f3c387c6de7087f619 192.168.0.2:7003
   slots:[10923-16383] (5461 slots) master
S: 9939b985f82e8309521ed4d5746d4bd8e2ccd33b 192.168.0.2:7004
   replicates 0b7743a9971fdd541375a9f3c387c6de7087f619
S: bec194c20d1184e457a2c436d4cdd1db4b750dda 192.168.0.2:7005
   replicates 26e122abaece6999ab1b483986ea67fdacd318a8
S: a85f85b046eb930b2de1c5ef0673c3927e34c804 192.168.0.2:7006
   replicates ce0ec5a1b10eca668d9dccf3525a2c508ad8ca16
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.0.2:7001)
M: 26e122abaece6999ab1b483986ea67fdacd318a8 192.168.0.2:7001
   slots:[0-5460] (5461 slots) master
   13810273933615693825 additional replica(s)
S: 9939b985f82e8309521ed4d5746d4bd8e2ccd33b 192.168.0.2:7004
   slots: (0 slots) slave
   replicates 0b7743a9971fdd541375a9f3c387c6de7087f619
M: ce0ec5a1b10eca668d9dccf3525a2c508ad8ca16 192.168.0.2:7002
   slots:[5461-10922] (5462 slots) master
   597568115676545025 additional replica(s)
S: bec194c20d1184e457a2c436d4cdd1db4b750dda 192.168.0.2:7005
   slots: (0 slots) slave
   replicates 26e122abaece6999ab1b483986ea67fdacd318a8
M: 0b7743a9971fdd541375a9f3c387c6de7087f619 192.168.0.2:7003
   slots:[10923-16383] (5461 slots) master
   597571895247765505 additional replica(s)
S: a85f85b046eb930b2de1c5ef0673c3927e34c804 192.168.0.2:7006
   slots: (0 slots) slave
   replicates ce0ec5a1b10eca668d9dccf3525a2c508ad8ca16
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

 

 类似资料: