They are introduced

  • ZooKeeper is a distributed, open source, distributed application coordination service, an open source implementation of Google’s Chubby, and a key component of Hadoop and HBase. It is a software that provides consistent services for distributed applications, including configuration maintenance, domain name service, distributed synchronization, group service and so on.
  • The goal of ZooKeeper is to encapsulate complex and error-prone key services and provide users with an easy-to-use interface and an efficient and stable system.
  • ZooKeeper contains a simple set of primitives that provide Java and C interfaces.
  • The ZooKeeper code version provides an interface for distributed exclusive locking, voting, and queuing at ZooKeeper -3.4.3\ SRC \recipes. There are Java and C versions of distributed locks and queues, and only Java versions of elections.

Zookeeper download

Web site:https://zookeeper.apache.org/…

Just download any version

They are installed

Install the JDK

Uphold the JDK1.8 file to /src/usr/local/java.

Unzip the files

tar -xvf jdk-8u51-linux-x64.tar.gz

Configure the environment variables and edit the environment variable configuration file

vim /etc/profile

Upload installation files

Note: Upload the ZooKeeper installation file. After decompression

Unzip the files

The tar - XVF zookeeper - 3.4.8. Tar. Gz

Modifying configuration files

Create the folder data/log in the root directory of zk

mkdir data log

Jump into the conf directory to change the configuration file Copy the configuration file and change the name

cp zoo_sample.cfg zoo.cfg

Start the zookeeper

Jump to the bin directory

./zkServer.sh start

ZooKeeper cluster installation

Prepare folder

Create a new folder, zkCluster, in the ZooKeeper root directory

Create a zk1/zk2/zk3 folder

Create data/log folders in each folder

mkdir {zk1,zk2,zk3}/{data,log}

Add the myid file

Create a new file myid in the data folder of zk1/zk2/zk3 respectively. The contents are in order of 1/2/3, corresponding to the node number of ZK

Edit the myid file and define the number

Edit configuration files

Copy zoo_sample.cfg to zoo1.cfg and modify the configuration file

Modify zoo1. CFG



Make 2 copies of zoo1.cfg after configuration. Then you need to change the corresponding folder directory. And a different port

ZooKeeper cluster tests

Start the ZK cluster with the following command

sh zkServer.sh start   zoo1.cfg
sh zkServer.sh start   zoo2.cfg
sh zkServer.sh start   zoo3.cfg

Check the master-slave relationship, the slave information

Check master-slave relationship, host profile

Described in the ZooKeeper cluster

In the ZooKeeper cluster, the leader is responsible for monitoring the state of the cluster, and the follower is mainly responsible for the client link to obtain the service list information. Vote at the same time