1.在/etc/systemd/system/路径下编辑prometheus.service (linux centos7系统)
$ cat /etc/systemd/system/prometheus.service
[Unit]
Description=logging prometheus service
Documentation=https://prometheus.io
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/prometheus --config.file=/opt/prometheus/prometheus.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target
2. 通过systemctl命令启动prometeus.service
$ systemctl daemon-reload //重新加载服务配置文件
$ systemctl start prometheus && systemctl enable prometheus //启动prometheus并设置开机自启动