Ubuntu Kafka开机自启动服务

1、创建service文件

        在/lib/systemd/system目录下创建kafka.service文件

[Unit]
Description=Apache Kafka Server
Documentation=http://kafka.apache.org/documentation.html
Requires=zookeeper.service

[Service]
Type=simple
Environment="JAVA_HOME=/usr/local/programs/jdk-8u333-linux-x64/jdk1.8.0_333"
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh

[Install]
WantedBy=multi-user.target
Alias=kafka.service
 2. 启动服务并检查状态
$ systemctl daemon-reload
$ systemctl start kafka
$ systemctl status kafka
$ systemctl restart kafka

3. 开机自启动

$ systemctl enable kafka

你可能感兴趣的:(Ubuntu20,ubuntu,kafka,debian)