zookeeper distributed coordination service

The distributed coordination service mainly separates the responsibility of multi-machine coordination from distributed applications to reduce the coupling of the system and increase the scalability.

Zookeeper adopts the classic master-slave architecture in distributed: master->slave, which usually dynamically stores key metadata in distributed applications.

As a distributed coordination service, zookeeper mainly acts as a coordinator and can provide services such as leader election, load balancing, and service discovery.

Overall structure:

zookeeper uses a hierarchical memory namespace, the structure is similar to the directory structure of the file system, in which each directory node is called ZNode, each

ZNode has attributes such as data, type, version, children, and ACL.

Where data: actual data; type: znode type, version: updated version, children: child node, ACL (Access Control List): permission management

A configuration list of , which defines who can access, modify, delete and other operations on the ZNode. At the same time, the data access of ZNode is atomic, that is, to ensure data reading,

Atomicity when operations are concurrent.

ZNode type :

Persistent (persistent node), Ephemeral (temporary node, with the life cycle of the session), sequence (unique name, the file name is appended with a unique self-incrementing number by default, this type will not exist alone)

According to the three node types, four types of ZNode are derived: Persistent, Ephemeral, Persistent_sequence, Ephemeral_sequence

Watcher listener:

Publishing/notification mechanism, when the ZNode changes, the client can receive the notification, and the watcher has an important feature: once triggered, the watcher will be deleted,

After that, the client needs to re-register the watcher. Generally, the client monitors the changes of the znode by registering the watcher to respond quickly.

Seesion:

The client establishes a communication channel between the seesion and the zookeeper. In the real environment, the zookeeper is generally built in a cluster mode, and the client only needs a random

Select a server to establish a session.

Session has the characteristics of timing and fault tolerance. For example, when the client sends a message, zookeeper will record it according to the current timing of the message. In terms of fault tolerance, zookeeper uses a set of

In the form of a group, zookeeper can ensure the consistency of each server. When the server to which the client connects goes down, the client can automatically connect to other servers.

Draft to be continued. . .

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325717076&siteId=291194637