如何通过systemd管理kafka broker?
how to manage kafka broker by systemd?
我正在尝试通过 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
杀死那些守护进程时,所有两个守护进程都停止了!那么,为什么我不能只杀死一个经纪人?
像这样:
[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
我正在尝试通过 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
杀死那些守护进程时,所有两个守护进程都停止了!那么,为什么我不能只杀死一个经纪人?
像这样:
[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