創建的過程當中 Ruby 會要求更改 nodes.conf ,就輸入 yes 就能夠了。
輸入yes後 我滿懷期待等到成功的消息。誰知道給我一個無限的waiting?
H:\Tools\cluster>ruby H:\Tools\cluster\redis.trib.rb create --replicas 0 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
>>> Creating cluster
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 5 nodes...
Using 5 masters:
127.0.0.1:7001
127.0.0.1:7002
127.0.0.1:7003
127.0.0.1:7004
127.0.0.1:7005
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7001
slots:0-3276 (3277 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7002
slots:3277-6553 (3277 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7003
slots:6554-9829 (3276 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7004
slots:9830-13106 (3277 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7005
slots:13107-16383 (3277 slots) master
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..........................................................................................................................................................
NND,一時摸不着頭腦,網上一查了幾個方案 都試了仍是不行。
google查了也沒找到相關信息。
仍是沒人鳥我啊。。多是我英語太差了 。
由於是用ruby的代碼去配置cluster的。
接下來就調試ruby代碼 看下究竟是哪裏出了問題才致使block在waiting的。
要修改一下redis.trib.rb文件才能夠調試,由於參數不是經過COMMAND的ARGV傳過去的。
調試的時候運行到下面的代碼的時候報錯了
錯誤信息爲:
ERR Slot 6387 is already busy
ok 解決了一個問題了。
F5運行 不會報錯了 ,但TMD仍是會block在waiting。此處省略一萬頭馬。
分析了一下。這裏會7001,7002,7003,7004,7005 都會發送給7000 meet這個命令。
而後會收到簽名後纔算是分配成功
發現
signatures
裏面全是7000的回執簽名。
不對啊。應該接收到的是 7001——7005的纔對啊。
除非都發給本身啦?
仔細一看,7000-7005的nodeId都是同樣。不出錯纔怪!
在回過頭看下以前啓動redis的命令,才發現建立的NodeID都是同樣的,一開始就錯了!!!
配置修改爲以下:
port 7005
appendonly yes
appendfilename "appendonly.7005.aof"
cluster-enabled yes
cluster-config-file nodes.7005.conf
cluster-node-timeout 15000
cluster-slave-validity-factor 10
cluster-migration-barrier 1
cluster-require-full-coverage yes
而後從新來過
出現如下結果說明配置好了:
>>> Creating cluster
Connecting to node 127.0.0.1:7000: OK
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: fa810d10bca15ffc480953329c12da988fc3f52a 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 65e347cbe71aeae7b983ce85cf14eec1f0c1e0b7 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 17739ba52d2c171db5c960962e4ec8845c6e63b0 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: d7c9a9c3982dde2f0cc551f227e023b5746373b5 127.0.0.1:7003
replicates fa810d10bca15ffc480953329c12da988fc3f52a
S: fbac6089f7889b68726dd152daaf71834a97dd6e 127.0.0.1:7004
replicates 65e347cbe71aeae7b983ce85cf14eec1f0c1e0b7
S: 76867e63d75e1ff00dc4a5f60a91ea4634a083aa 127.0.0.1:7005
replicates 17739ba52d2c171db5c960962e4ec8845c6e63b0
>>> 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 127.0.0.1:7000)
M: fa810d10bca15ffc480953329c12da988fc3f52a 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 65e347cbe71aeae7b983ce85cf14eec1f0c1e0b7 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 17739ba52d2c171db5c960962e4ec8845c6e63b0 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: d7c9a9c3982dde2f0cc551f227e023b5746373b5 127.0.0.1:7003
replicates fa810d10bca15ffc480953329c12da988fc3f52a
S: fbac6089f7889b68726dd152daaf71834a97dd6e 127.0.0.1:7004
replicates 65e347cbe71aeae7b983ce85cf14eec1f0c1e0b7
S: 76867e63d75e1ff00dc4a5f60a91ea4634a083aa 127.0.0.1:7005
replicates 17739ba52d2c171db5c960962e4ec8845c6e63b0
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.