0

I've installed Kafka on a VM and want to launch it on VM startup and turn it off on shutdown. It would be a quite simple task, but Kafka relies on working Zookeeper service.

Dependency on startup can be configured using capabilities of Systemd:

[Unit]
Description=Apache Kafka Server
Documentation=http://kafka.apache.org/documentation.html
Requires=zookeeper.service

But I couldn't find how to configure shutdown order, I need to stop Kafka first and only after that stop Zookeeper, otherwise Kafka didn't de-register itself from it properly, and fails with the following error on the next startup:

ERROR Error while creating ephemeral at /brokers/ids/1001, node already exists and owner '100620751232642057' does not match current session '100626285143549184' (kafka.zk.KafkaZkClient$CheckedEphemeral)

Could you suggest how can I arrange the shutdown order for Systemd units?

Thanks

Player
  • 35
  • 1
  • 4

1 Answers1

0

Try adding a wait between ZooKeeper and Kafka by setting ExecStartPre.

[Service]
ExecStartPre=/bin/sleep 20

Refer to error while starting kafka broker