How to Install Apache ZooKeeper on Debian 10

How to Install Apache ZooKeeper on Debian 10


Linux Articles / All 103 Views comments

Apache Zookeeper is a free and open-source service for distributed techniques that lets you handle a big set of hosts. It's a centralized service used for sustaining configuration info, naming and group providers. It's written in Java and permits builders to concentrate on constructing software program options with out worrying concerning the distributed nature of the appliance. Apache ZooKeeper mostly utilized in "read-dominant" workloads the place reads are rather more widespread than writes. It comes with a wealthy set of options together with, Synchronization, Ordered Messages, Serialization, Reliability, Atomicity, Quick Processing and lots of extra. It has a locking and synchronization mechanism that helps you in automated fail restoration whereas connecting different distributed purposes. Zookeeper undertaking is likely one of the most profitable tasks from the Apache basis. Many corporations adopted Zookeeper for creating extremely obtainable distributed techniques at giant scale.

On this tutorial, we'll present you how one can arrange a single-node Apache Zookeeper cluster on Debian 10 server.


  • A server operating Debian 10 with 2 GB of RAM.
  • A root password is configured in your server.

Getting Began

Earlier than beginning, it is suggested to replace your server with the newest model. You'll be able to replace it utilizing the next command:

apt-get replace -y
apt-get improve -y

As soon as your server is up to date, restart it to implement the modifications.

Set up Java

Apache Zookeeper is written within the Java language. So you will have to put in Java in your system. By default, the newest model of Java is on the market within the Debian 10 default repository. You'll be able to set up it by operating the next command:

apt-get set up default-jdk -y

After putting in Java, confirm the put in model of Java utilizing the next command:

java --version

It is best to get the next output:

openjdk 2019-10-15
OpenJDK Runtime Surroundings (construct
OpenJDK 64-Bit Server VM (construct, combined mode, sharing)

As soon as you're achieved, you possibly can proceed to create a system consumer for Zookeeper.

Create a System Consumer for Zookeeper

It's a good suggestion to create a devoted consumer to run the Zookeeper service. It will enhance your safety and manageability.

First, run the next command to create a zookeeper consumer with house listing:

useradd zookeeper -m

Subsequent, set the default shell for the zookeeper consumer utilizing the next command:

usermod --shell /bin/bash zookeeper

Subsequent, set a password for zookeeper consumer utilizing the next command:

passwd zookeeper

Subsequent, add the zookeeper consumer to the sudo group:

usermod -aG sudo zookeeper

At this level, you have got created and configured the Zookeeper consumer. Now you can proceed to obtain the Zookeeper.

Obtain Zookeeper

First, you will want to obtain the newest model of the Apache Zookeeper from its official web site. On the time of writing this text, the newest model of Apache Zookeeper is Three.5.6.

To obtain it, change the listing to the /choose and run the next command:

cd /choose

As soon as the obtain is accomplished, extract the downloaded file with the next command:

tar -xvzf apache-zookeeper-Three.5.6-bin.tar.gz

Subsequent, rename the extracted listing to zookeeper and provides correct permissions:

mv apache-zookeeper-Three.5.6-bin zookeeper
chown -R zookeeper:zookeeper /choose/zookeeper

Subsequent, you will want to create a knowledge listing for Zookeeper to shops all configuration and state knowledge. You possibly can create in on the native filesystem or the distant filesystem as per your want.

You possibly can create a knowledge listing utilizing the next command:

mkdir -p /knowledge/zookeeper

Subsequent, change the possession of the info listing to zookeeper consumer:

chown -R zookeeper:zookeeper /knowledge/zookeeper

At this level, you've gotten downloaded Zookeeper and create a knowledge listing for it. Now you can proceed to configure the Zookeeper.

Configure Zookeeper

Zookeeper all of the configuration information are situated inside /choose/zookeeper/conf/ listing. You possibly can create a Zookeeper configuration file inside /choose/zookeeper/conf/ listing utilizing the next command:

nano /choose/zookeeper/conf/zoo.cfg

Add the next strains:


Save and shut the file if you find yourself completed.

The place:

  • tickTime : This feature units the size of a tick in milliseconds.
  • dataDir : Specify the info listing to retailer Zookeeper knowledge.
  • clientPort : Specify the port used to pay attention for shopper connections.
  • maxClientCnxns : Used to limits the utmost variety of shopper connections.

Word : Above parameters are for improvement and testing. You possibly can change them in response to your want.

At this level, you could have configured Zookeeper. Now you can prepared to start out the Zookeeper server.

Begin and Check Zookeeper Server

You can begin the Zookeeper server utilizing the next command:

/choose/zookeeper/bin/ begin

It is best to get the next output:

ZooKeeper JMX enabled by default
Utilizing config: /choose/zookeeper/bin/../conf/zoo.cfg
Beginning zookeeper ... STARTED

Subsequent, you'll be able to hook up with the Zookeeper server on port 2181 utilizing the next command:

/choose/zookeeper/bin/ -server

As soon as related, you need to see the next output:

[zk: 0]

Subsequent, run the assistance command to get an inventory of instructions that you would be able to execute from the shopper.

[zk: 0] assist

It is best to see the next output:

ZooKeeper -server host:port cmd args
        addauth scheme auth
        config [-c] [-w] [-s]
        join host:port
        create [-s] [-e] [-c] [-t ttl] path [data] [acl]
        delete [-v version] path
        deleteall path
        delquota [-n|-b] path
        get [-s] [-w] path
        getAcl [-s] path
        historical past 
        listquota path
        ls [-s] [-w] [-R] path
        ls2 path [watch]
        printwatches on|off
        give up 
        reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]
        redo cmdno
        removewatches path [-c|-d|-a] [-l]
        rmr path
        set [-s] [-v version] path knowledge
        setAcl [-s] [-v version] [-R] path acl
        setquota -n|-b val path
        stat [-w] path
        sync path

After testing, exit from the shopper session utilizing the give up command:

[zk: 0] give up

Now you can cease the Zookeeper service with the next command:

/choose/zookeeper/bin/ cease

It is best to see the next command:

ZooKeeper JMX enabled by default
Utilizing config: /choose/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

At this level, you have got efficiently began and examined the Zookeeper server.

Create a Systemd Service File for Zookeeper

Subsequent, you will have to create a systemd service file to handle the Zookeeper service utilizing systemd.

You'll be able to create it with the next command:

nano /and so forth/systemd/system/zookeeper.service

Add the next strains:

Description=Zookeeper Daemon

ExecStart=/choose/zookeeper/bin/ begin /choose/zookeeper/conf/zoo.cfg
ExecStop=/choose/zookeeper/bin/ cease /choose/zookeeper/conf/zoo.cfg
ExecReload=/choose/zookeeper/bin/ restart /choose/zookeeper/conf/zoo.cfg


Save and shut the file if you end up completed. Then, reload the systemd daemon with the next command:

systemctl daemon-reload

Subsequent, begin the Zookeeper service and allow it to start out after system reboot utilizing the next command:

systemctl begin zookeeper
systemctl allow zookeeper

Now you can confirm the Zookeeper standing utilizing the next command:

systemctl standing zookeeper

You need to see the next output:

? zookeeper.service - Zookeeper Daemon
   Loaded: loaded (/and so on/systemd/system/zookeeper.service; disabled; vendor preset: enabled)
   Lively: lively (operating) since Solar 2019-12-29 15:12:39 UTC; 8min in the past
  Course of: 9229 ExecStart=/choose/zookeeper/bin/ begin /choose/zookeeper/conf/zoo.cfg (code=exited, standing=zero/SUCCESS)
 Foremost PID: 9245 (java)
    Duties: 29 (restrict: 2359)
   Reminiscence: 49.7M
   CGroup: /system.slice/zookeeper.service
           ??9245 java -Dzookeeper.log.dir=/choose/zookeeper/bin/../logs -Dzookeeper.log.file=zookeeper-zookeeper-server-debian10.log -Dzookeeper.

Dec 29 15:12:38 debian10 systemd[1]: Beginning Zookeeper Daemon...
Dec 29 15:12:38 debian10[9229]: /usr/bin/java
Dec 29 15:12:38 debian10[9229]: ZooKeeper JMX enabled by default
Dec 29 15:12:38 debian10[9229]: Utilizing config: /choose/zookeeper/conf/zoo.cfg
Dec 29 15:12:39 debian10[9229]: Beginning zookeeper ... STARTED
Dec 29 15:12:39 debian10 systemd[1]: Began Zookeeper Daemon.

Now, you possibly can simply handle the Zookeeper service with systemd.


Congratulations! you could have efficiently put in and configured a single node Zookeeper cluster on Debian 10 server. This setup could be very helpful for developmental and testing environments. I hope you will have now sufficient information to arrange a single node Zookeeper cluster. Be happy to ask me in case you have any questions.