How to install ZooKeeper on Elementary OS Latest

ZooKeeper is a distributed coordination service that helps manage distributed systems. It is used to build reliable distributed systems and ensures that the different nodes in the system can communicate with each other.

In this tutorial, we will guide you through the steps to install ZooKeeper on Elementary OS Latest.

Prerequisites

Step 1 - Install Java

Before installing ZooKeeper, ensure that you have Java installed on your system. To install it, run the following command:

sudo apt-get install default-jdk

Step 2 - Download and extract ZooKeeper

  1. Visit the ZooKeeper website and download the latest stable version.
  2. Extract the downloaded file to the /opt directory. You can do this using the following command:
sudo tar -xvf zookeeper-3.6.3.tar.gz -C /opt
  1. Rename the extracted directory to zookeeper by running the following command:
sudo mv /opt/zookeeper-3.6.3 /opt/zookeeper

Step 3 - Configure ZooKeeper

  1. Navigate to the zookeeper/conf directory:
cd /opt/zookeeper/conf
  1. Copy the sample zoo_sample.cfg file to a new file named zoo.cfg:
sudo cp zoo_sample.cfg zoo.cfg
  1. Edit the zoo.cfg file using the text editor of your choice. You will need to provide the list of servers in your ZooKeeper instance. For example:
tickTime=2000
dataDir=/opt/zookeeper/data
clientPort=2181
server.1=192.168.0.1:2888:3888
server.2=192.168.0.2:2888:3888
server.3=192.168.0.3:2888:3888

Replace 192.168.0.1 with the IP address of your first ZooKeeper server; 192.168.0.2 with the IP address of your second server, and so on.

Step 4 - Start ZooKeeper

  1. Navigate to the zookeeper directory:
cd /opt/zookeeper
  1. Start the ZooKeeper server using the following command:
sudo ./bin/zkServer.sh start

You should see output similar to the following:

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

Step 5 - Verify the installation

To verify the installation, you can use the client utility that comes with ZooKeeper:

./bin/zkCli.sh

You should see output similar to the following:

Connecting to localhost:2181
2021-11-02 14:33:40,844 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.6.3-8c479feea0ffdb2a0c54f9f8eacdf9a1e15a68d4, built on 10/25/2021 06:42 GMT
Welcome to ZooKeeper!
2021-11-02 14:33:40,927 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Opening socket connection to server localhost/127.0.0.1:2181.
2021-11-02 14:33:40,962 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1052] - Socket connection established, initiating session, client: /127.0.0.1:40060, server: localhost/127.0.0.1:2181
JLine support is enabled
[zk: localhost:2181(CONNECTED) 0] 

Conclusion

That's it! You have successfully installed and configured ZooKeeper on your Elementary OS Latest. You can now use it to build reliable distributed systems.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!