Zookeeper download installation and configuration
1. Download zookeeper
Address: https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz
2. Upload to Linux
Choose a directory, upload
3. Unzip
Run the following command to decompress
1> .tar.gz file
tar -zxvf zookeeper-3.5.9.tar.gz (this file name is changed according to the actual name of the file)
2> .tar file
tar -xvf zookeeper-3.5.9.tar (this file name is changed according to the actual name of the file)
decompression is successful
4. Configuration
1>Enter the decompressed zookeeper/conf directory
[root@lingyun tools]# cd apache-zookeeper-3.5.9-bin
[root@lingyun apache-zookeeper-3.5.9-bin]# cd conf
[root@lingyun conf]# ls
configuration.xsl log4j.properties zoo_sample.cfg
2> Copy the zoo_sample.cfg file as zoo.cfg, and copy three copies because of the pseudo-distributed configuration
[root@lingyun conf]# cp zoo_sample.cfg zoo.cfg
3> Edit the zoo1.cfg file
[root@lingyun conf]# vi zoo1.cfg
Modify zoo2.cfg
vi zoo2.cfg
Modify zoo3.cfg
vi zoo3.cfg
4> Create a file for zookeeper to save data
[root@lingyun conf\]# mkdir -p /usr/tools/zookeeper/data/zk1
[root@lingyun conf\]# mkdir -p /usr/tools/zookeeper/data/zk2
[root@lingyun conf\]# mkdir -p /usr/tools/zookeeper/data/zk3](https://img-blog.csdnimg.cn/0524554c26834617a63d4a38257b9704.png)
Create a new myid file under the above paths respectively
[root@lingyun data]# touch zk1/myid
[root@lingyun data]# touch zk2/myid
[root@lingyun data]# touch zk3/myid
write content
[root@lingyun data]# echo "1" > zk1/myid
[root@lingyun data]# echo "2" > zk2/myid
[root@lingyun data]# echo "3" > zk3/myid
start up
[root@lingyun zookeeper]# ls
bin conf data docs lib LICENSE.txt NOTICE.txt README.md README_packaging.txt
[root@lingyun zookeeper]# bin/zkServer.sh start zoo1.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/../conf/zoo1.cfg
Starting zookeeper ... STARTED
[root@lingyun zookeeper]# bin/zkServer.sh start zoo2.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/../conf/zoo2.cfg
Starting zookeeper ... STARTED
[root@lingyun zookeeper]# bin/zkServer.sh start zoo3.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/../conf/zoo3.cfg
Starting zookeeper ... STARTED
[root@lingyun zookeeper]#
查看状态
[root@lingyun zookeeper]# bin/zkServer.sh status zoo1.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/…/conf/zoo1.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
[root@lingyun zookeeper]# bin/zkServer.sh status zoo2.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/…/conf/zoo2.cfg
Client port found: 2182. Client address: localhost. Client SSL: false.
Mode: leader
[root@lingyun zookeeper]# bin/zkServer.sh status zoo3.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/…/conf/zoo3.cfg
Client port found: 2183. Client address: localhost. Client SSL: false.
Mode: follower
[root@lingyun ~]# jps
23491 QuorumPeerMain
30135 Jps
22761 QuorumPeerMain
23663 QuorumPeerMain
stop zookeeper
[root@lingyun conf]# /usr/tools/zookeeper/bin/zkServer.sh stop zoo1.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/../conf/zoo1.cfg
Stopping zookeeper ... STOPPED
[root@lingyun conf]# /usr/tools/zookeeper/bin/zkServer.sh stop zoo2.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/../conf/zoo2.cfg
Stopping zookeeper ... STOPPED
[root@lingyun conf]# /usr/tools/zookeeper/bin/zkServer.sh stop zoo3.cfg
ZooKeeper JMX enabled by default
Using config: /usr/tools/zookeeper/bin/../conf/zoo3.cfg
Stopping zookeeper ... STOPPED