资源规划

组件 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用户安装。

解压缩

  1. cd /share
  2. wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
  3. tar -xvzf node_exporter-0.17.0.linux-amd64.tar.gz
  4. mkdir -p /usr/local/prometheus/exporter
  5. rm -rf /usr/local/prometheus/exporter/node_exporter
  6. mv /share/node_exporter-0.17.0.linux-amd64 /usr/local/prometheus/exporter/node_exporter

授权

  1. chown -R prometheus:prometheus /usr/local/prometheus/exporter

探针服务配置

  1. rm -rf /usr/lib/systemd/system/node_exporter.service
  2. vi /usr/lib/systemd/system/node_exporter.service

配置如下:

  1. [Unit]
  2. Description=node_exporter
  3. Documentation=https://prometheus.io/
  4. After=network.target
  5. [Service]
  6. Type=simple
  7. User=prometheus
  8. ExecStart=/usr/local/prometheus/exporter/node_exporter/node_exporter
  9. Restart=on-failure
  10. [Install]
  11. WantedBy=multi-user.target

启动探针

  1. systemctl daemon-reload
  2. systemctl enable node_exporter
  3. systemctl start node_exporter
  4. systemctl stop node_exporter
  5. systemctl disable node_exporter

验证探针

  1. systemctl status node_exporter
  2. ps -ef | grep node_exporter
  3. # 端口查看
  4. netstat -anpt

Web UI:http://192.168.0.101:9100
Metric URL:http://192.168.0.101:9100/metrics

Prometheus服务配置

  1. vi /usr/local/prometheus/prometheus.yml

配置如下(scrape_configs节点):

  1. - job_name: 'node_exporter'
  2. scrape_interval: 5s
  3. static_configs:
  4. - targets: ['192.168.0.101:9100']

重启Prometheus服务:

  1. systemctl restart prometheus.service

验证Prometheus

  1. systemctl status prometheus.service
  2. ps -ef | grep prometheus
  3. # 端口查看
  4. netstat -anpt

Web UI:http://192.168.0.101:9090/graph
Targets UI:http://192.168.0.101:9090/targets