redis主从异常
1、现象
redis启用redis-sentinel架构,三台sentinel两台redis。发现从库没有从主库同步数据。
2、日志
31201:S 24 Feb 2023 14:26:59.626 * Connecting to MASTER 192.168.162.152:16380 31201:S 24 Feb 2023 14:26:59.626 * MASTER <-> REPLICA sync started 31201:S 24 Feb 2023 14:26:59.627 * Non blocking connect for SYNC fired the event. 31201:S 24 Feb 2023 14:26:59.627 * Master replied to PING, replication can continue... 31201:S 24 Feb 2023 14:26:59.627 # Unable to AUTH to MASTER: -ERR invalid password
3、查看slveof状态
从库,显示没连上master
127.0.0.1:16380> info replication # Replication role:slave master_host:192.168.162.152 master_port:16380 master_link_status:down master_last_io_seconds_ago:0 master_sync_in_progress:0 slave_repl_offset:1916743737 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:9525edbaf58286234e4d0c2144a22a2cddd2d569 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:1916743737 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1915695162 repl_backlog_histlen:1048576
主库:
用info replication命令查看,也没有salve连接
查看主从库的masterauth:
127.0.0.1:16380> CONFIG GET masterauth 1) "masterauth" 2) "ada68d"
主从库密码都是这个。
命令行手动去同步master也返回OK
redis 127.0.0.1:16380> SLAVEOF NO ONE OK redis 127.0.0.1:16380> SLAVEOF 192.168.162.152 16380 OK
4、最后用原来的配置新建了两个16379端口的redis主从去测试,发现把masterauth和requirepass密码设置成一样时,主从连接正常了。
https://blog.csdn.net/damanchen/article/details/100584275
说是:
主从在做复制的时候,如果有masterauth,从库会先发送masterauth给主库进行验证,验证无误后再进行下面的主从复制,验证不通过时就跳转到error错误处理。