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
posted @   两个黄鹂鸣翠柳丶  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示