redis集群设置密码详解
原文:http://lookingdream.blog.51cto.com/5177800/1827851
注意事项:
1.如果是使用redis-trib.rb工具构建集群,集群构建完成前不要配置密码,集群构建完毕再通过config set + config rewrite命令逐个机器设置密码(我觉得最好是在每一个redis.conf文件中配置requirepass)
2.如果对集群设置密码,那么requirepass和masterauth都需要设置,否则发生主从切换时,就会遇到授权问题,可以模拟并观察日志
3.各个节点的密码都必须一致,否则Redirected就会失败
[plain] view plain copy
-
config set masterauth abc
-
config set requirepass abc
-
config rewrite
-
设置密码后,redis-trib.rb check 192.168.0.107:6379
设置密码后,redis-trib.rb check 192.168.0.107:6379 报错连接不上实例,解决方法:
vim /usr/lib/ruby/gems/1.8/gems/redis-3.3.0/lib/redis/client.rb
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 => "gh*8pass",
:db => 0,
:driver => nil,
:id => nil,
:tcp_keepalive => 0,
:reconnect_attempts => 1,
:inherit_socket => false
}
修改下默认密码就可以了
看完打开支付宝扫一扫领个红包吧!