In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces what ZooKeeper analysis is like, the content is very detailed, interested friends can refer to, hope to be helpful to you.
A brief introduction to distributed systems
Distributed system is composed of multiple software running independently across multiple physical hosts at the same time. In such a distributed system, how to ensure the synchronization and sharing of node information is a troublesome thing, and the main use scenario of ZooKeepe is as a collaborative service of distributed systems to solve these problems.
Distributed collaborative service is to enable the information of each node to be synchronized and shared in some way. This depends on communication between service processes. The communication methods are as follows:
Information sharing through the network
Ex.: in real life, the developer leader conveys the task at the meeting, and team members know what they want to do by listening to leader's commands or checking leader's email. When there is a change in the task assignment, leader notifies the team members individually or holds another meeting. Information is transmitted through direct communication between people.
Through shared Stora
Example: development leader according to the agreed time and path, put the task assignment table on SVN, team members go to SVN every day to pull the latest task assignment table, and then work; when the SVN file version is updated, trigger email notification, each team member to pull the latest task assignment table. Where SVN is shared storage.
Second: how to realize distributed collaborative services by ZooKeeper
There are two ways to solve distributed collaborative services. ZooKeeper uses shared storage to solve the problem, but in fact, distributed applications also need to communicate with storage on the network.
The principle of distributed collaboration through ZooKeeper is similar to the example of SVN above. Like SVN, ZooKeeper stores shared information about task assignment, completion, and so on. The node of each distributed system is like a group member, subscribing to this shared information. When the master node (group leader) changes the division of labor information of a slave node, the related subscribers get the notification of ZooKeeper and get their latest task assignment. After the slave node completes the work, the completion is stored in zookeeper, and the master node subscribes to the completion information of the task, so it will get the completion notification of zookeeper.
Note: if the Slave node wants to get the update notification of ZooKeeper, it needs to set the observation point on the concerned data node in advance.
If the information between the nodes can not be shared and synchronized in time, then a variety of problems will arise in the process of cooperation. The key for ZooKeeper to solve the cooperation problem is to ensure the consistency of distributed system information.
Three: understanding the concept of ZooKeeper
ZooKeeper is an open source distributed coordination service framework. Its design goal is to encapsulate those complex and error-prone distributed consistency services to form an efficient set of primitives and provide them to users with some simple interfaces. Based on it, distributed applications can implement functions such as data subscription / publishing, load balancing, naming services, cluster management, distributed locking and distributed queues.
First of all, to learn ZooKeeper, you need to have a general understanding of the following concepts:
3.1 Cluster role
In distributed systems, each machine that constitutes a cluster usually has its own role, the most typical is the active / standby mode (Master/Slave). What can handle and write is the master machine, which is called the Slave machine that obtains the latest data and provides read services through asynchronous replication. However, these concepts are not adopted in ZooKeeper, but three roles of Leader, Follower and Observer are introduced.
In order to facilitate understanding, we can first understand the theoretical knowledge of algorithms such as Paxos and Raft to solve distributed consistency. Although Zookeeper does not directly use the Paxos algorithm, it uses a consistency protocol called ZAB (Zookeeper Atomic Broadcast). Distributed (1)-- introduction and Theory
All machines in Leader:zookeeper are elected to select a machine called Leader to provide read and write services.
Follower: provide read service and election leader service.
Observer: can also provide read service, the difference is not to participate in the election, do not participate in the write operation of more than half of the successful strategy, as well as the recorder of the election.
3.2 session (session)
Session refers to a client session, and a client connection refers to a TCP persistent connection between the client and the server.
The service port of ZooKeeper defaults to 2181. When the client starts, it establishes a tcp persistent connection with the server. From the first connection establishment, the lifecycle of the client session begins. Through this connection, the client can perform heartbeat detection to maintain a valid session with the server, send requests and receive responses to the ZooKeeper server, and receive watch event notifications from the server through the connection.
3.3data Node (ZNode)
Nodes are usually referred to as a machine in distribution, but in ZooKeeper there are two types of nodes:
Machine node: the machines that make up the cluster
Data node (ZNode); ZooKeeper stores all the data in memory, and the data model is a ZNode Tree, as shown in the following figure.
Each node in the tree is a ZNode, and each ZNode stores its own data content and a series of attribute information.
Version 3.4
For each ZNode,ZooKeeper, a data structure called Stat is maintained. This Stat data structure records the three data versions of the current ZNode:
Version: the current version of ZNode
Cversion: the version of the current ZNode child node
Aversion: the current ACL version of ZNode
3.5 Watcher (event listener)
Watcher event listener is an important feature of ZooKeeper to implement distributed coordination service. ZooKeeper allows users to register some Watcher at specified nodes, and when some specific events are triggered, ZooKeeper will notify interested clients of events.
3.6 ACL (Access Control Lists)
ZooKeeper uses ACL policy for permission control, and has the following five permissions:
CREATE: permission to create child nodes
READ: access to node data and child node list
WRITE: permission to update node data
DELETE: delete permissions for child nodes
ADMIN: setting permissions for node ACL
About how ZooKeeper analysis is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.