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 cluster building

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

I built these a long time ago, but now I still write a simple cluster installation blog for reuse, which is convenient to read later. I also hope to give a help to the novice. All right, let's start the construction work ^ _ ^!

Modify hostname

Prod-wuliu-zookeeper1-42-10

Prod-wuliu-zookeeper2-42-11

Prod-wuliu-zookeeper3-42-12

Configuration / etc/hosts

172.16.42.10 zookeeper1

172.16.42.11 zookeeper2

172.16.42.12 zookeeper3

Install jdk

Extract jdk to / opt/jdk

# set java evironment

Export JAVA_HOME=/opt/jdk

Export JAVA_BIN=/opt/jdk/bin

Export JRE_HOME=/opt/jdk/jre

Export PATH=$ {JAVA_HOME} / bin:$PATH

Export CLASSPATH=.:$ {JAVA_HOME} / lib/dt.jar:$ {JAVA_HOME} / lib/tools.jar

# add

Verify that the jdk installation is successful

Java-version to view the version of jdk

Download the package to / opt/zookeeper

See the official zookeeper documentation for single point configuration.

Https://zookeeper.apache.org/doc/r3.4.10/zookeeperStarted.html#sc_Download

Configure related directories

Mkdir-p / opt/zookeeper/data

Mkdir-p / opt/zookeeper/logs

Cluster configuration

TickTime=2000

InitLimit=10

SyncLimit=5

DataDir=/opt/zookeeper/data

ClientPort=2181

DataLogDir=/opt/zookeeper/logs

Server.1=zookeeper1:2888:3888

Server.2=zookeeper2:2888:3888

Server.3=zookeeper3:2888:3888

Set the myid configuration file in the dara directory. The configuration file of myid corresponds to the value of server.id one by one.

Start zookeeper

1. Start a node first

. / zkServer.start

2. Then start the remaining two nodes

. / zkServer.sh status to view the current role of zookeeper

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.

Write 0 in / Users/apple/zookeeper0/data/myid file, 1 in / Users/apple/zookeeper1/data/myid file, and 2. 0 in / Users/apple/zookeeper2/data/myid file.

Go to / Users/apple/zookeeper0/bin, / Users/apple/zookeeper1/bin, / Users/apple/zookeeper2/bin, respectively, and start server.

Select any server directory and start the client:

Bin/zkCli.sh-server zookeeper1:2181

Ls /

[zookeeper]

Zookeeper's reference address for cluster building:

Http://www.cnblogs.com/xujishou/p/6477944.html

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

Servers

Wechat

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

12
Report