Redis3集群无限等待集群加入

标签 redis

我有 2 台服务器,每台服务器有 3 个 redis3 实例。我有一个 cluster-nodes 目录,其中包含每个实例的所有数据。在这里。

cluster-nodes/
|-- 7777
|   |-- db01
|   |  -- nodes-7777.conf
|   -- redis.conf
|-- 7778
|   |-- db02
|   |   -- nodes-7778.conf
|   -- redis.conf
-- 7779
    |-- db03
    |   -- nodes-7779.conf
    -- redis.conf

这是我的配置文件redis.conf7777目录下

pidfile /var/run/redis/redis-7777.pid
port 7777
dir /opt/redis/cluster-nodes/7777/db01/
cluster-enabled yes
cluster-config-file nodes-7777.conf
cluster-node-timeout 15000

当我尝试启动 redis 时,我得到

./redis-trib.rb create --replicas 1 127.0.0.1:7777 127.0.0.1:7778 127.0.0.1:7779 192.168.56.41:7777 192.168.56.41:7778 192.168.56.41:7779
>>> Creating cluster
Connecting to node 127.0.0.1:7777: OK
Connecting to node 127.0.0.1:7778: OK
Connecting to node 127.0.0.1:7779: OK
Connecting to node 192.168.56.41:7777: OK
Connecting to node 192.168.56.41:7778: OK
Connecting to node 192.168.56.41:7779: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7777
192.168.56.41:7777
127.0.0.1:7778
Adding replica 192.168.56.41:7778 to 127.0.0.1:7777
Adding replica 127.0.0.1:7779 to 192.168.56.41:7777
Adding replica 192.168.56.41:7779 to 127.0.0.1:7778
M: 209d68fae9c64855d34972f660232eb96370a669 127.0.0.1:7777
   slots:0-5460 (5461 slots) master
M: 62e2b167a287b94b5154f7b9b0f226345baa81b7 127.0.0.1:7778
   slots:10923-16383 (5461 slots) master
S: 36ed59deceb01788db76abc0c2f22925a27295fc 127.0.0.1:7779
   replicates 2760b5fcc99c6563a7cf8deea159efb012309238
M: 2760b5fcc99c6563a7cf8deea159efb012309238 192.168.56.41:7777
   slots:5461-10922 (5462 slots) master
S: 16bf95ba9cb743c2a3caecaab5c2fd5121d80557 192.168.56.41:7778
   replicates 209d68fae9c64855d34972f660232eb96370a669
S: 30e7a5b4a94b5ff3a09f4809d6fd62edb2279b0e 192.168.56.41:7779
   replicates 62e2b167a287b94b5154f7b9b0f226345baa81b7
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.....................................................................................................................................................................................................................................................................^C./redis-trib.rb:534:in `sleep': Interrupt
    from ./redis-trib.rb:534:in `wait_cluster_join'
    from ./redis-trib.rb:1007:in `create_cluster_cmd'
    from ./redis-trib.rb:1373:in `<main>'

这是第一台服务器上集群节点的输出

62e2b167a287b94b5154f7b9b0f226345baa81b7 127.0.0.1:7778 master - 0 1435144555558 2 connected 10923-16383
36ed59deceb01788db76abc0c2f22925a27295fc 127.0.0.1:7779 master - 0 1435144554554 3 connected
209d68fae9c64855d34972f660232eb96370a669 127.0.0.1:7777 myself,master - 0 0 1 connected 0-5460

这是第二个

16bf95ba9cb743c2a3caecaab5c2fd5121d80557 127.0.0.1:7778 master - 0 1435144648065 5 connected
30e7a5b4a94b5ff3a09f4809d6fd62edb2279b0e 127.0.0.1:7779 master - 0 1435144647057 6 connected
2760b5fcc99c6563a7cf8deea159efb012309238 127.0.0.1:7777 myself,master - 0 0 4 connected 5461-10922

看来都是高手起步?我的配置有问题吗? 谢谢。

附:当我尝试相同的配置并启动一台服务器中的所有实例时,一切正常。

最佳答案

我的问题是我正在使用本地主机地址启动服务,

./redis-trib.rb create --replicas 1 127.0.0.1:7777 127.0.0.1:7778 127.0.0.1:7779 192.168.56.41:7777 192.168.56.41:7778 192.168.56.41:7779

为了修复127.0.0.1应该替换为本地节点的IP地址,即

./redis-trib.rb create --replicas 1 192.168.56.40:7777 192.168.56.40:7778 192.168.56.40:7779 192.168.56.41:7777 192.168.56.41:7778 192.168.56.41:7779

关于Redis3集群无限等待集群加入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31031345/

相关文章:

Redis HSCAN 多重匹配

ruby - 发送给 EventMachine pubsub 订阅者的重复数据

F# 多属性 CLIMutable DataContract

mysql - 规划数据库扩展和架构更改

redis-cli 和文件中的值

node.js - 以二进制形式从 Redis 中获取位图

unix - select、epoll、kqueue 和 evport 之间的根本区别是什么?

基于 Scala 磁盘的 Map

redis - 我对 K8s 中的 redis 不了解的地方

使用 Prometheus 和 Grafana 进行 Redis 监控