In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
The knowledge points of this article include: the concept of Zookeeper, the introduction of the role of Zookeeper, the election introduction of Zookeeper, the role of Zookeeper, the zab protocol in Zookeeper and the nodes of Zookeeper. I believe you have a certain understanding of Zookeeper after reading the complete article.
ZooKeeper concept
ZooKeeper is a distributed, open source distributed application coordination service, an open source implementation of Google's Chubby, and an important component of Hadoop and Hbase. It is a software that provides consistency services for distributed applications, including configuration maintenance, domain name services, distributed synchronization, group services and so on. The goal of ZooKeeper is to encapsulate complex and error-prone key services and provide users with simple and easy-to-use interfaces and systems with efficient performance and stable functions. ZooKeeper contains a simple set of primitives that provides an interface between Java and C.
[1. Roles in Zookeeper]
① Leader (leader) Leader server provides read and write services for clients. It is the core of the cluster working mechanism, and the transaction request is the only scheduler and processor to ensure the sequence of cluster transaction request processing.
② learners (learner), who are divided into followers and observers:
The follower (follower) Follower server provides read services for the client, participates in the Leader election process, and participates in the write operation "more than half write success" strategy. Handle non-transactional requests, forward transactional requests to leaders, and vote at the same time.
The observer Observer server provides read services for the client, does not participate in the Leader election process, and does not participate in the write operation "more than half write success" strategy. It is used to improve the read performance of the cluster without affecting the write performance. The service does not participate in voting and is optional.
The ③ client (client) service request initiator.
[II. Zookeeper election]
How did the server roles mentioned above come into being, that is, through elections.
Here, I would like to illustrate the election process with an example:
1, we now have 10 servers, the server that just went online does not have any data, brand-new. Let's give it a number: 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10. Let's turn on all 10 servers one by one.
2. When the server starts, the election begins. Server No. 1 starts up, vote for yourself first, then send out your message and let others vote as well. However, other servers have not been started yet, so the No. 1 server has not received any feedback. The mood is very lost, like the author that year, at this time the No. 1 server began to be in the election state (Looking looking around, waiting anxiously).
3. Then server 2 finally started, and it voted for itself, but server 2 received feedback from server 1. Server 2 won temporarily, the number of votes has not been more than half, and server 2 has to be in the state of election.
4. Tongliha, start on the 3rd, start on the 4th, start on the 5th until the 6th. On the 6th, it cast a vote for itself first, and then received a vote of 1, 2, 3, 4, 5, with more than half of the 6 votes, and he was the leader. At the same time, it is also preconceived, and no matter what the number of votes is, no matter what the number of votes is on the follow-up 7, 8, 9, 10.
[III. Various roles of Zookeeper]
1. Requests in Zookeeper
Transaction request:
Request to change the state of the server.
Non-transactional request:
A request to read data only and not modify it.
2. Leader Leader
Leaders will deal with them differently according to different requests.
3. Follower Follower
① sends a request to the leader
② receives messages from leaders and processes them
③ receives the client request, and if it is a write, it needs to be sent to the leader for half the vote.
④ returns the request result to the client.
4. Observer Observer
Except for not participating in the Leader election and Proposal voting, it has the same function as Follower.
[IV. Zab protocol in Zookeeper]
All write requests from the ① client are forwarded to the only leader Leader in the service, and then the leader Leader initiates a Proposal request based on the request
Other ② follow services to vote on the Proposal request to see if they support the request
③ leader Leader collects votes, and when more than half the votes are counted, leader Leader sends a notification to all services.
The server to which the ④ client connects receives the message, performs the operation, and responds to the client.
[v. Zookeeper node]
There are four common nodes in Zookeeper:
① persistence: PERSISTENT, [persistence node]
② PERSISTENT_SEQUENTIAL, which is sequentially automatically numbered [persistent nodes], which is automatically added by 1 according to the number of existing nodes.
③ EPHEMERAL, [temporary node], client session timeout, such nodes will be automatically deleted
④ EPHEMERAL_SEQUENTIAL, [temporary Node] temporarily automatically numbering nodes.
Then these four kinds of nodes can be divided!
According to persistence
Persistence: PERSISTENT, PERSISTENT_SEQUENTIAL
Temporary: EPHEMERAL, EPHEMERAL_SEQUENTIAL
It can also be divided according to the type.
Directory nodes: PERSISTENT, EPHEMERAL
Numbered catalog nodes: PERSISTENT_SEQUENTIAL, EPHEMERAL_SEQUENTIAL
After reading the above, do you have any further understanding of Zookeeper? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
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.