Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Apache Zookeeper installation in Ubuntu for Standalone mode

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 916
    Comment on it

    Hi there, This blog is to help you for Apache Zookeeper installation on your local Ubuntu machine.

    Apache Zookeeper is used to develop and maintain an open-source server which provides highly reliable distributed coordination. 

    Follow these links to learn more about Apache Zookeeper.

    Zookeeper was originally built by Yahoo and widely used by Apache Hadoop, Apache HBase,  Apache Solr and many more.

    Java version greater then or equal to 1.6 is required for Zookeeper.

    Steps to install Zookeeper
     

    • Download a stable version of zookeeper from Apache mirrors
       
    • Open terminal and go to that directory. (Suppose downloaded in Downloads)
    cd ~/Downloads

     

    • Extract the tar file
    sudo tar -zxvf zookeeper-3.4.8.tar.gz

     

    • Move the extracted package to /usr/local/zookeeper 
    sudo mv ~/zookeeper-3.4.8 /usr/local/zookeeper

     

    • Open your .bashrc. 
    gedit ~/.bashrc

     

    • Append the following code into it.
    #zookeper variables
    export ZOOKEEPER_HOME=/usr/local/zookeeper
    export PATH=$ZOOKEEPER_HOME/bin:$PATH

     

    • Save the .bashrc file
       
    • Execute the source command to .bashrc.
    source ~/.bashrc

     

    • Go to Zookeeper's conf directory
    cd /usr/local/zookeeper/conf

     

    • Make a copy of zoo_sample.cfg with file name zoo.cfg
    sudo cp zoo_sample.cfg zoo.cfg

     

    • Open zoo.cfg
    sudo gedit zoo.cfg

     

    • Edit value for dataDir
    dataDir=/home/avish/zookeeper/data

     

    • Save the file.
       
    • You need to manually create the location for dataDir, execute the below line for it.
    mkdir ~/zookeeper/data

     

    • now create an empty file inside it, and put a value 1 inside it.
    touch ~/zookeeper/data/myid
    
    sudo gedit ~/zookeeper/data/myid

     

    • Again open your zoo.cfg file, and append the following line to it.
    server.1=localhost:2888:3888

     

    Now the Installation part is over you can start your Zookeeper server.
     

    cd
    
    zkServer.sh start

    The response of above would be

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


    To use it in Command line mode 

    zkCli.sh

    And the response will be

    Connecting to localhost:2181
    2016-05-23 19:02:27,157 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.8--1, built on 02/06/2016 03:18 GMT
    2016-05-23 19:02:27,160 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=localhost
    2016-05-23 19:02:27,160 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.7.0_80
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-7-oracle/jre
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper/bin/../build/classes:/usr/local/zookeeper/bin/../build/lib/*.jar:/usr/local/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/bin/../zookeeper-3.4.8.jar:/usr/local/zookeeper/bin/../src/java/lib/*.jar:/usr/local/zookeeper/bin/../conf:
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
    2016-05-23 19:02:27,162 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
    2016-05-23 19:02:27,163 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.13.0-58-generic
    2016-05-23 19:02:27,163 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=abhishek
    2016-05-23 19:02:27,163 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/home/abhishek
    2016-05-23 19:02:27,163 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/home/abhishek
    2016-05-23 19:02:27,164 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@6da13047
    Welcome to ZooKeeper!
    2016-05-23 19:02:27,195 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
    2016-05-23 19:02:27,199 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session
    JLine support is enabled
    [zk: localhost:2181(CONNECTING) 0] 2016-05-23 19:02:27,306 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x154ddd08ab80000, negotiated timeout = 30000
    
    WATCHER::
    
    WatchedEvent state:SyncConnected type:None path:null
    

     

    To know about the status of server

    zkServer.sh status

    And the response will be

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


    To Stop the Zookeeper server

    zkServer.sh stop

    And the response would be

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

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: