zookeeper's zab agreement with the observer

I. Overview
1. ZAB (Zookeeper Atomic Broadcast) is a broadcast protocol designed specifically for Zookeeper
2. Based on the bottom of the 2PC protocol designed algorithm, improved algorithm using PAXOS
3. action: broadcasting atoms crash recovery and
4. PAXOS algorithm Introduction: in a cluster, all nodes determine whether to perform an operation; communication network between the nodes, the node will request after receiving the request to the local log record. The problem is that this process does not guarantee stability, and stability of the network nodes, how to ensure the normal voting process and ensure the validity of the vote - PAXOS actually solves the data in an unstable cluster of validity and consistency problem

Second, the atomic broadcast
atomic broadcast mainly to ensure that data from all nodes in the cluster consistency Zookeeper
2. Atomic Broadcast 2PC-based algorithm to design
3. 2PC - 2 Phase Commit - two-phase commit protocol - the core idea is "one vote veto ":
a confirmation stage: coordinator after receipt of the request will forward the request to each participant, waiting for feedback from participants
b commit phase: if all participants return to yes, then the coordinator will give participants issue instructions to perform this request, and the client coordinator will return success signal
c aborted stage: If the coordinator participants receive no return or have not received all the participants yes, then all participants will be asked to remove the operation at the same time the client returns a failure signal
4. If a node is a record operation failed, but the entire cluster has decided to implement this operation, so this time follower leader will send the request, then the leader will send follower operation to re-record again, follower during the re-recording, do not vote

Atomic Broadcast Process

 

   Third, crash recovery

  1. When the entire cluster leader is lost when the cluster will automatically elect a new leader, then the process is called Crash Recovery
  2. Each leader after being elected, will be assigned a globally increasing number -epochid, when the elected leader, will epochid distributed to each follower, and if there have been two leader, so this time Zookeeper automatically kill off the smaller epochid leader ensure that the entire cluster, only one leader
  3. transaction id is 64-bit binary number, where 32 represents the high epochid, only the lower 32 bits of the real transaction ID
  4. Leader each a replacement, will generate a new snapshot and the log file

  Observer Overview
  1. Features: do not vote nor election, but will monitor the voting results, and then perform the corresponding request according to the voting results
  2. Application scenario: a bad network or remote network structure; a large number of cluster nodes more
  3. observer of survival or not does not affect the entire cluster

Guess you like

Origin www.cnblogs.com/zym627270054/p/11576412.html