Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis psync #3

Open
Jack-laoniu opened this issue Jun 21, 2022 · 0 comments
Open

redis psync #3

Jack-laoniu opened this issue Jun 21, 2022 · 0 comments

Comments

@Jack-laoniu
Copy link
Owner

RDB 与 offset

  • 主服务器与从服务器 进行数据一致的同步时 ,往往会出现 断线,并且断线后没有上次的同步进度 ,导致只能进行全量的 同步 很好资源

  • 在引入offset后 ,在从服务器 断线后上线后 ,进行同步操作,就可以带上 runid和offset 给主服务器 ,主服务会根据runid来判断是否是之前的 同步过的 从服务器,如果不是会全量同步 ,如果同步过 ,就进行部分同步

  • 主从之前的 offset 差异数据会保存在 缓冲区中,用list保存保证有序 ,从服务offset150 发给主服务,主服务发现自己的offset是 200.并且缓冲区中有相差的50的数据 ,主服务会化身为从服务的客户端 向从服务发送command

offset 与 心跳

  • 上面说的复制过程存在 从服务彻底断线后的恢复
  • 在增量的数据同步中 ,从服务会每秒向主服务 ping心跳,主服务在使用心跳间隔时间来决定是否要继续向从服务发送command,如果超过限制时间没有收到从服务的 心跳 ,主服务会停止向从服务发送命令 (因为即使发送从服务也有可能处理不了),同时 ,主服务在 执行完客户端的 command之后 ,增加自己的offset ,再把command发给从服务,从服务会ack自己的offset 给主服务 ,如果 主服务发现offset不同步,会重新发送差异的 offset 数据给从服务
@Jack-laoniu Jack-laoniu changed the title redis sentinel and sync redis sentinel and psync Jun 21, 2022
@Jack-laoniu Jack-laoniu changed the title redis sentinel and psync redis psync Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant