前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >redis 4 增量同步的日志详解

redis 4 增量同步的日志详解

作者头像
保持热爱奔赴山海
发布2019-09-18 14:52:58
1.1K0
发布2019-09-18 14:52:58
举报
文章被收录于专栏:饮水机管理员饮水机管理员

redis 4 增量同步的日志详解

1、1主 2从 环境下,关闭原先的master节点

2、在新的master上执行 slaveof no one

看到的日志:

6855:M 02 Sep 15:43:16.871 # Setting secondary replication ID to 2ba403b0a69dcacbfe92650ac8758ae236693d5c, valid up to offset: 4802. New replication ID is 5f01e7a777abda968d9765145d5bc09146226615

6855:M 02 Sep 15:43:16.871 * Discarding previously cached master state.

6855:M 02 Sep 15:43:16.871 * MASTER MODE enabled (user request from 'id=3 addr=127.0.0.1:59204 fd=8 name= age=3041 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=slaveof')

6855:M 02 Sep 15:43:33.820 * 1 changes in 900 seconds. Saving...

6855:M 02 Sep 15:43:33.840 * Background saving started by pid 6929

6929:C 02 Sep 15:43:33.854 * DB saved on disk

6929:C 02 Sep 15:43:33.855 * RDB: 0 MB of memory used by copy-on-write

6855:M 02 Sep 15:43:33.941 * Background saving terminated with success

###日志解说:

2ba403b0a69dcacbfe92650ac8758ae236693d5c 这个是 宕机的原先master的runid

5f01e7a777abda968d9765145d5bc09146226615 这个是 新的master的runid

可以看到,新的master 在提升为主的时候,还记录了之前复制到的pos和之前主库的runid

3、然后,新的slave上执行 slaveof 127.0.0.1 6379

看到的日志:

6923:S 02 Sep 15:43:59.751 * SLAVE OF 127.0.0.1:6379 enabled (user request from 'id=3 addr=127.0.0.1:42122 fd=8 name= age=115 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=slaveof')

6923:S 02 Sep 15:44:00.427 * Connecting to MASTER 127.0.0.1:6379

6923:S 02 Sep 15:44:00.427 * MASTER <-> SLAVE sync started

6923:S 02 Sep 15:44:00.427 * Non blocking connect for SYNC fired the event.

6923:S 02 Sep 15:44:00.427 * Master replied to PING, replication can continue...

6923:S 02 Sep 15:44:00.428 * Trying a partial resynchronization (request 2ba403b0a69dcacbfe92650ac8758ae236693d5c:4802). # 可以看到,从库在连接到新的主库时候,会把之前的主库复制的runid和pos发送给新master,尝试增量同步数据

6923:S 02 Sep 15:44:00.429 * Successful partial resynchronization with master.

6923:S 02 Sep 15:44:00.429 # Master replication ID changed to 5f01e7a777abda968d9765145d5bc09146226615

6923:S 02 Sep 15:44:00.429 * MASTER <-> SLAVE sync: Master accepted a Partial Resynchronization.

4、然后,再看下新的master的日志:

6855:M 02 Sep 15:44:00.428 * Slave 127.0.0.1:6381 asks for synchronization

6855:M 02 Sep 15:44:00.428 * Partial resynchronization request from 127.0.0.1:6381 accepted. Sending 128 bytes of backlog starting from offset 4802.

可看到,新master也同意了slave的增量复制的请求。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-09-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档