Article From:

Data access:
zookeeperThe data on the node is read and written in atomic form. When reading, get all the data under the node and write all the data under the replacement node. Each node has an access control list to control who can do anything.
zookeeperThe guarantee of session security is that when the zookeeper client establishes a connection with the server, zookeeper creates a session session to the client. To ensure session security, the server will create a password for each session ID.
Send it to the client and synchronize the password to the other servers in the cluster, and when the client connects the server, the password is sent to the server via the session ID.
zookeeperEach node in the cluster stores the full amount of data information to improve the reading performance, and is suitable for reading less writing scenes.
zookeeperUsing transaction log files and snapshot files to ensure data security in two ways.

ZABAgreement:Broadcasting: in the Zab protocol, all written requests are processed by leader, and updates are broadcast to the whole system.1. After receiving the new request, leader generates a globally unique 64 bit self increasing zxid through ZXThe size of ID has a causal order2, leader sends messages with zxid as a case (proposal) to all follower through queues.3, after follower received the proposal (PAfter roposal, proposal is written to disk. After writing successfully, a ACK message is sent to leader.4, when leader receives more than half of the ACK message from follower, it sends all follower messages.Send the commit command and execute the command locally5, follower receives commit and executesZab protocol can not terminate transaction, follower either return ack to leader, orAbandoning leader, at a certain time, the state of follower and leader may be inconsistent, so it can not handle the situation of leader hanging up, so it is introduced.Recover to solve this problemTwo, recovery: when the service is first startedOr leader hang up, the system automatically enters the recovery mode until the legitimate leader is selected, and then the new leader is responsible for synchronizing the whole system to the latest state.The messages that have been processed can not be lost1, the election has the largest zxidPoint as a new leader,2, the new leader completes the processing of the proposal unit commit in its transaction log.3. A queue between new leader and follower will be built.A proposal with follower but not sent to follower is sent to follower by sending these proposal commit to ensure all follower.All the messages are handledThe discarded message can't appear againConsidering such a scenario, leader receives a new message and generates a proposal, but it does not send the proposal out, so all fThere is no proposal information on the ollower node, so it passes through.The recovery mode will be skipped after the new leader is selected. At this point, the node is re registered and registered as follower, and he has retained the prop which is skipped by the message.The osal state is inconsistent with the whole system state and needs to be deleted.

Two phase lock / three phase lock

One or two phase lock:The first stage:1, the coordinator asks whether all participants nodes can perform submission operations.2, each participant is ready to begin the execution of things3, ready to complete, reply the coordinator can submitOr not to submitSecond stage1, if all participants return the "submission", the coordinator will issue a "formal submission" order, otherwise send a "rollback" command.2. The coordinator receives the information from the participants to complete the whole transaction.Two or three phase submissionThe first stage: the coordinator asks all participants to submit whether they can submit and receive the return information of all participants.The second stage: the coordinator sends the ready to submit order to all the participants, and the participant nodes perform the preparatory work (locking resources).Record log, etc.)The third phase: the coordinator sends the formal submission command to all the participants, the participant executes the submission and returns the execution results, and the coordinator ends the whole transaction after processing.
Link of this Article: About Zookeeper

Leave a Reply

Your email address will not be published. Required fields are marked *