Redis建集群时出现[ERR] Sorry, can’t connect to node的错误
原因是由于Redis设置密码,无法连接
但由于Redis不设置密码容易被入侵,因此需要找到ruby中的配置文件加入密码的配置
先要安装ruby和rubygems
1、查找配置文件
find / -name 'client.rb'
2、找到目录
/usr/local/share/gems/gems/redis-3.2.0/lib/redis/client.rb
3、进入client.rb
修改
DEFAULTS = {
:url => lambda { ENV["REDIS_URL"] },
:scheme => "redis",
:host => "127.0.0.1",
:port => 6379,
:path => nil,
:timeout => 5.0,
:password => "xxxxxx",
:db => 0,
:driver => nil,
:id => nil,
:tcp_keepalive => 0,
:reconnect_attempts => 1,
:inherit_socket => false
}
修改password为Redis的密码。同时需要注意的是要设置绑定ip否则只能127.0.0.1才能使用
在执行集群命令 成功执行。