创建kakfa的系统systemd
要创建Kafka的systemd服务,需要按照以下步骤操作:
-
创建一个新的systemd服务单元文件:
sudo nano /etc/systemd/system/kafka.service -
在该文件中添加以下内容:
[Unit] Description=Apache Kafka Documentation=http://kafka.apache.org/documentation.html Requires=network.target [Service] Type=simple User=kafka Group=kafka ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties ExecStop=/opt/kafka/bin/kafka-server-stop.sh Restart=on-failure [Install] WantedBy=multi-user.target请确保
ExecStart和ExecStop的路径与你的Kafka安装路径相匹配。 -
保存并关闭文件。
-
重新加载systemd配置:
sudo systemctl daemon-reload -
启动Kafka服务:
sudo systemctl start kafka现在Kafka应该已经在后台运行了。
-
(可选)设置Kafka自动启动:
sudo systemctl enable kafka这将在系统启动时自动启动Kafka服务。
现在你已经成功创建了Kafka的systemd服务。你可以使用sudo systemctl start kafka、sudo systemctl stop kafka和sudo systemctl restart kafka来管理Kafka服务
AI 优化版
原文地址:https://www.cveoy.top/t/topic/h9vj 著作权归作者所有。请勿转载和采集!