操作步骤
1.进入/usr/lib/systemd/system/kafka.service下,vim新建文件kafka.service
[Unit]
Description=kafka service
[Service]
ExecStart=/bin/bash /home/deploy/app/kafka/start_kafka.sh
User=deploy
Group=deploy
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
2.几个坑
(1)start_kafka.sh中的bash命令,必须全路径
(2)-daemon去掉
(3)LOG_DIRS环境变量是有用的,改成日志磁盘的挂载目录/var/data/kafka,不要/var/log/kafka
3.杀死原先进程,systemctl启动kafka
systemctl start kafka.service
4.重启检查成功后,使其开机启动(注意enable之后才会开机自启动)
systemctl enable kafka.service
5.在上述操作过程中随时检查systemd服务的状态
systemctl status kafka.service