配置模板

修改后放到目录 /etc/systemd/system/

[Unit]
Description=Kafka Stream Job For DBAudit, No.%I
After=network.target

[Service]
User=dbaudit
Group=dbaudit
ExecStart=bash /export/servers/app/kafka-stream/start.sh %I
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
  • %I 用于多进程使用,比如文件命名为 kstream@.service,启动时直接 systemctl start kstream@1.service
  • ExecStart 为启动的命令,无法修改文件夹,最好对接一个 shell 脚本

写好配置后,运行

# 加载配置文件
systemctl daemon-reload
# 启动服务
systemctl start kstream@1.service
systemctl start kstream@2.service
1
2
3
4
5

查看服务状态

systemctl status kstream@1.service
1