redis master配置了密码进行主从同步

1.如果master不设置密码,那么直接在slave服务器配置slaveof即可 配置如下

#slaveof ip 端口
slaveof  221.224.85.186 6379 

配置好我们看下redis的日志 看是否同步成功

5014:S 25 Jan 10:53:53.667 * Connecting to MASTER 221.224.85.186:6379
5014:S 25 Jan 10:53:53.667 * MASTER <-> SLAVE sync started
5014:S 25 Jan 10:53:53.700 * Non blocking connect for SYNC fired the event.
5014:S 25 Jan 10:53:53.734 * Master replied to PING, replication can continue...
5014:S 25 Jan 10:53:53.832 * Partial resynchronization not possible (no cached master)
5014:S 25 Jan 10:53:53.867 * Full resync from master: 4d6221e370675f397c396c9222b1b60bfcea1efb:1
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: receiving 844 bytes from master
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: Flushing old data
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: Loading DB in memory
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: Finished with success
5014:S 25 Jan 10:53:53.667 * Connecting to MASTER 221.224.85.186:6379
这句是从上面slave服务器日志里面获取的,我们可以看到连接的master的服务器的ip是221.224.85.186

MASTER <-> SLAVE sync: Finished with success
看到输出的语句是success表示同步成功.

2.master设置密码的情况下同步数据,其实很简单,我们只要让slave能连上master就可以了,我们在slave的配置文件中加一句话即可。
masterauth 123456

 OK。

 不然可能会出现一下错误

 

4939:S 25 Jan 09:53:20.450 # MASTER aborted replication with an error: NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.291 * Connecting to MASTER 120.27.137.142:6379
4939:S 25 Jan 09:53:21.292 * MASTER <-> SLAVE sync started
4939:S 25 Jan 09:53:21.317 * Non blocking connect for SYNC fired the event.
4939:S 25 Jan 09:53:21.342 * Master replied to PING, replication can continue...
4939:S 25 Jan 09:53:21.368 * (Non critical) Master does not understand REPLCONF listening-port: -NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.393 * (Non critical) Master does not understand REPLCONF capa: -NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.393 * Partial resynchronization not possible (no cached master)
4939:S 25 Jan 09:53:21.419 # Unexpected reply to PSYNC from master: -NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.419 * Retrying with SYNC...
4939:S 25 Jan 09:53:21.444 # MASTER aborted replication with an error: NOAUTH Authentication required.

 

转载于:https://www.cnblogs.com/sz-jack/p/5156913.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值