TechAE Blogs - Explore now for new leading-edge technologies

TechAE Blogs - a global platform designed to promote the latest technologies like artificial intelligence, big data analytics, and blockchain.

Full width home advertisement

Post Page Advertisement [Top]

Main Image

How to Setup Apache Zookeeper on Hadoop Cluster

ZooKeeper is an open-source high-performance distributed application coordination service. Coordination and management of service in a distributed environment is a difficult task. ZooKeeper solves this problem with its straightforward architecture and API. It exposes common services in a simple interface, such as naming, configuration management, synchronization, and group services, so you don't have to write them from scratch. It is ready-to-use for implementing consensus, group management, leader election, and presence protocols. And you can expand on it to meet your own unique requirements.

The ZooKeeper framework was created by Yahoo to make it easier and more robust to access their applications. Later, Apache ZooKeeper became a distributed framework standard for organized service, used by Hadoop, HBase, and other frameworks managed by Apache Software Foundation. This tutorial covers how to install and deploy a ZooKeeper cluster in a distributed environment.

Step 1: Verifying Java Installation

$ java -version

Step 2: Download ZooKeeper

Visit the following link and download the latest version of ZooKeeper.

Zookeeper Website

We are going to use the latest 3.7.0 version for now.

Download Zookeeper

Step 3: Extract the tar file

$ tar -zxf apache-zookeeper-3.7.0-bin.tar.gz
$ cd apache-zookeeper-3.7.0-bin
$ mkdir data

Step 4: Create the configuration file

$ nano conf/zoo.cfg
# Enter these configs
tickTime = 2000
dataDir = /home/hdoop/apache-zookeeper-3.7.0-bin/data
clientPort = 2181
initLimit = 5
syncLimit = 2

We have to add this admin.serverPort config because when I installed spark, it also ran in 8080 port so there was a clash of the port IDs so we had configured zookeeper port now to 8020. The error I faced:

Caused by: Failed to bind to /
    at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(
    at org.eclipse.jetty.server.ServerConnector.doStart(
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
    at org.eclipse.jetty.server.Server.doStart(
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
    at org.apache.zookeeper.server.admin.JettyAdminServer.start(
    ... 5 more
Caused by: Address already in use: bind
        at Method)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(
        ... 12 more
Unable to start AdminServer, exiting abnormally

Return to the terminal once the configuration file has been successfully saved. The zookeeper server can now be started.

Step 5: Start the ZooKeeper server

$ bin/ start

You will get the following response:

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

Step 6: Start CLI

To start CLI, you can write

$ bin/

You will get the following response:

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

Stop ZooKeeper Server

After connecting to the server and completing all operations, use the following code to terminate the zookeeper server.

$ bin/ stop

No comments:

Post a Comment

Thank you for submitting your comment! We appreciate your feedback and will review it as soon as possible. Please note that all comments are moderated and may take some time to appear on the site. We ask that you please keep your comments respectful and refrain from using offensive language or making personal attacks. Thank you for contributing to the conversation!

Bottom Ad [Post Page]