1. Official website homepage:

zookeeper.apache.org/

2. Download the screenshot, as shown in Figure 5-5, 5-6, 5-7



1. Cluster planning

Zookeeper is deployed on hadoop102, Hadoop103, and Hadoop104.

2. Unpack the installation

(1) Decompress the Zookeeper installation package to /opt/module/

[atguigu@hadoop102 software]$tar -zxvf zookeeper-3.4.10.tar.gz -c /opt/module/

(2) Synchronize the /opt/module/zookeeper-3.4.10 directory to hadoop103 and hadoop104

[atguigu @ hadoop102 module] $xsync zookeeper 3.4.10 /

3. Configuring the Server Number

Create zkData in /opt/module/zookeeper-3.4.10/

[atguigu@hadoop102 zookeeper-3.4.10]$mkdir -p zkData

Create a myID file in /opt/module/zookeeper-3.4.10/zkData

[atguigu@hadoop102 zkData]$ touch myid

Add myid file, be sure to create in Linux, in notepad++ is likely to be garbled

(3) Edit myID file

[atguigu@hadoop102 zkData]$ vi myid

Add the number corresponding to server to the file:

2

(4) Copy the ZooKeeper configuration to another host

[atguigu@hadoop102 zkData]$ xsync myid

And change the contents of myID file to 3 and 4 on hadoop102 and hadoop103 respectively

4. Configure the zoo. CFG file

(1) Rename zoo_sample. CFG in the /opt/module/zookeeper-3.4.10/conf directory to zoo.cfg

[atguigu@hadoop102 conf]$ mv zoo_sample.cfg zoo.cfg

(2) Open zoo. CFG file

[atguigu@hadoop102 conf]$ vim zoo.cfg

Example Modify data store path configuration

DataDir = / opt/module/zookeeper – 3.4.10 / zkData

Add the following configuration

#######################cluster##########################

server.2=hadoop102:2888:3888

server.3=hadoop103:2888:3888

server.4=hadoop104:2888:3888

(3) Synchronize the zoo. CFG configuration file

[atguigu@hadoop102 conf]$ xsync zoo.cfg

(4) Interpretation of configuration parameters

Server. A = B: C: D.

A is A number that indicates the server number;

In cluster mode, A file myID is configured, which is in the dataDir directory. There is A data in this file that is the value of A. When Zookeeper starts up, it reads this file and compares the data with the configuration information in zoo.cfg to determine which server it is.

B is the IP address of the server;

C is the port on which the server exchanges information with the Leader server in the cluster;

In case the Leader server in the cluster fails, a port is needed to re-elect a new Leader, and this port is used to communicate with each other during the election.

4. Cluster operations

(1) Start Zookeeper respectively

[atguigu @ hadoop102 zookeeper – 3.4.10] $bin/zkServer. Sh start

[atguigu @ hadoop103 zookeeper – 3.4.10] $bin/zkServer. Sh start

[atguigu @ hadoop104 zookeeper – 3.4.10] $bin/zkServer. Sh start

(2) Check the status

[atguigu @ hadoop102 zookeeper – 3.4.10] # bin/zkServer. Sh status

JMX enabled by default

Using the config: / opt/module/zookeeper – 3.4.10 / bin /… /conf/zoo.cfg

Mode: follower

[atguigu @ hadoop103 zookeeper – 3.4.10] # bin/zkServer. Sh status

JMX enabled by default

Using the config: / opt/module/zookeeper – 3.4.10 / bin /… /conf/zoo.cfg

Mode: leader

[atguigu @ hadoop104 zookeeper – 3.4.5] # bin/zkServer. Sh status

JMX enabled by default

Using the config: / opt/module/zookeeper – 3.4.10 / bin /… /conf/zoo.cfg

Mode: follower