redis建立叢集報錯
阿新 • • 發佈:2018-12-14
建立redis叢集,單節點執行完畢,建立叢集時報錯:
[[email protected] src]$ ./redis-trib.rb create --replicas 1 192.168.0.7:7000 192.168.0.7:7001 192.168.0.7:7002 192.168.0.7:7003 192.168.0.7:7004 192.168.0.7:7005
./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
安裝ruby。
ruby官網https://www.ruby-lang.org/en/downloads/下載穩定版本,本次安裝下載的是ruby-2.4.2版本,將下載好的軟體上傳到伺服器上
# tar xvf ruby-2.4.2.tar.gz
# cd ruby-2.4.2
# ./configure
# make&& make install
又報錯:
[[email protected] src]$ ./redis-trib.rb create --replicas 1 192.168.0.7:7000 192.168.0.7:7001 192.168.0.7:7002 192.168.0.7:7003 192.168.0.7:7004 192.168.0.7:7005 /usr/local/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError) from /usr/local/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' from ./redis-trib.rb:25:in `<main>'
發現缺少redis庫。
執行安裝:
[[email protected] ruby-2.4.2]# gem install redis
-bash: /usr/bin/gem: /usr/bin/ruby: bad interpreter: No such file or directory
才發現ruby預設安裝到了/usr/local/bin/ruby,後面就是安裝redis庫了
[[email protected] ruby-2.4.2]# /usr/local/bin/ruby --version
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
// 建立軟鏈
[ [email protected] ruby-2.4.2]# cd /usr/bin/
[[email protected] bin]# ln -s /usr/local/bin/ruby /usr/bin/ruby
[[email protected] bin]# ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
//安裝redis庫
[[email protected] bin]# gem install redis
Fetching: redis-4.0.2.gem (100%)
Successfully installed redis-4.0.2
Parsing documentation for redis-4.0.2
Installing ri documentation for redis-4.0.2
Done installing documentation for redis after 0 seconds
1 gem installed
然後建立叢集:
[[email protected] src]$ ./redis-trib.rb create --replicas 1 192.168.0.7:7000 192.168.0.7:7001 192.168.0.7:7002 192.168.0.7:7003 192.168.0.7:7004 192.168.0.7:7005
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.0.7:7000
192.168.0.7:7001
192.168.0.7:7002
Adding replica 192.168.0.7:7003 to 192.168.0.7:7000
Adding replica 192.168.0.7:7004 to 192.168.0.7:7001
Adding replica 192.168.0.7:7005 to 192.168.0.7:7002
M: 90857fd17a70eb2a1af48aeb65807f207830b057 192.168.0.7:7000
slots:0-5460 (5461 slots) master
M: 90857fd17a70eb2a1af48aeb65807f207830b057 192.168.0.7:7001
slots:5461-10922 (5462 slots) master
M: 90857fd17a70eb2a1af48aeb65807f207830b057 192.168.0.7:7002
slots:10923-16383 (5461 slots) master
S: 90857fd17a70eb2a1af48aeb65807f207830b057 192.168.0.7:7003
replicates 90857fd17a70eb2a1af48aeb65807f207830b057
S: 90857fd17a70eb2a1af48aeb65807f207830b057 192.168.0.7:7004
replicates 90857fd17a70eb2a1af48aeb65807f207830b057
S: 90857fd17a70eb2a1af48aeb65807f207830b057 192.168.0.7:7005
replicates 90857fd17a70eb2a1af48aeb65807f207830b057
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.................