我正在尝试通过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
使用该文件,我可以通过命令systemctl --user start kafka@0.service
和systemctl --user start kafka@1.service
启动kafka。
但是当我试图通过systemctl --user stop kafka@0.service
杀死那些守护进程时,所有两个守护进程都停止了!所以,为什么我不能只杀死一个经纪人?
答案 0 :(得分:5)
这样的事情:
[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