记一次redis3.2.5集群创建失败的解决办法
先说一下情况,三台机器:A机器:192.168.1.35 7001/7002
B机器:192.168.1.36 7001/7002
C机器:192.168.1.37 7001/7002
之前创建集群成功过,但是因为点问题,我重新创建,但是反复创建都是失败,后来发现是我用gem升级了redis包导致
过程还原,大致如下:
创建集群:
# /usr/local/src/redis-3.2.5/src/redis-trib.rb create --replicas 1 192.168.1.35:7001 192.168.1.35:7002 192.168.1.36:7001 192.168.1.36:7002 192.168.1.37:7001 192.168.1.37:7002
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.37:7001
192.168.1.36:7001
192.168.1.35:7001
Adding replica 192.168.1.36:7002 to 192.168.1.37:7001
Adding replica 192.168.1.37:7002 to 192.168.1.36:7001
Adding replica 192.168.1.35:7002 to 192.168.1.35:7001
M: 651f5f10e6159a55e2be407a6da765a618aeaaa7 192.168.1.35:7001
slots:10923-16383 (5461 slots) master
S: 89f64adc4d0dfeb5928ce6b1a1cff8af96864b9d 192.168.1.35:7002
replicates 651f5f10e6159a55e2be407a6da765a618aeaaa7
M: deb9c8aa14d16cb81d8e9ea5a4c46acc1e87923b 192.168.1.36:7001
slots:5461-10922 (5462 slots) master
S: 6accdb55478019a64999a8db7e9c86b06d655613 192.168.1.36:7002
replicates 89d0d5d77d5d34acc46cb1723ecbb1884d646863
M: 89d0d5d77d5d34acc46cb1723ecbb1884d646863 192.168.1.37:7001
slots:0-5460 (5461 slots) master
S: c8adcd9c3e95d0b59fa004404281241298332cf8 192.168.1.37:7002
replicates deb9c8aa14d16cb81d8e9ea5a4c46acc1e87923b
Can I set the above configuration? (type 'yes' to accept): yes
/usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/connection/ruby.rb:111:in `_write_to_socket': Connection timed out (Redis::TimeoutError)
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/connection/ruby.rb:131:in `write'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/connection/ruby.rb:130:in `loop'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/connection/ruby.rb:130:in `write'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/connection/ruby.rb:374:in `write'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:271:in `write'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:250:in `io'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:269:in `write'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:228:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:222:in `each'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:222:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:367:in `ensure_connected'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:221:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:306:in `logging'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:220:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis/client.rb:120:in `call'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis.rb:2705:in `method_missing'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis.rb:58:in `synchronize'
from /usr/lib/ruby/1.8/monitor.rb:242:in `mon_synchronize'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis.rb:58:in `synchronize'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.2/lib/redis.rb:2704:in `method_missing'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:212:in `flush_node_config'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:776:in `flush_nodes_config'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:775:in `each'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:775:in `flush_nodes_config'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:1296:in `create_cluster_cmd'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:1701:in `send'
from /usr/local/src/redis-3.2.5/src/redis-trib.rb:1701
然后就一直报这样的错,打开这个文件 /usr/local/src/redis-3.2.5/src/redis-trib.rb查看,感觉跟用gem升级了redis有关,其实我也没弄明白为啥,反正我升级的卸载了,就好了!
查了一下gem常用命令,然后卸载
# gem uninstall redis --version=3.3.2
ERROR: While executing gem ... (Gem::InstallError)
redis is not installed in GEM_HOME, try:
gem uninstall -i /usr/lib/ruby/gems/1.8 redis
# gem uninstall -i /usr/lib/ruby/gems/1.8 redis
Select gem to uninstall:
1. redis-3.3.1
2. redis-3.3.2
3. All versions
> 2 // 选择卸载高版的
Successfully uninstalled redis-3.3.2
提示卸载成功
查看本机所有已安装的gem包
# gem list
*** LOCAL GEMS ***
redis (3.3.1)
rubygems-update (2.6.7)
然后在次创建集群
# /usr/local/src/redis-3.2.5/src/redis-trib.rb create --replicas 1 192.168.1.35:7001 192.168.1.35:7002 192.168.1.36:7001 192.168.1.36:7002 192.168.1.37:7001 192.168.1.37:7002
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.37:7001
192.168.1.36:7001
192.168.1.35:7001
Adding replica 192.168.1.36:7002 to 192.168.1.37:7001
Adding replica 192.168.1.37:7002 to 192.168.1.36:7001
Adding replica 192.168.1.35:7002 to 192.168.1.35:7001
M: 651f5f10e6159a55e2be407a6da765a618aeaaa7 192.168.1.35:7001
slots:10923-16383 (5461 slots) master
S: 89f64adc4d0dfeb5928ce6b1a1cff8af96864b9d 192.168.1.35:7002
replicates 651f5f10e6159a55e2be407a6da765a618aeaaa7
M: deb9c8aa14d16cb81d8e9ea5a4c46acc1e87923b 192.168.1.36:7001
slots:5461-10922 (5462 slots) master
S: 6accdb55478019a64999a8db7e9c86b06d655613 192.168.1.36:7002
replicates 89d0d5d77d5d34acc46cb1723ecbb1884d646863
M: 89d0d5d77d5d34acc46cb1723ecbb1884d646863 192.168.1.37:7001
slots:0-5460 (5461 slots) master
S: c8adcd9c3e95d0b59fa004404281241298332cf8 192.168.1.37:7002
replicates deb9c8aa14d16cb81d8e9ea5a4c46acc1e87923b
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.1.35:7001)
M: 651f5f10e6159a55e2be407a6da765a618aeaaa7 192.168.1.35:7001
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: 89f64adc4d0dfeb5928ce6b1a1cff8af96864b9d 192.168.1.35:7002
slots: (0 slots) slave
replicates 651f5f10e6159a55e2be407a6da765a618aeaaa7
S: 6accdb55478019a64999a8db7e9c86b06d655613 192.168.1.36:7002
slots: (0 slots) slave
replicates 89d0d5d77d5d34acc46cb1723ecbb1884d646863
S: c8adcd9c3e95d0b59fa004404281241298332cf8 192.168.1.37:7002
slots: (0 slots) slave
replicates deb9c8aa14d16cb81d8e9ea5a4c46acc1e87923b
M: deb9c8aa14d16cb81d8e9ea5a4c46acc1e87923b 192.168.1.36:7001
slots:5461-10922 (5462 slots) master
1 additional replica(s)
M: 89d0d5d77d5d34acc46cb1723ecbb1884d646863 192.168.1.37:7001
slots:0-5460 (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.
好了,这次创建成功!大周六,因为升级了一个gem包,折腾了半天!我发现,有时老时反复搞一个东西时,一直弄出来时,可以放一放,出去走走或换点别的事,等会在来做,灵感就来了,哈哈!
评论