1. 程式人生 > >Redis密碼驗證情況下建立叢集

Redis密碼驗證情況下建立叢集

在執行:

redis-trib.rb create --replicas 1 ........

提示:>>> Creating cluster
[ERR] Sorry, can’t connect to node ip:port
解決方案:

find / -name client.rb -print

/usr/share/ruby/xmlrpc/client.rb
/usr/local/lib/ruby/2.3.0/xmlrpc/client.rb
/usr/local/lib/ruby/2.1.0/xmlrpc/client.rb
/usr/local/rvm/src/ruby-2.3.3/lib/xmlrpc/client.rb
/usr/local/rvm/gems/ruby-2.3.3/gems/redis-4.0.0/lib/redis/client.rb
/usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/xmlrpc/client.rb

找到gems目錄下的client.rb,並修改它(在執行redis-trib.rb的機器上修改就可以了):

vim /usr/local/rvm/gems/ruby-2.3.3/gems/redis-4.0.0/lib/redis/client.rb

一下配置,根據自己環境來配置,比如:我的埠和密碼

    DEFAULTS = {
      :url => lambda { ENV["REDIS_URL"] },
      :scheme => "redis",
      :host => "127.0.0.1",
      :port => 6377,
      :path
=> nil, :timeout => 5.0, :password => "Htdhy,Lyzhh", :db => 0, :driver => nil, :id => nil, :tcp_keepalive => 0, :reconnect_attempts => 1, :inherit_socket => false }

儲存,重新執行

redis-trib.rb create --replicas 1 ........

‘>>> Creating cluster
‘>>> Performing hash slots allocation on 6 nodes…
Using 3 masters:
192.170.18.104:6377
192.170.18.128:6377
192.170.18.151:6377
Adding replica 192.170.18.152:6377 to 192.170.18.104:6377
Adding replica 192.170.18.105:6377 to 192.170.18.128:6377
Adding replica 192.170.18.129:6377 to 192.170.18.151:6377
M: 160532e157874a99bfd50aed7387075fa2a50913 192.170.18.104:6377
slots:0-5460 (5461 slots) master
M: fcd4635e10260cd05114174bc98cee4dc16013f1 192.170.18.128:6377
slots:5461-10922 (5462 slots) master
M: 5fddeceef9606efdbf672b831bb111ef4b84b1b4 192.170.18.151:6377
slots:10923-16383 (5461 slots) master
S: a4cdff4d120a57fa74c6ebfa103ba3429860fb0f 192.170.18.152:6377
replicates 160532e157874a99bfd50aed7387075fa2a50913
S: 0d60cbf4fcf9709a4f27be1472db7bb0cede2558 192.170.18.105:6377
replicates fcd4635e10260cd05114174bc98cee4dc16013f1
S: f672231c69f65611f193e5847defe8806798cce1 192.170.18.129:6377
replicates 5fddeceef9606efdbf672b831bb111ef4b84b1b4