David Castro
David Castro

Reputation: 1975

Can't start Kafka/Zookeeper Service on Centos 7/Centos 8

Paths are correct, I don't know why I can't start kafka service, all lines, log files, etc and do not say what the Issue is... :/

I'm trying to install kafka on my Centos 7/8 and there is no Issue description I can figure out.

zookeeper.service file:

[Unit] 
Requires=network.target remote-fs.target 
After=network.target remote-fs.target 

[Service] 
Type=simpleUser=kafka 

ExecStart=/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties 
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.shRestart=on-abnormal 

[Install]
WantedBy=multi-user.target 

kafka.service file:

[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.shRestart=on-abnormal 

[Install]
WantedBy=multi-user.target 

enter image description here

enter image description here

UPDATE: I was trying to solve kafka Issue when I sould check zookeeper service first. Please check the workaround below.

Upvotes: 0

Views: 1381

Answers (2)

David Castro
David Castro

Reputation: 1975

Ok I found the solution and I'm posting it because I saw a lot of questions regarding this Issue hoping I can also help them.

So, please check out the new command line ExecStart:

zookeeper.service file:

[Unit] 
Requires=network.target remote-fs.target 
After=network.target remote-fs.target 

[Service] 
Type=simpleUser=kafka 

ExecStart=/bin/sh -c '/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 

[Install]
WantedBy=multi-user.target 

On Centos (7/8/ X Version) it needs to specify the batch like this (using /bin/sh -c ''):

ExecStart=/bin/sh -c '/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties'

zookeeper working as expected

After this, you can run the kafka service! :)

Upvotes: 2

arunkvelu
arunkvelu

Reputation: 1743

From Kafka docs Quickstart

Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one. You can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.

Start zookeeper server with default settings

$ bin/zookeeper-server-start.sh config/zookeeper.properties

Start Kakfa server with default settings

$ bin/kafka-server-start.sh config/server.properties

If you had already done this step and still getting this error, Kafka server is unable to reach zookeeper service. Please check zookeeper server is running and listening on port mentioned (clientPort, default port: 2181) in zookeeper.properties file using anyone of the following commands - netstat, lsof, and telnet

Upvotes: 1

Related Questions