zookeeper installation deployment

zookeeper installation deployment

Here, zookeeper uses zookeeper-3.4.5.tar.gz

1. Local mode installation and deployment

1.1 preparation before installation

(1) zookeeper download address: http://archive.apache.org/dist/zookeeper/

(2) Install jdk

(3) Copy Zookeeper installation package to Linux system

(4) Enter the directory where the zookeeper installation package is stored and unzip it to the specified directory

tar -zxvf zookeeper-3.4.5.tar.gz -C /opt/module/

(5) After decompression, the file name is changed to zookeeper

mv zookeeper-3.4.5 zookeeper

1.2 setting zookeeper environment variable

Command:

vi /root/.bash_profile

Add the following:

export ZOOKEEPER_HOME=/opt/module/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

Make settings effective immediately:

source /root/.bash_profile

1.3 configuration modification

(1) Set / opt/module/zookeeper/conf to the zoo under this path_ Modify sample.cfg to zoo.cfg;

mv zoo_sample.cfg zoo.cfg

(2) Open the zoo.cfg file and modify the dataDir path:

vi zoo.cfg

Amend the following:

dataDir=/opt/module/zookeeper/zkData

(3) Create the zkData folder in the directory / opt/module/zookeeper /

mkdir zkData

1.4 operating Zookeeper

(1) Start Zookeeper

[root@master zookeeper]# bin/zkServer.sh start
 Or enter bin catalogue
[root@master bin]# zkServer.sh start

(2) Check whether the process starts

jps

The startup is successful, as shown in the figure:

(3) View status:

[root@master zookeeper]# bin/zkServer.sh status
 Or enter bin catalogue
[root@master bin]# zkServer.sh status

The status is shown in the figure:

(4) Start client:

[root@master zookeeper]# bin/zkCli.sh

(5) Exit client:

[zk: localhost:2181(CONNECTED) 0] quit

(6) Stop Zookeeper

[root@master zookeeper]# bin/zkServer.sh stop

2. Distributed installation and deployment (competition deployment)

2.1 cluster planning

Deploy Zookeeper on the master, slave01 and slave02 nodes.

2.2 decompression and installation

(1) Enter the directory where the zookeeper installation package is stored, and unzip the zookeeper installation package to the / opt/module / directory

tar -zxvf zookeeper-3.4.5.tar.gz -C /opt/module/

(2) After decompression, the file name is changed to zookeeper

mv zookeeper-3.4.5 zookeeper

2.3 setting zookeeper environment variable

Command:

vi /root/.bash_profile

Add the following:

export ZOOKEEPER_HOME=/opt/module/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

Make settings effective immediately:

source /root/.bash_profile

Copy environment variables to slave01 and slave01 nodes

slave01 Node:
scp -r /root/.bash_profile root@slave01:/root/.bash_profile 
slave02 Node:
scp -r /root/.bash_profile root@slave02:/root/.bash_profile 

2.4 configure server number

(1) Create zkData in the directory / opt/module/zookeeper /

mkdir zkData

(2) Create a myid file in the / opt/module/zookeeper/zkData directory

touch myid

(3) Edit myid file

vi myid

Add the number corresponding to the server in the file:

2

2.5 configuration zoo.cfg file

(1) Rename the zoo in the directory / opt/module/zookeeper/conf_ Sample.cfg is zoo.cfg

mv zoo_sample.cfg zoo.cfg

(2) Open the zoo.cfg file

vi zoo.cfg

Modify data storage path configuration

dataDir=/opt/module/zookeeper/zkData

Add the following configuration

server.2=master:2888:3888
server.3=slave01:2888:3888
server.4=slave02:2888:3888

(3) Copy the configured zookeeper to other nodes

slave01 Node:
scp -r /opt/module/zookeeper/ root@slave01:/opt/module/zookeeper/
slave02 Node:
scp -r /opt/module/zookeeper/ root@slave02:/opt/module/zookeeper/

And modify the contents of myid file as 3 and 4 on slave01 and slave02 respectively

2.6 cluster operation

(1) Start Zookeeper of three nodes respectively

master Node:
[root@master zookeeper]# bin/zkServer.sh start
slave01 Node:
[root@slave01 zookeeper]# bin/zkServer.sh start
slave02 Node:
[root@slave02 zookeeper]# bin/zkServer.sh start

(2) Check whether the process starts

jps

The startup is successful, as shown in the figure:

(3) View the status of three nodes

master Node:
[root@master zookeeper]# bin/zkServer.sh status
slave01 Node:
[root@slave01 zookeeper]# bin/zkServer.sh status
slave02 Node:
[root@slave02 zookeeper]# bin/zkServer.sh status

The status of the three nodes is shown in the figure:

(4) Start client:

[root@master zookeeper]# bin/zkCli.sh

(5) Exit client:

[zk: localhost:2181(CONNECTED) 0] quit

(6) Stop Zookeeper

[root@master zookeeper]# bin/zkServer.sh stop

Posted on Tue, 09 Nov 2021 05:20:31 -0500 by gameshints