redis集群启用了密码后ruby无法连接问题

环境:

os:Centos 7

redis:4.0.12

 

1. 查看ruby安装路径

[root@dev_test_redis ~]# which ruby
/opt/ruby/bin/ruby
[root@dev_test_redis ~]# 

 

2.尝试检查redis集群

检查其中一个节点即可

[root@dev_test_redis bin]# /usr/local/services/redis/redis-trib.rb check 192.168.1.84:6379
/opt/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
[ERR] Sorry, can't connect to node 192.168.1.84:6379

 

3.解决办法

修改client.rb文件,填写密码部分

[root@dev_test_redis ruby]# find ./ -name client.rb
./lib/ruby/gems/2.5.0/gems/xmlrpc-0.3.0/lib/xmlrpc/client.rb
./lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb

 

vi /opt/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb

复制代码
[root@dev_test_redis ~]# more /opt/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb
require "redis/errors"
require "socket"
require "cgi"

class Redis
  class Client

    DEFAULTS = {
      :url => lambda { ENV["REDIS_URL"] },
      :scheme => "redis",
      :host => "127.0.0.1",
      :port => 6379,
      :path => nil,
      :timeout => 5.0,
      :password => "hxl2018",
      :db => 0,
      :driver => nil,
      :id => nil,
      :tcp_keepalive => 0,
      :reconnect_attempts => 1,
      :inherit_socket => false
    }
复制代码

 

4.再次检查

复制代码
[root@dev_test_redis redis]# /usr/local/services/redis/redis-trib.rb check 192.168.1.84:6379
/opt/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 192.168.1.84:6379)
M: 4e688916897cf2f8c356935625fc0dfa6bb92e4e 192.168.1.84:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
M: 833d5097073149a963f3e08b3dc30ab41469af86 192.168.1.84:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: 42c0d84c580d072d03485032dce961aac7d0f3a0 192.168.1.84:6383
   slots: (0 slots) slave
   replicates 4e688916897cf2f8c356935625fc0dfa6bb92e4e
S: ce4c1a4da8f62d3364a63762f3fee7ec72840ed5 192.168.1.84:6384
   slots: (0 slots) slave
   replicates 0af2601f87d2620cc684771b0e75e5c009865b20
M: 0af2601f87d2620cc684771b0e75e5c009865b20 192.168.1.84:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 51e54d50118412115ef25233777eb8d783d74d30 192.168.1.84:6382
   slots: (0 slots) slave
   replicates 833d5097073149a963f3e08b3dc30ab41469af86
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
复制代码

 

posted @   slnngk  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2020-02-17 goldengate(o2o)部署for_12C(非cdb)_to_11G
2020-02-17 goldengate Not able to establish initial position for begin time
点击右上角即可分享
微信分享提示