• 1.安装prometheus(hadoopm01)
    • 上传prometheus压缩包,解压到/opt/module目录下
      tar -zxvf prometheus-2.34.0.linux-amd64.tar.gz -C /opt/module
    • 修改目录名
      mv prometheus-2.34.0.linux prometheus-2.34.0
    • 修改配置文件 prometheus.yml
      # my global config
      global:
      scrape_interval: 25s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
      evaluation_interval: 25s # Evaluate rules every 15 seconds. The default is every 1 minute.
      # scrape_timeout is set to the global default (10s).
      # Alertmanager configuration
      alerting:
      alertmanagers:
      – static_configs:
      – targets:
      # – alertmanager:9093
      # Load rules once and periodically evaluate them according to the global ‘evaluation_interval’.
      rule_files:
      # – “first_rules.yml”
      # – “second_rules.yml”
      # A scrape configuration containing exactly one endpoint to scrape:
      # Here it’s Prometheus itself.
      scrape_configs:
      # The job name is added as a label `job=` to any timeseries scraped from this config.
      – job_name: “prometheus”
      # metrics_path defaults to ‘/metrics’
      # scheme defaults to ‘http’.
      static_configs:
      – targets: [“hadoopm01:9090”]
      – job_name: “node_export_hadoopm01”
      static_configs:
      – targets: [‘hadoops01:9100’]
      – job_name: “node_export_hadoopm02”
      static_configs:
      – targets: [‘hadoops02:9100’]
      – job_name: “node_export_hadoops01”
      static_configs:
      – targets: [‘hadoops03:9100’]
      – job_name: “node_export_hadoops02”
      static_configs:
      – targets: [‘hadoops04:9100’]
      – job_name: “node_export_hadoops03”
      static_configs:
      – targets: [‘hadoops05:9100’]
      – job_name: “node_export_hadoops04”
      static_configs:
      – targets: [‘hadoops06:9100’]
      – job_name: “node_export_hadoops05”
      static_configs:
      – targets: [‘hadoops07:9100’]
    • 启动prometheus
      nohup ./prometheus –config.file=prometheus.yml > ./prometheus.log 2>&1 &
    • 启动后访问url hadoopm01:9090 即可看见promethues监控界面
  • 2.安装Node Exporter(每台机器)
    • (每台机器)上传Node_exporter压缩包,解压到/opt/module目录下
      tar -zxvf node_exporter-1.3.1.linux-amd64.tar.gz -C /opt/module
    • 修改文件夹名称
      mv node_exporter-1.3.1.linux node_exporter-1.3.1
    • 设置开机自启动
      • 创建service文件
        sudo vim /usr/lib/systemd/system/node_exporter.service
      • service 文件内容如下
        [Unit]
        Description=node_export
        Documentation=https://github.com/prometheus/node_exporter
        After=network.target
        [Service]
        Type=simple
        User=admin
        ExecStart= /opt/module/node_exporter-1.3.1/node_exporter
        Restart=on-failure
        [Install]
        WantedBy=multi-user.target
      • sudo systemctl enable node_exporter.service
      • sudo systemctl start node_exporter.service
  • 3.安装grafana (hadoopm02)
    • 上传并解压grafana的压缩包
      sudo tar -zxvf grafana-enterprise-10.1.2.linux-amd64.tar.gz -C /opt/module/
    • 进入grafana文件夹下
      cd grafana-10.1.2/
      nohup ./bin/grafana-server web > ./grafana.log 2>&1 &
    • 访问Web UI : 网页端输入 hadoopm02:3000
      • 默认账号密码 admin / admin

作者 admin

张宴银,大数据开发工程师

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注