• No products in the cart.

Zookeeper Framework Installation

 

For the installation of zookeeper, hadoop must be installed. On this system, hduser is the hadoop user. Let us follow the following below steps to install zookeeper.

Step1: Download a Stable Release

Visit official website of zookeeper website. It will shown in the image given below:

Now click on the Download link as shown in the image given below:

You will be redirected to a page where you will see several mirror sites link to download the zookeeper. Visit any suggested mirror site and you will get the different releases as shown in the image given below:

You will get the directory link of different releases. Explore the stable link:

And save the file as the image given below:

Step 2: Extract and Move

Extract the tar file and move it into the installation directory.

First, open the terminal and login through hadoop user. (On this system, hadoop user is “hduser”).

    $ su - hduser
    Password: 

Go to the Download directory. Here, in the below command, put your root user name at the place of user. (On this system, root user is gopal.)

    $ cd /home/user/Downloads/

To see whether your file is downloaded or not, run ls command. You will get the downloaded zookeeper file in this directory.

    $ ls

You can take help from the image given below:

**Extract the File:**

    $ sudo tar -zxvf zookeeper-3.4.9.tar.gz 

Move the extracted file into the installation directory:

    $ sudo mv zookeeper-3.4.9 /usr/local/zookeeper
    $ sudo chown hduser:hadoop /usr/local/zookeeper/

Step 3: Create configuration file

Open the configuration file named conf/zoo.cfg

    $ cd /usr/local/zookeeper/conf/
    $ sudo cp zoo_sample.cfg zoo.cfg
    $ sudo nano zoo.cfg

Edit the file zoo.cfg. Your file should have the following field given below:

    # The number of milliseconds of each tick
    tickTime=2000
    # The number of ticks that the initial
    # synchronization phase can take
    initLimit=10
    # The number of ticks that can pass between
    # sending a request and getting an acknowledgement
    syncLimit=5
    # the directory where the snapshot is stored.
    # do not use /tmp for storage, /tmp here is just
    # example sakes.
    dataDir=/tmp/zookeeper
    # the port at which the clients will connect
    clientPort=2181
    # the maximum number of client connections.
    # increase this if you need to handle more clients
    #maxClientCnxns=60
    #
    # Be sure to read the maintenance section of the
    # administrator guide before turning on autopurge.
    #
    # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
    #
    # The number of snapshots to retain in dataDir
    #autopurge.snapRetainCount=3
    # Purge task interval in hours
    # Set to "0" to disable auto purge feature
    #autopurge.purgeInterval=1

Use Ctrl+X and Y to save.

Step 4: Start and Stop zookeeper

    $ cd /usr/local/zookeeper/bin

To start zookeeper run the command given below:

    $ sudo ./zkServer.sh start

You will get the output like this:

    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED

To connect to Zookeeper server using Java, use following command:

    $ ./zkCli.sh -server 127.0.0.1:2181

If everything goes right, you will see a screen showing some logs as listed below in the image:

From the shell, type help to get a listing of commands that can be executed from the client, as in:

From here, you can try a few simple commands to get a feel for this simple command line interface. First, start by issuing the list command, as in ls, yielding: :

    [zk: 127.0.0.1:2181(CONNECTED) 0] ls /
    [zookeeper]

As you can see, there is no znode created. Let us create a new one with name znode01

    [zk: 127.0.0.1:2181(CONNECTED) 1] create /znode01 data01
    Created /znode01

Let’s explore the created nodes by following command:

    [zk: 127.0.0.1:2181(CONNECTED) 2] ls /
    [znode01, zookeeper]

You have seen a new node znode01 is create with data01. Let us verify if the data is associated with this node or not:

    [zk: 127.0.0.1:2181(CONNECTED) 3] get /znode01

You will get the output:

    data01
    cZxid = 0xd
    ctime = Fri Jan 06 14:51:10 IST 2017
    mZxid = 0xd
    mtime = Fri Jan 06 14:51:10 IST 2017
    pZxid = 0xd
    cversion = 0
    dataVersion = 0
    aclVersion = 0
    ephemeralOwner = 0x0
    dataLength = 6
    numChildren = 0

Let us delete one of the create znode01 from the server by following command:

     [zk: 127.0.0.1:2181(CONNECTED) 4] delete /znode01

Now if you will see present nodes by ls command, znode01 is gone from there:

    [zk: 127.0.0.1:2181(CONNECTED) 5] ls /
    [zookeeper]

Now to exit, use the quit command:

    [zk: 127.0.0.1:2181(CONNECTED) 6] quit

You can take help from the image given below:

To get the server status, run the command given below:

    $ ./zkServer.sh status

To stop zookeeper server, run the command given below:

    $ ./zkServer.sh stop

You will get the output like this:

    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
    Stopping zookeeper ... STOPPED

Statinfer

Statinfer derived from Statistical inference. We provide training in various Data Analytics and Data Science courses and assist candidates in securing placements.

Contact Us

info@statinfer.com

+91- 9676098897

+91- 9494762485

 

Our Social Links

top
© 2020. All Rights Reserved.