简体   繁体   English

如何通过systemd管理kafka经纪人?

[英]how to manage kafka broker by systemd?

I am trying to manager kafka broker by systemd. 我正在尝试通过systemd来管理kafka经纪人。 here is a unit-file: 这是一个单位文件:

[Unit]
Description=Kafka with broker id (%i)
After=network.target
After=zk.service

[Service]
Type=simple

SyslogIdentifier=kafka (%i)
WorkingDirectory=/opt/service/kafka_2.11-0.9.0.1
LimitNOFILE=16384:163840

ExecStart=/usr/bin/bash -c 'bin/kafka-server-start.sh /opt/service/units/kafka/%i.properties'
ExecStop=/usr/bin/bash -c 'bin/kafka-server-stop.sh /opt/service/units/kafka/%i.properties'

[Install]
WantedBy=multi-user.target

with that file, I can start kafka by command systemctl --user start kafka@0.service and systemctl --user start kafka@1.service . 有了该文件,我可以通过命令systemctl --user start kafka@0.servicesystemctl --user start kafka@1.service

But when I try to kill those daemons by systemctl --user stop kafka@0.service , all two daemons are stoped! 但是,当我尝试通过systemctl --user stop kafka@0.service杀死那些守护程序时,所有两个守护程序都systemctl --user stop kafka@0.service so, why could not I kill just only one broker? 因此,为什么我不能只杀死一位经纪人?

Something like this: 像这样:

[Unit]
Description=Kafka with broker id (%i)
After=network.target
After=zk.service

[Service]
Type=forking

SyslogIdentifier=kafka (%i)
Restart=on-failure
LimitNOFILE=16384:163840

ExecStart=/opt/service/kafka_2.11-0.9.0.1/bin/kafka-server-start.sh -daemon /opt/service/units/kafka/%i.properties

[Install]
WantedBy=multi-user.target

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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