skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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! :)


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search