关于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”配置)

可以告诉副本在之前进行身份验证

启动复制同步进程,否则主进程将执行此操作

拒绝复制请求。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章