Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install a Zookeeper cluster

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to install a Zookeeper cluster. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Overview of zookeeper

What is zookeeper? Why is zookeeper so important in big data's field? Let's start with the basics.

Zookeeper is an open source framework for distributed coordination services. Its main function is to solve the problem of data consistency in distributed clusters. Zookeeper is essentially a small file system. Its data structure is similar to the directory tree of the file system, and zookeeper can manage these nodes effectively. Through node management, the goal of monitoring and maintaining node data is achieved. By monitoring the changes of data, to achieve the purpose of managing the cluster. Common applications such as configuration management, name service, distributed message queue, distributed lock, distributed coordination service and so on.

Zookeeper characteristics

Data consistency: in a zookeeper cluster, each server keeps a copy of the same data. No matter which server client connects to, the data displayed is consistent. This is a very important feature of zookeeper and the basis of its wide application in big data field.

Reliability: if the client request is accepted by any server, the request will be accepted by the entire cluster.

Orderability: there are two kinds of global order and partial order. Global ordering means that if message an is published before message b on a server, message an is published before message b on all server. The partial order means that message an is published by the same server before message b, then message a must precede message b.

Atomicity of data updates: either a data update succeeds or fails, and there is no intermediate state.

Real-time: zookeeper ensures that the client gets the response from the server within a certain time interval, regardless of success or failure.

Zookeeper role

Leader: is the core of the normal operation of the cluster. The only handler and scheduler of transactional (write) requests. Managers and dispatchers within the cluster.

Follower: handles non-transactional requests, participates in cluster leader elections, and forwards transactional requests to leader.

Observer: handles non-transactional requests, does not participate in leader elections, and forwards transactional requests to leader. If the cluster has a lot of read requests, you can add the observer role to improve the non-transactional capabilities of the cluster.

Zookeeper installation

The installation of zookeeper is divided into stand-alone version and cluster version, and the stand-alone version is mainly used for debugging. Let's demonstrate how to install a cluster version in a virtual machine. Zookeeper clusters are usually made up of odd nodes to ensure the election of cluster leader (based on the paxos algorithm, which is not covered in this article). This demo uses three machines to install a zookeeper cluster.

1. Install jdk, all three machines must be installed

Download address https://www.oracle.com/technetwork/java/javase/downloads / index.htmljdk-8u211-linux-x64.rpm# install rpm-ivh jdk-8u211-linux-x64.rpm# switch javaalternatives-- config java

two。 Download the zookeeper installation package

Download address: https://archive.apache.org/dist/zookeeper/ installation package version: zookeeper-3.4.5.tar.gz

3. Configure hostname Mappin

Vim / etc/hosts192.168.80.10 node1192.168.80.11 node2192.168.80.12 node3

4. Modify zookeeper configuration file

Tar-zxvf zookeeper-3.4.5.tar.gz-C / servers/cd / serversln-s zookeeper-3.4.5/ zookeepercd / servers/zookeeper/confcp zoo_sample.cfg zoo.cfgvim zoo.cfg# adds the following configuration information tickTime=2000dataDir=/servers/zookeeper / dataclientPort=2181server.1=node1:2888:3888server.2=node2:2888:3888s erver.3=node3:2888:3888 to zoo.cfg

5. Set up the myid file

The myid file contains only one number, and the value ranges from 1 to 255. The location of the Myid file is in the data directory, specified by the dataDir parameter.

Cd / servers/zookeeper/dataecho 1 > myid Note that the values in myid must be unique. Here, our three machines are set to 1mem2 and 3 respectively.

6. Start zookeeper

. / zkServer.sh start

7. View role status

/ servers/zookeeper/bin/zkServer.sh status Thank you for your reading! This is the end of the article on "how to install Zookeeper clusters". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report