关于Redis配置主从复制踩到的坑!!!
设置单机集群的时候,两台从机都显示连接到主机,但是主机显示连接到的从机数量为0:
主机信息:
从机80:
从机81:
查看从机log日志文件发现错误信息:
MASTER aborted replication with an error: NOAUTH Authentication required.
主库master要求密码验证!
因为之前配置redis的密码,在配置文件中将requirepass注释掉即可!
重启Redis,成功!!!
所以:
对于Redis集群,如果设置了requirepass,则一定要设置masterauth,否则从节点无法正常工 作!!!
其实仔细阅读redis.conf文件会发现:
redis说明了
# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the replica to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the replica request.
#
# masterauth <master-password>
翻译:
如果主服务器是密码保护的(使用“requirepass”配置)可以告诉副本在之前进行身份验证启动复制同步进程,否则主进程将执行此操作拒绝复制请求。