Raft算法总结

2018-03-20  本文已影响83人  6a91e15c5cde

raft算法介绍

node节点的三种状态

一个node节点具有三种状态

选举过程

  1. 所有节点开始时处于Follower state
    All our nodes start in the follower state
  2. 如果follower 没有听到过leader发来的消息,那么就可以成为condidate候选者.
    If followers don't hear from a leader then they can become a candidate.
  3. 候选者请求其他节点投票给自己。
    The candidate then requests votes from other nodes.
  4. 节点会以投票的方式回复。
    Nodes will reply with their vote.
  5. 如果候选者获得大多数节点的投票,他会成为领导者。
    The candidate becomes the leader if it gets votes from a majority of nodes.
  6. 领导人选举结束。
    This process is called Leader Election.
  1. 到此系统的所有的变化都要经过领导者Leader;
  2. 每一次的变更节点都会记录节点日志;
  3. 如果节点日志没有提交,就不会更新其他节点的信息;
  4. 如果节点日志提交了,会将信息复制给其他follower;
  5. 然后节点等待大多数节点写入数据完成;
  6. 此时在将变更的数据提交到leader节点;
  7. 然后leader会通知follower信息已经提交;
  8. 到此为止,整个集群的数据达成了一致。
  9. 这个过程称为日志复制。
上一篇 下一篇

猜你喜欢

热点阅读