软件包列表
Prometheus安装
解压部署
rm -rf ./prometheus-2.28.1.linux-amd64
tar -xvf prometheus-2.28.1.linux-amd64.tar.gz
rm /usr/local/prometheus* -rf
mv prometheus-2.28.1.linux-amd64 /usr/local/
ln -sv /usr/local/prometheus-2.28.1.linux-amd64/ /usr/local/Prometheus
安装服务
cat <<EOF >/usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus server daemon
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/usr/local/prometheus/prometheus.yml \
--storage.tsdb.path="/usr/local/prometheus/data" \
--storage.tsdb.retention=30d \
--web.console.templates="/usr/local/prometheus/consoles" \
--web.console.libraries="/usr/local/prometheus/console_libraries" \
--web.external-url=http://192.168.23.101:9090 \
--web.listen-address=0.0.0.0:9090
Restart=on-failure
EOF
配置说明
各项配置说明
--config.file=/usr/local/prometheus/prometheus.yml:指定Prometheus的配置文件
--storage.tsdb.path="/usr/local/prometheus/data": 监控数据存储路径
--storage.tsdb.retention=30d : 最长只保留30天
--web.console.templates="/usr/local/prometheus/consoles": 控制台模板路径位置
--web.console.libraries="/usr/local/prometheus/console_libraries" : 控制台库路径
--web.external-url =http://192.168.0.50:9090: Prometheus外部连接地址
--web.listen-address=0.0.0.0:9090 : 监听的地址和端口
检查配置文件是否有语法错误:
/usr/local/prometheus/promtool check config /usr/local/prometheus/prometheus.yml
启动服务
systemctl daemon-reload
systemctl enable prometheus.service
systemctl start prometheus.service
systemctl restart prometheus.service
systemctl status prometheus.service
node_exporter安装
解压部署
tar -xvf node_exporter-1.1.2.linux-amd64.tar.gz
rm -rf /usr/local/node_exporter*
mv node_exporter-1.1.2.linux-amd64/ /usr/local/
ln -sv /usr/local/node_exporter-1.1.2.linux-amd64 /usr/local/node_exporter
安装服务
cat <<EOF >/usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter for linux server
Documentation=https://prometheus.io/
After=network-online.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
启动服务
systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter
systemctl restart node_exporter
配置Prometheus.yaml
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['192.168.23.101:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['192.168.23.102:9100','192.168.23.103:9100']
labels:
cluster: node
role: node-host
team: test
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)