prometheus开机自动启动设置流程
作者:蓝眼泪
原先手动重启的方式
/usr/local/Prometheus/prometheus --config.file=/usr/local/Prometheus/prometheus.yml &
/usr/local/node_exporter-0.17.0.linux-amd64/node_exporter &
/usr/local/mysqld_exporter-0.11.0.linux-amd64/mysqld_exporter --config.my-cnf="/usr/local/mysqld_exporter-0.11.0.linux-amd64/.my.cnf" &
/usr/local/redis_exporter redis//192.168.1.130:6379 & -web.listenaddress 192.168.1.130:9121
/usr/local/redis_exporter redis//192.168.60.124:6379 & -web.listenaddress 192.168.60.124:9121
自动启动设置1
vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
[Service]
ExecStart=/usr/local/Prometheus/prometheus
--config.file=/usr/local/Prometheus/prometheus.yml
--web.listen-address=:9090
[Install]
WantedBy=multi-user.target
自动启动设置2
vim /lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/Prometheus/prometheus --config.file=/usr/local/Prometheus/prometheus.yml
[Install]
WantedBy=multi-user.target
#设置开机自启
systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus