promethus粘贴复制式部署文档

Prometheus安装

 cd /usr/src/
 wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz
tar xf prometheus-2.12.0.linux-amd64.tar.gz  -C /usr/local/
cd /usr/local/
ln -s prometheus-2.12.0.linux-amd64  prometheus

设置systemctl prometheus 启动

cat > /usr/lib/systemd/system/prometheus.service     << EOF
[Unit]
Description=Prometheus: the monitoring system
Documentation=http://prometheus.io/docs/

[Service]
ExecStart=/usr/local/prometheus/prometheus  --config.file=/usr/local/prometheus/prometheus.yml
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF
systemctl enable prometheus       ##制作开机启动prometheus  
systemctl start prometheus            ##启动prometheus 
systemctl status prometheus         ##查看promethus状态

node_exporter安装部署 -> promethus依赖node_exporter来采集信息

cd /usr/src/
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar xf node_exporter-0.18.1.linux-amd64.tar.gz  -C /usr/local/
cd  /usr/local/
ln -s node_exporter-0.18.1.linux-amd64  node_exporter

制作systemctl方式启动node_exporter

cat >  /usr/lib/systemd/system/node_exporter.service  <<  EOF
[Unit]
Description=Prometheus node exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target

[Service]
Restart=on-failure
ExecStart="/usr/local/node_exporter/node_exporter"

[Install]
WantedBy=multi-user.target
EOF

制作node_exporter服务启动

systemctl enable node_exporter.service     ##制作开机启动node_exporter
systemctl start node_exporter.service          ##启动node_exporter
systemctl status node_exporter.service       ##查看node_exporter状态

访问方式

http://localhost:9090

获取主机信息

curl http://localhost:9090/metrics

如需要设置报警面板显示和监控多台机器可参考142机器的promethus.yml

posted on 2020-03-04 11:52  石圪节胡德禄  阅读(212)  评论(0编辑  收藏  举报

导航