How to Install ZooKeeper on Arch Linux

Introduction

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. In this tutorial, we will be covering the steps to install ZooKeeper on Arch Linux.

Prerequisites

Before we start installing, we need to ensure that our system is up-to-date using the following commands.

sudo pacman -Syu

Install the Oracle JDK

ZooKeeper requires the Oracle JDK to run. You can install the Oracle JDK using the following commands.

sudo pacman -S jdk8-openjdk
sudo archlinux-java set java-8-openjdk

After the installation process, check whether the Oracle JDK is successfully installed by running the command below.

java -version

Install ZooKeeper

Now it's time to install the ZooKeeper package. The ZooKeeper package is not available via pacman, so we need to download it from the official website.

wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
tar xzf zookeeper-3.4.14.tar.gz

The next step is to move ZooKeeper to /opt.

sudo mv zookeeper-3.4.14 /opt/

Configure ZooKeeper

Create a new file at /etc/systemd/system/zookeeper.service.

sudo nano /etc/systemd/system/zookeeper.service

Paste the following configuration:

[Unit]
Description=Zookeeper
After=network.target

[Service]
User=zookeeper
ExecStart=/opt/zookeeper-3.4.14/bin/zkServer.sh start
ExecStop=/opt/zookeeper-3.4.14/bin/zkServer.sh stop
ExecReload=/opt/zookeeper-3.4.14/bin/zkServer.sh restart
WorkingDirectory=/opt/zookeeper-3.4.14
Restart=always

[Install]
WantedBy=multi-user.target

Save and close the file.

Create a new user named zookeeper.

sudo useradd zookeeper
sudo chown -R zookeeper:zookeeper /opt/zookeeper-3.4.14/

Active ZooKeeper

Start the ZooKeeper service using the following command.

sudo systemctl start zookeeper

The ZooKeeper service is now up and running. Check the status using the command below.

sudo systemctl status zookeeper

If everything went well, you will see output like the following:

● zookeeper.service - Zookeeper
   Loaded: loaded (/etc/systemd/system/zookeeper.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-11-01 23:27:23 UTC; 22min ago
 Main PID: 9154 (java)
    Tasks: 16 (limit: 14658)
   Memory: 166.6M
   CGroup: /system.slice/zookeeper.service
           └─9154 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/zookeeper-3.4.14/bin/../build/classes:/opt/zookeeper-3.4.14/bin/../build/lib/*.jar:/opt/zookeeper-3.4.14*/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/zookeeper-3.4.14/bin/../lib/slf4j-api-1.7.25.jar:...

Make sure to enable the service at boot time using the following command.

sudo systemctl enable zookeeper

Conclusion

Congratulations! You now have ZooKeeper installed on Arch Linux. ZooKeeper is an essential tool for maintaining configurations in distributed systems. You can now use it to build and manage distributed systems. If you encounter any issues during the installation process, please leave a comment below.

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!