执行redis-cli命令创建redis集群时报错“Could not connect to Redis at IP:端口: No route to host”
2024-12-20 07:55:52 阅读次数:2
cli,IP,redis,route
问题描述:执行redis-cli命令创建redis集群时报错“Could not connect to Redis at IP:端口: No route to host”,如下所示:
数据库:redis 6.2.6
系统:rhel 7.9
1、异常重现
[root@leo-redis626-a src]# /usr/local/src/redis-6.2.6/src/redis-cli --cluster create --cluster-replicas 1 \
> 192.168.133.100:8001 192.168.133.100:8002 \
> 192.168.133.101:8001 192.168.133.101:8002 \
> 192.168.133.102:8001 192.168.133.102:8002
Could not connect to Redis at 192.168.133.101:8001: No route to host
2、异常原因
该问题是在远程访问redis时出现,原因为服务器防火墙开启导致.
3、解决方案
--此处关闭三台服务器防火墙.
[root@leo-redis626-a src]# systemctl stop firewalld
[root@leo-redis626-a src]# systemctl disable firewalld
[root@leo-redis626-b src]# systemctl stop firewalld
[root@leo-redis626-b src]# systemctl disable firewalld
[root@leo-redis626-c src]# systemctl stop firewalld
[root@leo-redis626-c src]# systemctl disable firewalld
--此后重新执行redis-cli命令创建集群.
[root@leo-redis626-a src]# /usr/local/src/redis-6.2.6/src/redis-cli --cluster create --cluster-replicas 1 \
> 192.168.133.100:8001 192.168.133.100:8002 \
> 192.168.133.101:8001 192.168.133.101:8002 \
> 192.168.133.102:8001 192.168.133.102:8002
>>> 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.133.101:8002 to 192.168.133.100:8001
Adding replica 192.168.133.102:8002 to 192.168.133.101:8001
Adding replica 192.168.133.100:8002 to 192.168.133.102:8001
M: c036f0322c2f8bdd04b1f156f8ff7c29804eb28b 192.168.133.100:8001
slots:[0-5460] (5461 slots) master
S: 6bf0eff5c1874da48cb64df57accac8eaf7aa57d 192.168.133.100:8002
replicates 81c45df99418144728954cda61dfa9fb3e1c5b3f
M: 6d9ca761fc09c83b6a3c2273a36b565c4c525ac3 192.168.133.101:8001
slots:[5461-10922] (5462 slots) master
S: 9f2b2480fecb0a193fdb2feed8c507c7c664cd74 192.168.133.101:8002
replicates c036f0322c2f8bdd04b1f156f8ff7c29804eb28b
M: 81c45df99418144728954cda61dfa9fb3e1c5b3f 192.168.133.102:8001
slots:[10923-16383] (5461 slots) master
S: 5d9ff4989ef75877c6683ece2cc39f22fa4160e6 192.168.133.102:8002
replicates 6d9ca761fc09c83b6a3c2273a36b565c4c525ac3
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.133.100:8001)
M: c036f0322c2f8bdd04b1f156f8ff7c29804eb28b 192.168.133.100:8001
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 5d9ff4989ef75877c6683ece2cc39f22fa4160e6 192.168.133.102:8002
slots: (0 slots) slave
replicates 6d9ca761fc09c83b6a3c2273a36b565c4c525ac3
S: 6bf0eff5c1874da48cb64df57accac8eaf7aa57d 192.168.133.100:8002
slots: (0 slots) slave
replicates 81c45df99418144728954cda61dfa9fb3e1c5b3f
M: 6d9ca761fc09c83b6a3c2273a36b565c4c525ac3 192.168.133.101:8001
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
M: 81c45df99418144728954cda61dfa9fb3e1c5b3f 192.168.133.102:8001
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: 9f2b2480fecb0a193fdb2feed8c507c7c664cd74 192.168.133.101:8002
slots: (0 slots) slave
replicates c036f0322c2f8bdd04b1f156f8ff7c29804eb28b
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
说明:如上所示,redis集群成功创建.
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/u_12991611/6181364,作者:Liujun_Deng,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:最大的 String 字符长度是多少?