Redis创建集群设置密码的配置

创建redis集群的时候,当节点配置了密码,这时候就会出现无法创建集群,无法连接节点,这时候的配置需要修改

错误描述

Connecting to node 127.0.0.1:6381: [ERR] Sorry, can't connect to node 127.0.0.1:6381

解决方案

需要修改gem的redis工具下的一个文件,我这里是默认安装,路径如下:/var/lib/gems/2.3.0/gems/redis-4.0.1/lib/redis/client.rb ,修改内容如下:

修改下面的:password => “admin”,admin就是redis节点的密码,记住需要加双引号

kunzai@kunzai:/var/lib/gems/2.3.0/gems/redis-4.0.1/lib/redis$ cat client.rb 
require_relative "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 => "admin",
      :db => 0,
      :driver => nil,
      :id => nil,
      :tcp_keepalive => 0,
      :reconnect_attempts => 1,
...............................