# Could not connect to Redis No route to host
点击查看
- 一般是防火墙问题,关闭每个节点的防火墙即可
[root@summer script]# /usr/local/bin/redis-cli --cluster create 192.168.0.68:27000 192.168.0.68:27001 192.168.0.186:27000 192.168.0.186:27001 192.168.0.90:27000 192.168.0.90:27001 --cluster-replicas 1
Could not connect to Redis at 192.168.0.90:27000: No route to host
[root@summer script]# systemctl stop firewalld.service
[root@summer script]# /usr/local/bin/redis-cli --cluster create 192.168.0.68:27000 192.168.0.68:27001 192.168.0.186:27000 192.168.0.186:27001 192.168.0.90:27000 192.168.0.90:27001 --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.186:27001 to 192.168.0.68:27000
Adding replica 192.168.0.90:27001 to 192.168.0.186:27000
Adding replica 192.168.0.68:27001 to 192.168.0.90:27000
M: db9f53a88ca58a45c0937ee47a3059351c08be63 192.168.0.68:27000
slots:[0-5460] (5461 slots) master
S: 0b1c24d6db9152c19062a2e1cef5b893d8722e55 192.168.0.68:27001
replicates ec9254a213de1d9c4d17ef2b1208e224b73bd2e2
M: d55bafc8e5e06a17d9987ac50075118988710330 192.168.0.186:27000
slots:[5461-10922] (5462 slots) master
S: 045ca4b6d55fd19f2b77bac013b0fa13e346b1cd 192.168.0.186:27001
replicates db9f53a88ca58a45c0937ee47a3059351c08be63
M: ec9254a213de1d9c4d17ef2b1208e224b73bd2e2 192.168.0.90:27000
slots:[10923-16383] (5461 slots) master
S: 22399be1d3274c8a6494a13f96030ff144e8f8ea 192.168.0.90:27001
replicates d55bafc8e5e06a17d9987ac50075118988710330
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.68:27000)
M: db9f53a88ca58a45c0937ee47a3059351c08be63 192.168.0.68:27000
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 0b1c24d6db9152c19062a2e1cef5b893d8722e55 192.168.0.68:27001
slots: (0 slots) slave
replicates ec9254a213de1d9c4d17ef2b1208e224b73bd2e2
M: ec9254a213de1d9c4d17ef2b1208e224b73bd2e2 192.168.0.90:27000
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
M: d55bafc8e5e06a17d9987ac50075118988710330 192.168.0.186:27000
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
S: 22399be1d3274c8a6494a13f96030ff144e8f8ea 192.168.0.90:27001
slots: (0 slots) slave
replicates d55bafc8e5e06a17d9987ac50075118988710330
S: 045ca4b6d55fd19f2b77bac013b0fa13e346b1cd 192.168.0.186:27001
slots: (0 slots) slave
replicates db9f53a88ca58a45c0937ee47a3059351c08be63
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@summer script]# redis-cli -h 192.168.0.68 -p 27000
192.168.0.68:27000> cluster nodes
0b1c24d6db9152c19062a2e1cef5b893d8722e55 192.168.0.68:27001@37001 slave ec9254a213de1d9c4d17ef2b1208e224b73bd2e2 0 1608806725754 5 connected
ec9254a213de1d9c4d17ef2b1208e224b73bd2e2 192.168.0.90:27000@37000 master - 0 1608806723740 5 connected 10923-16383
d55bafc8e5e06a17d9987ac50075118988710330 192.168.0.186:27000@37000 master - 0 1608806724000 3 connected 5461-10922
22399be1d3274c8a6494a13f96030ff144e8f8ea 192.168.0.90:27001@37001 slave d55bafc8e5e06a17d9987ac50075118988710330 0 1608806722732 6 connected
db9f53a88ca58a45c0937ee47a3059351c08be63 192.168.0.68:27000@37000 myself,master - 0 1608806720000 1 connected 0-5460
045ca4b6d55fd19f2b77bac013b0fa13e346b1cd 192.168.0.186:27001@37001 slave db9f53a88ca58a45c0937ee47a3059351c08be63 0 1608806724747 4 connected
192.168.0.68:27000>
# 37000总线端口未开放
点击查看
- 创建集群时一直显示
Waiting for the cluster to join
- 每个Redis集群中的节点都需要打开两个TCP连接。一个连接用于正常的给Client提供服务,比如6379,还有一个额外的端口(通过在这个端口号上加10000)作为数据端口。如16379,这是一个用二进制协议的点对点通信信道。集群总线(Cluster bus)用于节点的失败侦测、配置更新、故障转移授权,等等。客户端从来都不应该尝试和这些集群总线端口通信,它们只应该和正常的Redis命令端口进行通信。
- 命令端口和集群总线端口的偏移量是10000。
注意,集群中的每个节点都应该可以访问集群总线端口(客户端通信端口 10000)
集群总线用一个不同的二进制协议通信,用于节点之间的数据交换