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 zookeeper pseudo-cluster

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

Share

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

This article will explain in detail how to install zookeeper pseudo-cluster, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Zookeeper installation configuration

Download the official website address https://zookeeper.apache.org/. Remember to choose whether to download another image from the http image. Select the image to view-> https://jingyan.baidu.com/album/335530dafd4b3619cb41c3d8.html tutorial

Baidu network disk link: https://pan.baidu.com/s/1AN_kS9fO_uiN95hlhm-6xw extraction code: ndtz

Zookeeper installation does not distinguish between win, linux, mac direct decompression. Download with bin is only the class file, without bin is the java file is recommended with bin, the file is small.

If win runs the .cmd suffix startup file under bin directly, if linux and mac directly run the .sh startup file under bin

Configure pseudo-cluster

Parameter description:

TickTime: the basic unit of time used in zookeeper, the millisecond value. DataDir: data directory. It can be any directory. DataLogDir: log directory, which can also be any directory. If this parameter is not set, the same setting as dataDir will be used. ClientPort: the port number that listens for client connections. At this point, the stand-alone mode of zookeeper has been configured. To start server, simply run the script:

Bin/zkServer.sh start

After Server starts, you can start client to connect to server and execute the script:

Bin/zkCli.sh-server localhost:4180

Pseudo-cluster mode means to start multiple zookeeper processes in a single machine and form a cluster. Take starting 3 zookeeper processes as an example.

Make 2 copies of the catalog of zookeeper:

|-- zookeeper0 |-- zookeeper1 |-- zookeeper2

Change the zookeeper0/conf/zoo.cfg file to:

TickTime=2000 initLimit=5 syncLimit=2 dataDir=/Users/heliming/zookeeper0/data dataLogDir=/Users/heliming/zookeeper0/logs clientPort=4180 server.0=127.0.0.1:8880:7770 server.1=127.0.0.1:8881:7771 server.2=127.0.0.1:8882:7772

Several new parameters have been added, which mean as follows:

InitLimit: the zookeeper cluster contains multiple server, one of which is leader, and the rest of the server in the cluster is follower. The initLimit parameter configures the maximum heartbeat time between follower and leader when initializing the connection. At this point, the parameter is set to 5, indicating that the time limit is 5 times tickTime, that is, 5*2000=10000ms=10s.

SyncLimit: this parameter configures the maximum length of time to send messages, requests and replies between leader and follower. At this point, the parameter is set to 2, indicating that the time limit is 2 times tickTime, that is, 4000ms.

Server.X=A:B:C where X is a number, indicating which number server this is. An is the IP address where the server is located. B configure the port that the server uses to exchange messages with the leader in the cluster. C configure the port used to elect leader. Because the pseudo-cluster mode is configured, the B and C parameters of each server must be different.

Refer to zookeeper0/conf/zoo.cfg, configure zookeeper1/conf/zoo.cfg, and zookeeper2/conf/zoo.cfg files. Just change the parameters dataDir, dataLogDir, and clientPort.

Create a new myid file in the previously set dataDir and write a number indicating the number server. The number must correspond to the X in server.X in the zoo.cfg file. If it is windows, you can create myid.txt and write numbers in it, and then modify the file format to remove the suffix.

Write 0 in / Users/heliming/zookeeper0/data/myid file / Users/heliming/zookeeper1/data/myid file write 1 / Users/heliming/zookeeper2/data/myid file write 2

Go to / Users/apple/zookeeper0/bin, / Users/heliming/zookeeper1/bin, / Users/heliming/zookeeper2/bin, respectively, and start server. Select any server directory and start the client:

Bin/zkCli.sh-server localhost:4180

Extract to the appropriate directory. Go to the confs subdirectory under the zookeeper directory and create a zoo.cfg:

TickTime=2000 dataDir=/Users/heliming/zookeeper/data dataLogDir=/Users/heliming/zookeeper/logs clientPort=4180

Cluster mode

The configuration of cluster mode is basically the same as that of pseudo-cluster. Because in cluster mode, each server is deployed on different machines, the conf/zoo.cfg files of each server can be exactly the same. Here is an example:

TickTime=2000 initLimit=5 syncLimit=2 dataDir=/home/zookeeper/data dataLogDir=/home/zookeeper/logs clientPort=4180 server.43=10.1.39.43:2888:3888 server.47=10.1.39.47:2888:3888 server.48=10.1.39.48:2888:3888

In the example, three zookeeper server are deployed on 10.1.39.43,10.1.39.47,10.1.39.48 respectively. It is important to note that the numbers in the myid file in the dataDir directory of each server must be different.

10.1.39.43 server myid 43 10.1.39.47 server myid 47 10.1.39.48 server myid 48

On how to install zookeeper pseudo-cluster to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it 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