ZooKeeper installation and deployment configuration under Centos (cluster mode)

Keywords: Zookeeper Hadoop vim Mac

catalog

Step 1: prepare documents

(1) Upload file

Upload the compressed file of zookeeper to node1. The Mac system can upload directly through the terminal scp command, and the Windows system can upload through other upload tools. Upload method:

scp / native path of own computer / zookeeper-3.4.13 tar.gz  caizhengjie@10.211.55.59 :/home/caizhengjie/Hadoop

(2) Unzip files

After the upload is successful, you need to give permission to the file

chmod u+x zookeeper-3.4.13.tar.gz

Unzip file:

tar -zxvf zookeeper-3.4.13.tar.gz

To create a soft link:

ln -s zookeeper-3.4.13 zookeeper

Step 2: modify the configuration file

(1) Rename file

When installing zookeeper, we need to modify the zookeeper pre installed under the conf directory_ sample.cfg This file, the first thing we have to do is rename this file. In the directory / home/caizhengjie/Hadoop/zookeeper/conf, change the_ sample.cfg Renamed zoo.cfg File. This step is very important. If it is not modified, the following problems will occur:

ZooKeeper JMX enabled by default
Using config: /home/caizhengjie/zookeeper/bin/../conf/zoo.cfg
grep: /home/caizhengjie/zookeeper/bin/../conf/zoo.cfg: There is no file or directory
mkdir: Unable to create directory"": There is no file or directory
Starting zookeeper ... /home/caizhengjie/zookeeper/bin/zkServer.sh:Line 149: /zookeeper_server.pid: insufficient privilege
FAILED TO WRITE PID

This is the first pit!
Then we need to change the file name:

mv zoo_sample.cfg  zoo.cfg

(2) Create tmp folder

cd /home/caizhengjie/Hadoop/zookeeper/
mkdir tmp
cd tmp
mkdir data

(3) Create a myid file

cd /home/caizhengjie/Hadoop/zookeeper/tmp/data
vim myid

First host node1 add content: 1
Note: be sure to create myid in the data folder you just created
If you directly create a myid file in the tmp folder, check the zookeeper.out Log files will report errors

Caused by: java.lang.IllegalArgumentException: /home/caizhengjie/Hadoop/zookeeper/tmp/data/myid file is missing

This is the second pit!

(4) Modify profile

Modify zookeeper/conf zoo.cfg file

vim zoo.cfg
#The number of milliseconds of each tick
tickTime=2000
#The number of ticks that the initial 
#synchronization phase can take
initLimit=5
#The number of ticks that can pass between 
#sending a request and getting an acknowledgement
syncLimit=2
#the directory where the snapshot is stored.
#do not use /tmp for storage, /tmp here is just 
#example sakes.
#**This place fills in its own path**
dataDir=/home/caizhengjie/Hadoop/zookeeper/tmp/data
#the port at which the clients will connect
clientPort=2181
#the maximum number of client connections.
#increase this if you need to handle more clients
#maxClientCnxns=60 
#Server name and address: cluster information (server number, server number, server address, LF communication port, election port)
server.1=node1:2888:3888
server.2=node3:2888:3888
server.3=node3:2888:3888

Step 3: configure environment variables

Configure environment variables:

vim ~/.bashrc

Add the following:

export ZOOKEEPER_HOME=/home/caizhengjie/Hadoop/zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH

It needs to be filled in according to the installation path
Make it effective:

source ~/.bashrc

Step 4: distribute documents

(1) Distribution of documents

After node1 is configured, the files need to be distributed to node2 and node3 machines.

scp -r zookeeper zookeeper-3.4.13 zookeeper-3.4.13.tar.gz caizhengjie@node2:/home/caizhengjie/Hadoop/
scp -r zookeeper zookeeper-3.4.13 zookeeper-3.4.13.tar.gz caizhengjie@node3:/home/caizhengjie/Hadoop/

(2) Configuration environment variables of 2 and 3 computers

Configuration method of reference node1

(3) Modify myid file

Previously, in the / home/caizhengjie/Hadoop/zookeeper/tmp/data/myid file, the first host added content: 1
In node2 and node3, you can modify them as follows
Content added to the second host: 2
Content added to the third host: 3

Step 5: start and view the operation status

After the above steps are completed, you can start zookeeper
Start command (three machines start at the same time):

zkServer.sh start

Close command:

zkServer.sh stop

The installation is successful if

ZooKeeper JMX enabled by default
Using config: /home/caizhengjie/Hadoop/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

Verify jps process

4616 Jps
2041 QuorumPeerMain

Check operation status (three machines at the same time)

zkServer.sh status

node1

ZooKeeper JMX enabled by default
Using config: /home/caizhengjie/Hadoop/zookeeper/bin/../conf/zoo.cfg
Mode: follower

node2

ZooKeeper JMX enabled by default
Using config: /home/caizhengjie/Hadoop/zookeeper/bin/../conf/zoo.cfg
Mode: leader

node3

ZooKeeper JMX enabled by default
Using config: /home/caizhengjie/Hadoop/zookeeper/bin/../conf/zoo.cfg
Mode: follower

You will find that one of the machines is leader and the other two are follower
The zookeeper cluster mode has been successfully installed here!

Summary: if there is an error in the operation, look more zookeeper.out log file

The above content is for reference only. If there is infringement, please contact me to delete it!
If this article is helpful to you, the thumb in the lower left corner is the biggest encouragement to bloggers. Your encouragement is the biggest power of bloggers!

Posted by darkfreaks on Mon, 15 Jun 2020 22:32:36 -0700