# Start Zookeeper as Linux service

In 
Published 2022-12-03

This tutorial explains to you how to start Zookeeper as Linux service.

In order to start/ stop Zookeeper as a Linux service (CentOS 8 in my case), you need to do the following as root:

-- Go to the /etc/systemd/system directory

cd /etc/systemd/system

-- Create the service file (named zookeeper.service in my case)

vim zookeeper.service

-- Add the following content into the file

[Unit]
Description=Zookeeper as a service

[Service]
User=kafka
WorkingDirectory=/kafka/kafka_2.13-2.8.0/bin/
ExecStart=/usr/bin/bash zookeeper-server-start.sh /kafka/kafka_2.13-2.8.0/config/zookeeper.properties
ExecStop=/usr/bin/bash /kafka/kafka_2.13-2.8.0/bin/zookeeper-server-stop.sh
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

As you can see in the following picture :

-- Change the following permissions:

chmod +x zookeeper.service
chown kafka:kafka zookeeper.service

-- Reload the service files to include the new service

systemctl daemon-reload

-- Finally to start the script on boot, enable the service with systemd (optional)

systemctl enable zookeeper.service

-- Test the start of the service (using kafka user)

systemctl start zookeeper

or

service zookeeper start

-- Test the status of the service (using kafka user)

systemctl status zookeeper

or

service zookeeper status

-- Test the stop of the service (using kafka user)

systemctl stop zookeeper

or

service zookeeper stop

xxxx

 

This is a page from container

Hello World !

<p>This message is from my server&nbsp;😊 !</p>