Member-only story

Start Kafka service failed on Ubuntu

I followed along with tutorial from digital ocean but failed. I hope this could help.

Donald Le
1 min readApr 1, 2021
Photo by DocuSign on Unsplash

The reason for run service failed due to zookeeper and kafka cannot find java. The temporary workaround this is to add environment variable to zookeeper.service and kafka.service files.

kafka.service

[Unit]
Requires=zookeeper.service
After=zookeeper.service
[Service]
Type=simple
User=kafka
ExecStart=/bin/sh -c '/home/kafka/kafka/bin/kafka-server-start.sh /home/kafka/kafka/config/server.properties > /home/kafka/kafka/kafka.log 2>&1'
ExecStop=/home/kafka/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal
Environment=JAVA_HOME=/usr/lib/jvm/jdk1.8.0_281[Install]
WantedBy=multi-user.target

zookeeper.service

[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
User=kafka
ExecStart=/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal
Environment=JAVA_HOME=/usr/lib/jvm/jdk1.8.0_281[Install]
WantedBy=multi-user.target

--

--

Donald Le
Donald Le

Written by Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

No responses yet