Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Zookeeper installation


May 26, 2021 Zookeeper


Table of contents


Before installing ZooKeeper, make sure that your system is running on any of the following operating systems:

  • Any Linux OS - Supports development and deployment. S uitable for demo applications.

  • Windows OS - Development only.

  • Mac OS - Development only.

The ZooKeeper server was created with Java and runs on JVM. Y ou need to use JDK 6 or later.

Now follow these steps to install the ZooKeeper framework on your machine.

Step 1: Verify the Java installation

I'm sure you've installed a Java environment on your system. /b10>Now simply verify it with the following command.

$ java -version

If you have Java installed on your machine, you can see the installed version of Java. /b10> Otherwise, follow these simple steps to install the latest version of Java.

Step 1.1: Download JDK

Download the latest version of JDK by visiting the link and download the latest version of Java.

The latest version (at the time of writing of this tutorial) is JDK 8u 60, and the file is "jdk-8u60-linuxx64.tar.gz". /b10> Please download the file on your machine.

Step 1.2: Extract the file

Typically, files are downloaded to the download folder. V erify and extract the tar settings using the following commands.

$ cd /go/to/download/path
$ tar -zxf jdk-8u60-linux-x64.gz

Step 1.3: Move to the opt directory

To make Java available to all users, move the extracted Java content to the /usr/local/java folder.

$ su 
password: (type password of root user)
$ mkdir /opt/jdk
$ mv jdk-1.8.0_60 /opt/jdk/

Step 1.4: Set the path

To set the path and JAVA_HOME variables, add the following command to the .bashrc file.

export JAVA_HOME = /usr/jdk/jdk-1.8.0_60
export PATH=$PATH:$JAVA_HOME/bin

All changes are now applied to the currently running system.

$ source ~/.bashrc

Step 1.5: Java substitution

Use the following command to change the Java override.

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_60/bin/java 100

Step 1.6

Use the verification command (java -version) described in step 1 to verify the Java installation.

Step 2: ZooKeeper frame installation

Step 2.1: Download ZooKeeper

To install the ZooKeeper framework on your computer, visit the link below and download the latest version of zooKeeper. http://zookeeper.apache.org/releases.html

So far, the latest version of ZooKeeper is 3.4.6 (ZooKeeper-3.4.6.tar.gz).

Step 2.2: Extract the tar file

Use the following commands to extract the tar file

$ cd opt/
$ tar -zxf zookeeper-3.4.6.tar.gz
$ cd zookeeper-3.4.6
$ mkdir data

Step 2.3: Create a profile

Use the command vi conf/zoo .cfg set to the starting point for all the following parameters, and open a profile .cfg conf/zoo.

$ vi conf/zoo.cfg

tickTime = 2000
dataDir = /path/to/zookeeper/data
clientPort = 2181
initLimit = 5
syncLimit = 2

Once the profile is successfully saved, return to the terminal again. Y ou can now start the zookeyer server.

Step 2.4: Start the ZooKeeper server

Execute the following command

$ bin/zkServer.sh start

After you execute this command, you will receive the following response

$ JMX enabled by default
$ Using config: /Users/../zookeeper-3.4.6/bin/../conf/zoo.cfg
$ Starting zookeeper ... STARTED

Step 2.5: Start the CLI

Type the following command

$ bin/zkCli.sh

After typing the command above, you will be connected to the ZooKeeper server and you should get the following response.

Connecting to localhost:2181
................
................
................
Welcome to ZooKeeper!
................
................
WATCHER::
WatchedEvent state:SyncConnected type: None path:null
[zk: localhost:2181(CONNECTED) 0]

Stop the ZooKeeper server

After you connect the server and do everything, you can use the following command to stop the zookeyer server.

$ bin/zkServer.sh stop