ZooKeeper3. 4.6 construction of distributed environment

Miss Zhu 2022-02-13 08:38:39 阅读数:31

zookeeper3. zookeeper construction distributed environment

Used this time ZooKeeper3 by ZooKeeper3,Linux Issued as CentOS7.

Host name IP
zk1 192.168.150.21
zk2 192.168.150.22
zk3 192.168.150.23

Lead to :

One 、 build hp301
static state IP、 Turn off firewall , close selinux, Name the host as zk1, modify hosts Make a mapping , modify ip Address .
See :Hadoop3.3.1 Detailed tutorial ( Two ) Prototype configuration
Two 、 install JDK
See :Hadoop3.3.1 Detailed tutorial ( 3、 ... and ) Clone the prototype +JDK install
3、 ... and 、 Password free login
See :Hadoop3.3.1 Detailed tutorial ( Four )Linux Cluster building + Password free login

install ZooKeeper

1. download ZooKeeper3.4.6, And upload them to hp301 Of /apps Under the table of contents

2. Unzip to /usr/local under :

tar -xzf /apps/zookeeper-3.4.6.tar.gz -C /usr/local

3. by ZooKeeper Create a soft connection :
 Insert picture description here
4. modify ZooKeeper environment variable :

vi /etc/profile.d/zookeepr.sh

edit :

export ZOOKEEPER_HOME=/usr/local/zookeeper3
export PATH=$PATH:$ZOOKEEPER_HOME/bin

source Make it effective .

5. To configure ZooKeeper
1) stay linux Root directory / Create a new folder to save transaction logs and data zk_data, Build a new one under it zk_data Catalog , stay zk_data New under the directory data Contents and logs Catalog .
 Insert picture description here
2) Copy zookeeper3/conf Under the zoo_sample.cfg Renamed as zoo.cfg, And modify the allocation information :

zoo.cfg Of dataDir=/zk_data/data

Add one dataLogDir:

dataLogDir=/zk_data/logs

3)6. Configure cluster nodes :
server.n=ip:A:B
# n It's the node number , Generally from 1 Start
# ip It is the server of the node in the cluster IP Address
# A yes LF Communication port , Represents the server and the leader The port of information exchanged , The default is 2888
# B It's an election port , To vote for a new leader When the servers communicate with each other ( When leader Hang up , The rest of the servers will communicate with each other , Choose a new leader), The default is 3888

Three virtual machines , You can configure it like this , Copied to the zoo.cfg Last :

server.1=zk1:2888:3888
server.2=zk2:2888:3888
server.3=zk3:2888:3888

4) stay zk_data/data Create a new one in myid file , Fill in 1, Means the above server.1

6. Build clusters
Clone out zk2、zk3、 modify hostname、ip Address 、/zk_data/data/myid The values of are 2、3
You can also use the distribution method .

7. start-up ZooKeeper:

 # start-up , The default is background startup , At present shell Not blocked 
zkServer.sh start
# start-up , It can lead to shell Blocked 
zkServer.sh start-foreground
# stop it 
zkServer.sh stop
# restart 
zkServer.sh restart
# View the current node status 
zkServer.sh status
# upgrade It's an upgrade ,print-cmd It's a print order , These two use less 

If you just start another node Zookeeper, Without starting the cluster , Because three nodes are configured , So you can't vote , In execution zkServer.sh status When will it be reported :

Error contacting service. It is probably not running.

When all three nodes are started, they can be used again zkServer.sh status Command view time , Will see :
hp301、hp303 yes follower
 Insert picture description here
hp302 yes leader
 Insert picture description here

copyright:author[Miss Zhu],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130838366395.html