资源规划

组件 bigdata-node1 bigdata-node2 bigdata-node3
OS centos7.6 centos7.6 centos7.6
Prometheus Prometheus N.A N.A
Pushgateway pushgateway N.A N.A

安装介质

版本:pushgateway-0.8.0.linux-amd64.tar.gz
下载:https://prometheus.io/download/#pushgateway

环境准备

安装Prometheus

参考:《CentOS7.6-安装Prometheus-2.10.0

安装Pushgateway

注意:使用root用户安装。

解压缩

  1. cd /share
  2. wget https://github.com/prometheus/pushgateway/releases/download/v0.8.0/pushgateway-0.8.0.linux-amd64.tar.gz
  3. tar -xvzf pushgateway-0.8.0.linux-amd64.tar.gz
  4. rm -rf /usr/local/prometheus/pushgateway
  5. mv /share/pushgateway-0.8.0.linux-amd64 /usr/local/prometheus/pushgateway

授权

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

服务配置

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

配置如下:

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

启动

  1. # 方式1
  2. systemctl daemon-reload
  3. systemctl enable pushgateway
  4. systemctl start pushgateway
  5. systemctl stop pushgateway
  6. # 方式2
  7. cd /usr/local/prometheus/pushgateway
  8. ./pushgateway &

验证

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

Prometheus服务配置

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

配置如下(scrape_configs节点):

  1. - job_name: 'pushgateway'
  2. static_configs:
  3. - targets: ['192.168.0.101:9091']
  4. labels:
  5. instance: 'pushgateway'

重启Prometheus服务:

  1. systemctl restart prometheus.service

验证Prometheus

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

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