redis-trib.rb创建Redis集群时失败报错解决方案

数据齿轮 2019-12-20

问题描述:

[ init.d]# redis-trib.rb create --replicas 1 192.168.1.110:7001 192.168.1.110:7002 192.168.1.112:7003 192.168.1.112:7004 192.168.1.113:7005 192.168.1.113:7006
/usr/local/ruby/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:15:in `<class:Client>‘: undefined local variable or method `redis‘ for Redis::Client:Class (NameError)
    from /usr/local/ruby/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:6:in `<class:Redis>‘
    from /usr/local/ruby/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:5:in `<top (required)>‘
    from /usr/local/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require‘
    from /usr/local/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require‘
    from /usr/local/ruby/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis.rb:2771:in `<top (required)>‘
    from /usr/local/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require‘
    from /usr/local/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require‘
    from /usr/local/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require‘
    from /usr/local/bin/redis-trib.rb:25:in `<main>‘

解决方案:

检查client.rb的配置是否配置正确。

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

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

相关推荐

DiamondTao / 0评论 2020-08-30