简体   繁体   中英

Organize co-working for Kafka and Zookeeper using systemd

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

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

[Service]
ExecStartPre=/bin/sleep 20

Refer to error while starting kafka broker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM