redis集群设置密码

注意事项:
1.如果是使用redis-trib.rb工具构建集群,集群构建完成前不要配置密码,集群构建完毕再通过config set + config rewrite命令逐个机器设置密码
2.如果对集群设置密码,那么requirepass和masterauth都需要设置,否则发生主从切换时,就会遇到授权问题,可以模拟并观察日志
3.各个节点的密码都必须一致,否则Redirected就会失败
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
config set masterauth abc
config set requirepass abc
config rewrite

测试版本:
redis3.0.7

测试环境:
centos7

集群规模:
3主3从

集群构建成功前的redis配置:
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
port 8000
cluster-enabled yes
cluster-config-file "nodes-8000.conf"
cluster-node-timeout 15000
dir "/opt/redisdata"
appendonly yes
appendfilename "appendonly-8000.aof"
logfile "/opt/redisdata/8000.log"
daemonize yes
pidfile "/var/run/redis-8000.pid"
dbfilename "dump-8000.rdb"
cluster-require-full-coverage no

集群构建成功后的redis配置:
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
port 8004
cluster-enabled yes
cluster-config-file "nodes-8004.conf"
cluster-node-timeout 15000
dir "/opt/redisdata"
appendonly yes
appendfilename "appendonly-8004.aof"
logfile "/opt/redisdata/8004.log"
daemonize yes
pidfile "/var/run/redis-8004.pid"
dbfilename "dump-8004.rdb"
cluster-require-full-coverage no

Generated by CONFIG REWRITE

requirepass "abc"
masterauth "abc"

你可能感兴趣的:(redis集群设置密码)