以系统服务方式启动kafka

原创
qwerty 发表于: 2021-08-11   最后更新时间: 2021-11-01 18:45:44  
{{totalSubscript}} 订阅, 10,218 游览

创建服务文件

创建 /usr/lib/systemd/system/zookeeper.service 并写入

[Unit]
Requires=network.target
After=network.target
[Service]
Type=simple
LimitNOFILE=1048576
ExecStart=/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
ExecStop=/usr/local/kafka/bin/zookeeper-server-stop.sh
Restart=Always
[Install]
WantedBy=multi-user.target

创建 /usr/lib/systemd/system/kafka.service 并写入

[Unit]
Requires=zookeeper.service
After=zookeeper.service
[Service]
Type=simple
LimitNOFILE=1048576
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties 
ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh
Restart=Always
[Install]
WantedBy=multi-user.target

注意:示例的kafka安装地址在 /usr/local/kafka

启动服务

重载系统服务并启动

systemctl daemon-reload
systemctl enable zookeeper && systemctl enable kafka
systemctl start zookeeper && systemctl start kafka
systemctl status zookeeper && systemctl status kafka
更新于 2021-11-01

查看kafka更多相关的文章或提一个关于kafka的问题,也可以与我们一起分享文章