记一次redis主从连接的错误

Redis版本 redis-4.0.11
安装后多实例均可正常使用,将其中一个实例设置为从服务器后,调用info replication报master_link_status:down;
外部原因:
1.因为redis部署在阿里云服务器上,首先在阿里云控制台开放各redis实例的端口;
2.使用系统为ubuntu,设置ufw allow 各实例端口
步骤一:开启log日志,
设置log等级为debug,loglevel debug
设置log文件路径为: logfile “/usr/local/redis/log/redislog_16378.log”
步骤二:
日志内容如下所示:
slave:
11613:S 22 Aug 22:14:56.796 * Connecting to MASTER 47.95.212.99:16379
11613:S 22 Aug 22:14:56.796 * MASTER <-> SLAVE sync started
11613:S 22 Aug 22:14:56.799 * Non blocking connect for SYNC fired the event.
11613:S 22 Aug 22:14:56.802 * Master replied to PING, replication can continue…
11613:S 22 Aug 22:14:56.804 * (Non critical) Master does not understand REPLCONF listening-port: -NOAUTH Authentication required.
11613:S 22 Aug 22:14:56.807 * (Non critical) Master does not understand REPLCONF capa: -NOAUTH Authentication required.
11613:S 22 Aug 22:14:56.807 * Partial resynchronization not possible (no cached master)
11613:S 22 Aug 22:14:56.809 # Unexpected reply to PSYNC from master: -NOAUTH Authentication required.
11613:S 22 Aug 22:14:56.809 * Retrying with SYNC…
11613:S 22 Aug 22:14:56.812 # MASTER aborted replication with an error: NOAUTH Authentication required.
master:
11599:M 22 Aug 22:14:47.055 - Accepted 175.169.183.207:8917
11599:M 22 Aug 22:14:47.261 * Slave 175.169.183.207:16379 asks for synchronization
11599:M 22 Aug 22:14:47.261 * Full resync requested by slave 175.169.183.207:16379
11599:M 22 Aug 22:14:47.261 * Starting BGSAVE for SYNC with target: disk
11599:M 22 Aug 22:14:47.262 * Background saving started by pid 11603
11603:C 22 Aug 22:14:47.266 * DB saved on disk
11603:C 22 Aug 22:14:47.266 * RDB: 6 MB of memory used by copy-on-write
11599:M 22 Aug 22:14:47.357 * Background saving terminated with success
11599:M 22 Aug 22:14:47.357 * Synchronization with slave 175.169.183.207:16379 succeeded
11599:M 22 Aug 22:14:47.443 - Reading from client: Connection reset by peer
11599:M 22 Aug 22:14:47.443 # Connection with slave client id #3 lost.
经查slave未设置主服务器密码

解决方式:redis.conf中添加如下设置—> masterauth password
指定密码后
输入info replication
role:slave
master_host:47.95.212.99
master_port:16379
master_link_status:up
master_last_io_seconds_ago:7
master_sync_in_progress:0
slave_repl_offset:28
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:fc628a2b0f62b1c7175847ea1c7ac72169263b73
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:28
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:28
连接成功
效果图

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值