创建/etc/systemd/system/kafka.service
[root@zookeep-kafka-node1 kafka_2.12-2.3.0]# cat /etc/systemd/system/kafka.service [Unit] Description=Apache Kafka server (broker) After=network.target zookeeper.service [Service] Type=simple Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin://usr/local/jdk1.8.0_231/bin" User=root Group=root ExecStart=/opt/kafka_2.12-2.3.0/bin/kafka-server-start.sh /opt/kafka_2.12-2.3.0/config/server.properties ExecStop=/opt/kafka_2.12-2.3.0/bin/kafka-server-stop.sh [Install] WantedBy=multi-user.target
[root@zookeep-kafka-node1 ~]# systemctl daemon-reload [root@zookeep-kafka-node1 ~]# systemctl enable kafka [root@zookeep-kafka-node1 ~]# systemctl start kafka [root@zookeep-kafka-node1 ~]# systemctl stop kafka