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 master-slave #7

Open
ping-chang-xin opened this issue Dec 12, 2021 · 0 comments
Open

redis master-slave #7

ping-chang-xin opened this issue Dec 12, 2021 · 0 comments

Comments

@ping-chang-xin
Copy link
Owner

ping-chang-xin commented Dec 12, 2021

redis master-slave

redis主从连接过程时序图

redis-master-slaver

  • 主从建立连接过程可以理解为使用状态机驱动
  • redisServer struct中有个属性repl_state
  • 客户端发送replicaof命令,redis处理该命令,设置repl_state = REPL_STATE_CONNECT,开启状态转换
  • redis使用定时器事件,根据repl_state不同状态做不同操作,最终完成主备连接,发送PSYNC命令
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant