promethus、node_exporter二进制文件安装脚本
二进制包下载地址
https://prometheus.io/download/
grafana模板
https://grafana.com/grafana/dashboards/
Prometheus二进制安装
#!/bin/bash
useradd -M -r -s /bin/false prometheus
mkdir /etc/prometheus /var/lib/prometheus
tar xf prometheus-*.tar.gz && cd prometheus-*
cp ./{prometheus,promtool} /usr/local/bin/
cp -r ./{consoles,console_libraries} /etc/prometheus/
cp ./prometheus.yml /etc/prometheus/
chown -R prometheus:prometheus /etc/prometheus
chown prometheus:prometheus /var/lib/prometheus
cat >> /etc/systemd/system/prometheus.service << EOF
[Unit]
Description=Prometheus Time Series Collection and Processing Server
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now prometheus
sleep 3
netstat -lntp | grep 9090
node_exporter二进制安装
#!/bin/bash
useradd -M -r -s /bin/false prometheus
tar xf node_exporter-*.tar.gz && cd node_exporter-*
chown -R prometheus:prometheus node_exporter
cp ./node_exporter /usr/local/bin/
cat > /usr/lib/systemd/system/node_exporter.service << "EOF"
[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now node_exporter.service
sleep 3
netstat -lntp | grep 9100