In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1 Zookeeper introduction
Zookeeper is an open source distributed application coordination service.
To put it simply, zookeeper = notification mechanism + file system
Why is zookeeper odd?
Zookeeper has such a feature: as long as more than half of the machines in the cluster are working properly, then the whole cluster is available externally. That is to say, if there are 2 zookeeper, as long as 1 is dead, the zookeeper cannot be used, because 1 is not more than half, so the death tolerance of 2 zookeeper is 0; similarly, if there are 3 zookeeper, one is dead, there are 2 normal ones left, more than half, so the tolerance of 3 zookeeper is 1.
1.1 Primary roles
From the server side
> > the leader (leader) is responsible for initiating and deciding votes, updating system status (data synchronization), and sending heartbeats.
> > learners (learner), including followers (follower) and observers (observer).
> > follower (follower), which is used to accept client requests, return results to the client, and participate in voting during the selection process.
> > Observer can accept client requests and forward write requests to leader, but observer does not participate in the voting process and only synchronizes the status of leader. The purpose of observer is to expand the system and improve the reading speed.
1) when the leader fails, the new leader will be re-elected in the follower.
2) each follower is connected to leader and accepts data update operations from leader.
3) the client can connect to each server, and the data of each server is exactly the same
4) Service Server for each node, recording transaction logs and snapshots to persistent storage
1.2 how it works
The core of Zookeeper is atomic broadcasting, which ensures synchronization between Server. The protocol that implements this mechanism is called the Zab protocol.
There are two modes of Zab protocol, which are recovery mode (primary mode) and broadcast mode (synchronization). When the service starts or after the leader crashes, the Zab enters the recovery mode, which does not accept client requests, and when the leader is elected and most of the Server is finished synchronizing with the status of the leader, the recovery mode ends. State synchronization ensures that leader and Server have the same system state.
1.2.1 Zookeeper node data operation flow
1) write operation
Initiate a proposal proposal
Quorum quorum
1) issue a write request to Follwer or Observer at Client
2) Follwer or Observer sends the request to Leader
3) after receiving, Leader initiates a proposal to all follower
4) Follwer performs a write operation after receiving the proposal, and then sends the operation result to Leader
5) when most follower returns the result of the proposal, leader will commit the proposal and notify other Follower and Observer synchronization information
6) Follwer or Observer returns the result of the request to Client.
2) read operation
1) send a read request to Follwer or Observer at Client
2) Follwer or Observer returns the result of the request to Client
1.3 data model
1) ZooKeeper is essentially a distributed small file storage system.
2) Zookeeper is a hierarchical file system directory tree structure (unlike the file system, the node can have its own data, while the directory node in the file system has only child nodes), each node can store a small amount of data.
3) each node is called a ZNode. Each ZNode can be uniquely identified by its path.
4) Circular nodes can contain child nodes, and polygon nodes cannot contain child nodes. A node corresponds to an application, and the data stored by the node is the information needed by the application, such as HA status active, standby.
1.4 main features
Ultimate consistency: no matter which Server client is connected to, it is shown to it in the same view, which is the most important feature of zookeeper
Reliability: simple, robust, good performance, if the message is accepted by a server, then it will be accepted by all servers
Real-time: Zookeeper ensures that the client will get the update information of the server or the information of server failure within a time interval. However, due to network delay and other reasons, Zookeeper cannot guarantee that two clients can get the newly updated data at the same time. If the latest data is needed, the sync () interface should be called before reading the data.
Wait irrelevant (wait-free): slow or invalid client must not interfere with fast client requests, so that each client can wait effectively
Atomicity: updates can only succeed or fail, with no intermediate state
Sequency: update data in the order in which the client sends the request
1.5 Application scenario
Data publishing and subscription
The application configuration is centralized on the node, and the application is actively acquired when the application is started, and a watcher is registered on the node. Each configuration update will notify the application.
Publish and subscribe model
Namespace service
Distributed naming service, after creating a node, the path of the node is globally unique and can be used as a global name.
Distributed notification / coordination
Different systems listen to the same node, and once there is an update, another system can be notified.
Distributed lock
Zookeeper can ensure the strong consistency of data, and users can believe that the data of each node in the cluster is the same at any time. One user creates a node as a lock, and another user detects the node. If it exists, it means that another user has locked it. If it does not exist, a node can be created, which means that it has a lock.
[]
Cluster management
Each machine that joins the cluster creates a node and writes its own state. Users who monitor the parent node will be notified and processed accordingly. The node is deleted when you leave, and the user who monitors the parent node is also notified.
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.