[Zookeeper] zab Protocol

A description

zab (ZooKeeper Atomic Broadcast message broadcast protocol atoms), a zookeeper coherence protocol, including protocols ZAB two modes, message broadcasting and Ben crush recovery


Second, the role

zookeeper in the two main roles, leader and follower, these two roles have the right to vote


Third, the news broadcast

1.follower receive prosoal write transactions and other proposals

2.follower will be sent to leader

3.leader creates a queue for each follower, in a manner to ensure that messages tcp fifo characteristics to guarantee the order message

4. Upon receipt of the reply ack more than half of the follower, the follower will want to send each commit request


This is similar to 2pc (two-phase commit), the time difference is 1.zab do not need to wait for ack all follower of the next commit operation was carried out. 2.zab simplify the logic, interrupt logic removed

But this does not solve the similar 2pc submission time, as the leader received enough ack, after sending commit, received only a fraction follower, while the other part is not received commit,

At this time leader Ben rout out, this will lead to data inconsistencies, so you need to Ben collapse recovery to solve this problem


Fourth, Ben collapse recovery

When the zookeeper's leader Ben collapse, zookeeper cluster need to recover from Ben collapse, so need to elect a new leader, and the new leader is elected, the transaction id of the leader of the largest,

To ensure that the current leader contains the latest data submitted, so follow their leader and follower data synchronization, you can know what needs to be submitted when the data, which data is to be dropped



Published 140 original articles · won praise 28 · views 180 000 +

Guess you like

Origin blog.csdn.net/qq_16097611/article/details/79948808
Recommended