Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[distributed Coordination zookeeper] fundamentals

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Zookeeper introduces that it is a software that provides consistency services for distributed applications. The functions provided include: configuration maintenance, name service, distributed synchronization, group service and so on. What does zookeeper do?

1. Naming Service 2. Configuration Management 3. Cluster management 4. Distributed lock 5. Queue management

Second, the mixed type of the two models of zookeeper, the architecture model of zookeeper architecture:

Client-Server model: used to provide coordination services to objects in a distributed coordination system

Peer-to-Peer model: for exchanging data within a zookeeper cluster

This hybrid architecture allows zookeeper to keep the client simple while maintaining a good high availability mechanism within the cluster.

Two operating modes of zookeeper: standalone and quorum

Standalone mode:

The zookeeper is made up of a single node, and its data does not need to be copied between multiple nodes.

Quorum mode:

This mode is mainly used in production environment. Zookeeper has multiple nodes to form a cluster, which is related to Leader election of zookeeper and data synchronization between cluster nodes.

When using quorum mode, its basic operation flow is:

① elects Leader

② synchronization data

There are many algorithms in the Leader election process of ③, but the election criteria to be achieved are the same.

④ Leader needs to have the highest zxid

Most of the machines in the ⑤ cluster get the corresponding and follow-selected Leader

Description:

For the user's read operation, all nodes in the zookeeper cluster can receive processing; for the user's write operation, zookeeper treats it as a transaction, and only Leader can initiate the transaction; before each commit, the modified data should be synchronized in the cluster; third, the data model

Zookeeper serves the client through the centralized Cramp S architecture, using the peer-to-peer Pair-Pair architecture to synchronize data among the nodes. The data structures and data types within zookeeper are provided to users in a simplified way.

In terms of data structure, zookeeper adopts a tree structure; the node of the tree species is called znode, and there is a clear hierarchical relationship between father and son in the whole tree species.

Zookeeper's modification of data is treated as a transaction, each transaction is an atomic operation, and a unique zxid (zookeeper transacation id) is assigned.

The zxid;znode associated with it is recorded in each znode, in addition to the payload data, including the following attributes:

Czxid: the zxid that causes the current znode change

Mzxid: the zxid before the last modification of the current znode

Ctime: the time spent on znode transactions, in milliseconds

Mtime: the time it took to operate the last znode transaction, in milliseconds

Version: associated to the version attribute of zxid,znode itself, the number of current znode modifications

Number of modifications to the cversion:znode child node

Modification Test of aversion:znode ACL (access list)

EphemeralOwner: record client session ID, or 0 for persistent znode

Length of dataLength:znode data field

Number of numChildren:znode child nodes

1. Persistent and transient znode [corresponding to ephemeralOwner attribute]

Znode can specify patterns when it is created, and can be combined with different patterns to form the required distributed scene functions.

A znode node can be either Persistent or Ephemera

Difference: persistent:

Can only be deleted after receiving the delete command

Used to save structural information

Transient:

Will be automatically deleted when the saved session between the client and the server is interrupted

It can also be ordered to delete like persistent znode.

Once a connection is established between the client and the server, there will be regular heartbeats to ensure the survival of the long connection

2. Sequence znode

A unique incremental integer is automatically assigned when the znode is created, and this forward sequence can be used as part of the path name

For example, if the client creates a sequence znode of / woker/work-, zookeeper will automatically assign a sequence number, and if it is the first child node under the current znode, it will be assigned as 1. The most important function of a node whose path becomes / worker/work-1; sequence is to generate a unique name node and to provide information about the creation order between nodes.

3. ACL [access list]

Zookeeper's ACL is established under the authentication and authorization mechanism and includes the following authentication methods:

1. Digest: authenticate the client through username / password; 2. Sasl: support the client to authenticate through Kerberos; 3. Ip: authenticate the client through IP address

In terms of authorization, ACL can control the creation (child nodes), reading, writing, deletion and management of znode (setting ACL)

To be continued.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report