先安装环境:
链接:https://pan.baidu.com/s/1xzyoDLnvs8OTq9nLopU32A 提取码:jz6m
安装 Prometheus
cd /usr/local/src tar -zxvf prometheus.tar.gz cp -R prometheus-2.45.3.linux-amd64 /usr/local/prometheus
vim /usr/lib/systemd/system/prometheus.service
[Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target[Service] Type=simple User=root WorkingDirectory=/usr/local/prometheus ExecStart=/usr/local/prometheus/prometheus Restart=on-failure[Install] WantedBy=multi-user.target
启动服务和设置开机自动启动 systemctl daemon-reload systemctl enable prometheus.service systemctl start prometheus.service
浏览器访问 http://192.168.230.130:9090/targets?search=
安装 Grafana
yum install -y grafana.rpmsystemctl enable grafana-server systemctl start grafana-server
在浏览器访问地址:http:
//192.168.230.130:3000/ ,默认密码:admin/admin
安装 node_exporter
tar -zxvf node_exporter-1.6.1.linux-amd64.tar.gz cp -R node_exporter-1.6.1.linux-amd64 /usr/local/node_exporter
vim /usr/lib/systemd/system/node_exporter.service
[Unit] Description=node_exporter After=network.target[Service] Type=simple User=root ExecStart=/usr/local/node_exporter/node_exporter Restart=on-failure[Install] WantedBy=multi-user.target
设置开机自动启动systemctl daemon-reload systemctl enable node_exporter.service systemctl start node_exporter.service
监控主机
编辑 prometheus.yml
static_configs:- targets: ["localhost:9090"]- job_name: "linux"static_configs:- targets: ["127.0.0.1:9100"]labels:instance: localhost