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 > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. brief introduction
Zookeeper is an efficient distributed coordination service, which can provide configuration information management, naming, distributed synchronization, cluster management, database switching and other services. It is not suitable to store a large amount of information, but can be used to store a small amount of information such as configuration, publication, subscription and so on. Hadoop, Storm, message middleware, RPC service framework and distributed database synchronization system are all application scenarios of Zookeeper.
The number of nodes in a Zookeeper cluster is generally odd (> = 3). If the Master in the cluster is dropped and the number of remaining nodes is more than half, you can recommend a new master node to continue to provide services.
1. Typical application scenarios
1) distributed Notification / Coordination
Task distribution and task execution for distributed systems, line result feedback
2) Cluster management
-can monitor the survival status of nodes
3) Master election
In a system with Master/slave structure, to avoid a single point of failure, multiple master are required, in which
Only one active master,ZooKeeper helps to select active master
4) distributed lock
-monopolization: only one client can be obtained at a certain time
-Control timing: some processes of multiple clients execute rows sequentially
5) distributed queue
Https://blog.csdn.net/king866/article/details/53992653/
2. Architecture
2.1, Node
-2N+1 consists of 1 server. When one node is available, the whole system remains usable.
2.2, server Corner Color Typ
-Server: store data (in-memory)
-Leader: do not accept the client request, be responsible for initiating and deciding the voting of the advanced bank, and finally update the status-Follower: receive the customer request and return the customer result, participate in the vote initiated by Leader
3. ObServer node
problem
When the client becomes more, the ZK cluster becomes larger, and the nodes are all follower, the updated version is larger.
Solution scheme
ObServer node: interacts with client, keeps a copy of the data, and does not participate in voting
4. Role
5. ZooKeeper commitment
5.1, sequentiality
Client's update requests are processed sequentially according to the order in which they are sent.
5.2. Atomicity
A update operation either succeeds or fails, and there are no other possible results
5.3. Strong consistency
No matter which server client is connected to, the display shows it the same view.
5.4. Reliability
Once the update succeeds, it is persisted, except for a update request to update the current value
5.5, real-time
For each client, its system view is up to date
II. Preparatory work
1. System environment
Hostnam
System
Service version
IP
Master
CentOS7.4
3.4.12
192.168.56.129
Slave1
CentOS7.4
3.4.12
192.168.56.130
Slave2
CentOS7.4
3.4.12
192.168.56.131
2. Temporarily turn off the firewall and selinux
3. Software download
Download address: http://mirrors.hust.edu.cn/apache/zookeeper/
4. Java environment
Third, service building
1. Decompress the files of three nodes
[root@master ~] # cd / home/
[root@master home] # tar-zxvf zookeeper-3.4.12.tar.gz
[root@master home] # ln-s zookeeper-3.4.12 zookeeper
Note: three nodes have the same operation
2. Create a zoo.cfg file under the conf directory, and the configuration of the three nodes is the same, as follows
[root@master ~] # cd / home/zookeeper/conf/
[root@master conf] # cp zoo_sample.cfg zoo.cfg
[root@master conf] # vim zoo.cfg
TickTime=2000
InitLimit=10
SyncLimit=5
DataDir=/var/lib/zookeeper
ClientPort=2181
MaxClientCnxns=50
Server.1=192.168.56.129:2888:3888
Server.2=192.168.56.130:2888:3888
Server.3=192.168.56.131:2888:3888
3. The contents of creating files / var/lib/zookeeper/myid,3 nodes are 1, 2 and 3 respectively.
[root@master conf] # mkdir-p / var/lib/zookeeper
[root@master conf] # cd / var/lib/zookeeper/
[root@master zookeeper] # vim myid
4. Start three nodes
[root@master zookeeper] # bin/zkServer.sh start
[root@master zookeeper] # jps
[root@master zookeeper] # bin/zkServer.sh status
5. Test
5.1. in any node in zookeeper, execute the instruction zkCli.sh
[root@master zookeeper] #. / bin/zkCli.sh
5.2. enter: help # help
Ls / find root directory
Create / test abc creates nodes and assigns values
Get / test gets the value of the specified node
Set / test cb sets the value of an existing node
Rmr / test Recursive deletion Node
Delete / test/test01 deletes nodes that do not have child nodes
5.3. Related operation commands
New operation
Delete operation
5.4. Viewing tools
View Zookeeper cluster nodes in Eclipse
You can also use ZooInspector to view
Use the ZooInspector tool to view it here
Download address: https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip
Extract it, enter the directory ZooInspector\ build, and double-click to run zookeeper-dev-ZooInspector.jar
Note: only if Java is installed in the Windows environment
Click the connection button in the upper left corner and enter the zk service address: ip:2181
Click OK to view the ZK node information
6. Exception
CONNECTION_LOSS (connection lost)
-eg: the connected server down is dropped
6.2. SESSION_EXPIRED (session invalidation)
-managed by ZooKeeper cluster and not managed by client
-ZooKeeper clears the information related to the session.-this will not happen in the ZK of normal operation.
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.