In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Java big data development of ZooKeeper entry operation is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
1.1 Overview
ZooKeeper translates the Chinese name as zookeeper. Does that mean it has something to do with animals? The answer is yes and no. Why would you say that? In fact, zookeepers do not manage real animals, but many frameworks named after animals use ZooKeeper. Many frameworks in big data are related to animals, such as pig,hive, and so on. Foreigners are too casual in naming the framework, so they can come up with it at once.
ZooKeeper is an open source distributed Apache project that provides coordination services for distributed applications, produced by Apache, so it must not be much worse.
1.2 working mechanism
Zookeeper is understood from the perspective of design pattern: it is a distributed service management framework based on the observer pattern, which is responsible for storing and managing the data that everyone cares about, and then accepts the registration of the observers. Once the state of the data changes, Zookeeper will be responsible for notifying the observers who have registered on the Zookeeper to respond accordingly, thus realizing a similar Master/Slave management pattern in the cluster, which is difficult to understand. Let's take a look at the following picture:
Let's go through every step of the working mechanism in detail:
1 in the ① figure indicates that when the server starts, it registers information with ZooKeeper (hereinafter referred to as ZK).
2 in the ② figure shows that the client gets the list of current online servers and registers listening
③ figure 3 shows that a buddy with a disabled hand has hung up a server, and server 2 is now down.
4 in the ④ figure indicates that ZK does not receive a small biubiu sent by server 2 for a period of time and will notify the client through server online and offline events.
5 in the ⑤ figure indicates that the list of servers is retrieved and listeners are registered.
1.3Features of ZK
The image above shows a ZK cluster. Let's take a look at their characteristics:
① ZK cluster, which is composed of a leader (leader) and multiple followers (follower)
As long as more than half of the ② nodes survive, the ZK cluster can be used normally. There must be some cute people who will have doubts. What if two of the four machines fail? In that case, there is only one half left in our cluster, which is not called "more than half", all right, so we can't use two out of four. In order to distinguish what is more than half, remember, when building a cluster, we build odd-numbered stations, which is easy to do.
Each server of ③ keeps a copy of the data, and the data is consistent no matter which server the client connects to. Friends need to be clear: the data here refers to the status information of the cluster server, which has nothing to do with the data in your database.
④ update requests from the same client are sent on schedule and executed in turn.
⑤ atomicity: cluster machines either succeed or fail in one data update.
⑥ in a certain time range, the client can read the latest data.
You should understand at least half of these features (mainly the first few, of course).
1.4 Application scenario
1.4.1 Unified naming Service
In the distributed environment, it is necessary to name the application / service uniformly, which is easy to identify.
1.4.2 Unified configuration Management
In the distributed environment, the configuration information of all nodes in the cluster is required to be consistent, and the modified configuration files also need to be quickly synchronized to each node. Configuration management can be implemented by ZK. The process is as follows:
① can write configuration information to a node of ZK
② each client server listens to this node
③ once the node data is modified, ZK will notify each client server
1.4.3 Unified cluster management
In the distributed environment, it is necessary to grasp the state of each node in real time, and make some adjustments according to the real-time status. ZK can monitor the changes of node status in real time. The implementation process is as follows:
① can write node information to a node of ZK.
② listens to nodes to obtain node status information in real time
1.4.4 soft load balancing
You can select the server with the least number of visits according to the number of visits to each server.
1.5 Software download
Official website download page address: https://zookeeper.apache.org/releases.html
1.6 ZK installation (stand-alone mode, informal environment, available for testing)
1.6.1 preparation before installation
① install JDK
② copies the ZK installation package to Linux
Extract the ③ to the specified directory
Create a dev folder under the opt directory, and you will extract the files here later.
1.6.2 configuration modification
① modifies zoo_sample.cfg to zoo.cfg under the path / opt/dev/zookeeper-3.4.10/conf
② edits zoo.cfg, modifies dataDir path
1.6.3 operate ZK
① starts ZK
Command: [root@hadoop100 bin] #. / zkServer.sh start
② to see if the process is started
Command: jps
③ View status
Command: [root@hadoop100 bin] #. / zkServer.sh status
④ starts the client
Command: [root@hadoop100 bin] #. / zkCli.sh
⑤ exits the client
Command: [root@hadoop100 bin] # quit
⑥ stop ZK
Command: [root@hadoop100 bin] #. / zkServer.sh stop
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.