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 and configure ZooKeeper Cluster

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

Share

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

This article mainly shows you "how to install and configure ZooKeeper cluster", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to install and configure ZooKeeper cluster".

Download the ZooKeeper package from the Apache website (zookeeper.apache.org)

It is very easy to install on a Linux machine, as long as you unzip it and simply configure it to start the ZooKeeper server process.

ZooKeeper Standalone mode

Change the zoo_sample.cfg under the zookeeper-3.3.4/conf directory to zoo.cfg, and the contents of the configuration file are as follows:

TickTime=2000

DataDir=/home/hadoop/storage/zookeeper

ClientPort=2181

InitLimit=5

SyncLimit=2

The explanation is as follows:

TickTime-- the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice the tickTime.

DataDir-the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.

ClientPort-the port to listen for client connections

Start the ZooKeeper server process below:

Cd zookeeper-3.3.4/

Bin/zkServer.sh start

The ZooKeeper server process, named QuorumPeerMain, can be viewed through the jps command.

On the client side, connect to the ZooKeeper server and execute the following command:

Bin/zkCli.sh-server dynamic:2181

The above dynamic is my hostname. If it is executed locally, execute the following command:

Bin/zkCli.sh

Next, you can use help to view the basic operational commands that can be used by the Zookeeper client.

ZooKeeper Distributed mode

Step 1: host name to IP address mapping configuration

172.37.0.201 slave1.hadoop slave1

172.37.0.202 slave2.hadoop slave2

172.37.0.203 slave3.hadoop slave3

Step 2: modify the ZooKeeper configuration file

TickTime=2000

DataDir=/tmp/hadoop-root/zookeeper

ClientPort=2181

InitLimit=5

SyncLimit=2

Server.1= slave1.hadoop:2888:3888

Server.2= slave2.hadoop:2888:3888

Server.3= slave3.hadoop:2888:3888

Step 3: copy and distribute installation files remotely

Scp-r zookeeper-3.4.6 root@172.37.0.201:/home/hadoop/

Scp-r zookeeper-3.4.6 root@172.37.0.202:/home/hadoop/

Step 4: set up myid

Under the directory specified by the dataDir (/ tmp/hadoop-root/zookeeper) we configured, create a myid file with a number that identifies the current host and why the number X is in the server.X configured in the conf/zoo.cfg file. Enter this number in the myid file, for example:

Slave3.hadoop echo "1" > / tmp/hadoop-root/zookeeper/myid

Slave2.hadoop echo "2" > / tmp/hadoop-root/zookeeper/myid

Slave1.hadoop echo "3" > / tmp/hadoop-root/zookeeper/myid

Step 5: modify the environment variable (all nodes)

[root@slave3 ~] # vim .bashrc

Add:

Export ZOOKEEPER_HOME=/home/hadoop/zookeeper-3.4.6

Export PATH=$PATH:$ZOOKEEPER_HOME/bin

[root@slave3 ~] # source .bashrc

Step 6: start the ZooKeeper cluster

The command is as follows:

[root@slave3 ~] # zkServer.sh start

[root@slave2 ~] # zkServer.sh start

[root@slave1 ~] # zkServer.sh start

LOG:

JMX enabled by default

Using config: / home/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfg

Starting zookeeper... STARTED

JPS results:

540 QuorumPeerMain

View status: zkServer.sh status

Slave2.hadoop

JMX enabled by default

Using config: / home/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: leader

Slave1.hadoop

JMX enabled by default

Using config: / home/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: follower

Slave3.hadoop

JMX enabled by default

Using config: / home/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: follower

Cluster configuration complete!

These are all the contents of the article "how to install and configure ZooKeeper clusters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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