用tar包安装了prometheus,解压到/usr/local下,每次启动都是./proemetheus &,关闭就要kill进程
太麻烦,所以将其加入到systemctl管理
1.编辑文件
[root@prometheus prometheus]# vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
#Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
#User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data
Restart=on-failure
[Install]
WantedBy=multi-user.target
2.重新加载并启动服务
[root@prometheus prometheus]# systemctl daemon-reload
[root@prometheus prometheus]# systemctl start prometheus