如何用systemd管理kafka经纪人?

noj0wjuj  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(527)

我想通过systemd管理Kafka经纪人。这是一个单位文件:

[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

有了那个文件,我就可以按命令启动Kafka了 systemctl --user start kafka@0.service 以及 systemctl --user start kafka@1.service .
但是当我试图用 systemctl --user stop kafka@0.service ,所有两个守护进程都已停止!那么,为什么我不能只杀一个经纪人呢?

xtupzzrd

xtupzzrd1#

像这样:

[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

相关问题