注意:先停止kafka,再操作。
1.新增kafka.service
vi /etc/systemd/system/kafka.service
# kafka.service内容
[Unit]
Description=Apache Kafka Service
After=network.target
[Service]
Type=forking
ExecStart=/opt/app/middles/kafka_2.12-2.4.1/bin/kafka-server-start.sh -daemon /opt/app/middles/kafka_2.12-2.4.1/config/server.properties
ExecStop=/opt/app/middles/kafka_2.12-2.4.1/bin/kafka-server-stop.sh
User=root
Group=root
RestartSec=5
Environment="JAVA_HOME=/opt/app/middles/jdk8"
[Install]
WantedBy=multi-user.target
2.加载并设置自动启动
sudo systemctl daemon-reload
sudo systemctl enable kafka.service
sudo systemctl start kafka.service
sudo systemctl status kafka.service
sudo systemctl stop kafka.service
标签:service,app,sudo,Kafka,---,middles,systemctl,kafka
From: https://www.cnblogs.com/hujunwei/p/18453296