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

Zookeeper environment configuration

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

First download the linux installation package of zookeeper / / to install zookeeper, you must first install jdk, which is now more than 1.8.

/ / pay attention to the version control. There is no obvious bug for the online version of zookeeper3.4.8. It is necessary to control the version in production.

Upload to linux. Then extract tar-zxvf zookeeper... to the specified file directory -C / usr/local/apps/ cd app/ cd zookeeper.../ take a look at the jar package in his directory structure. There is only one command running in the zookeeper-3.4.5.jar bin directory. In conf, there are configuration files. First of all, go to the configuration file to configure cd conf/ the configuration file to be modified is zoo_sample.cfg (we need to change the name) mv zoo_sample.cfg zoo.cfg ls-l zoo.cfg is the configuration file we want to modify, change it to dataDir=/usr/local/apps/zookeeper-3.4.6/data working directory in vi zoo.cfg, and he must know at the end. What are the server server.1=hadoop-server-00:2888:3888 server.2=hadoop-server-01:2888:3888 server.3=hadoop-server-02:2888:3888 in our cluster (where 2181 represents the port used by the client to connect to the server) (2888 represents the port used for communication between leader and follower) (3888 of them) Representative: the port used to vote in the election between follower)

Note here:

In later production, it will be written here as server.1=ip:2888:3888

Server.2=ip:2888:3888

Server.3=ip:2888:3888

Because: write the host name, zk can get up, kafka can also get up, but kafka when he goes to parse ZK, he will have problems if he doesn't pass etc/hosts.

Inside here, let's go to IP. Pay attention here.

To create a working directory for data under this / root/app/zookeeper-3.4.5/data, mkdir data cd data/ needs to create a file in data that contains the number echo 1 > myid of the server in zookeeper (must be called myid and cannot be named otherwise)

This is done on a host, so we need to distribute the configuration files to each machine.

Change to the installation directory / usr/local/apps/ and copy the equipped zookeeper to the target machine scp-r zookeeper-3.4.6/ hadoop-server-01:/usr/local/apps/ scp-r zookeeper-3.4.6/ hadoop-server-02:/usr/local/apps/ to 01 02 machine respectively Because the myid we set on mainframe 00 is 1, we have to set myid to 2 / 3 on 01 02 and switch to / usr/local/apps/zookeeper-3.4.6/data cd zookeeper-3.4.6/data/ ll on hadoop-server-01. Cat myid echo 2 > myid is the same on hadoop-server-02. So far, zookeeper has been configured. Next, how do I start him?

Sunday, 2019-1-27

Note here, we also need to modify the startup memory size of zookeeper / / for more information on this step, see the Deep Learning kafka Research Notes.

Start the zookeeper cluster

The command to start zookeeper is in the bin directory

Cd bin/

Ll

[zkServer.sh (is the startup command in linux)

Zkserver.cmd (is the startup command in windows)]

. / zkServer.sh start

Jps will see QuorumpeerMain if you look at it.

However, the startup of the program process is not seen in other machines (normal), because this startup script is not responsible for starting service processes on other machines. Each machine needs to be started manually. You can also write a startup script (here we start manually)

Leader server is recommended on every machine by election, so we don't know which machine is leader server and that machine is follower server, so we can see what server is on each machine through. / zkServer.sh status.

When I kill one of the three nodes, it can still work normally, but if I kill two, it will not work properly. Zookeeper has a rule: as long as more than half of the nodes in the cluster are alive, the zookeeper will work normally, and it must be more than half, so why must it be more than half? it comes down to voting, because the voting algorithm in the cluster is random. That is to say, there has to be a machine to be selected as leader server, so when less than half of it cannot be elected, the number of configured server nodes in the leader server cluster is preferably odd.

The functions of zookeeper: / / there are only 2 functions, and the other functions are based on zk

That is, the third party, when you are asked to check the data, you can return it to the client, so he doesn't know what to do.

(the most important function is to keep the data for the client and provide the data monitoring service for the customer)

Data nodes in zookeeper

Each node is called znode and is accessed through a path

Each znode maintains data, stat data structures (ACL timestamp and version number)

The amount of data stored by each node is very small, at the KB level (state data, which is often a sign, cannot be stored in big data)

Zonde has permanent nodes (as long as it is not artificially deleted, it will not disappear, and the next time it is opened), and 00:00 nodes (as long as it is disconnected, it will be gone, and the next time it will not be opened, because it has been deleted).

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