资源规划
组件 | bigdata-node1 | bigdata-node2 | bigdata-node3 |
---|---|---|---|
OS | centos7.6 | centos7.6 | centos7.6 |
Prometheus | Prometheus | N.A | N.A |
node_exporter | node_exporter | N.A | N.A |
安装介质
版本:node_exporter-0.17.0.linux-amd64.tar.gz
下载:https://prometheus.io/download/#node_exporter
环境准备
安装Prometheus
参考:《CentOS7.6-安装Prometheus-2.10.0》
安装探针
使用Prometheus监控Linux服务器,需要在Linux服务器上配置探针:Prometheus node exporter。注意:使用root用户安装。
解压缩
cd /share
wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
tar -xvzf node_exporter-0.17.0.linux-amd64.tar.gz
mkdir -p /usr/local/prometheus/exporter
rm -rf /usr/local/prometheus/exporter/node_exporter
mv /share/node_exporter-0.17.0.linux-amd64 /usr/local/prometheus/exporter/node_exporter
授权
chown -R prometheus:prometheus /usr/local/prometheus/exporter
探针服务配置
rm -rf /usr/lib/systemd/system/node_exporter.service
vi /usr/lib/systemd/system/node_exporter.service
配置如下:
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/exporter/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动探针
systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter
systemctl stop node_exporter
systemctl disable node_exporter
验证探针
systemctl status node_exporter
ps -ef | grep node_exporter
# 端口查看
netstat -anpt
Web UI:http://192.168.0.101:9100
Metric URL:http://192.168.0.101:9100/metrics
Prometheus服务配置
vi /usr/local/prometheus/prometheus.yml
配置如下(scrape_configs节点):
- job_name: 'node_exporter'
scrape_interval: 5s
static_configs:
- targets: ['192.168.0.101:9100']
重启Prometheus服务:
systemctl restart prometheus.service
验证Prometheus
systemctl status prometheus.service
ps -ef | grep prometheus
# 端口查看
netstat -anpt
Web UI:http://192.168.0.101:9090/graph
Targets UI:http://192.168.0.101:9090/targets