Prometheus(一)安裝部署
阿新 • • 發佈:2021-11-02
一、Prometheus安裝部署
1.1 官網地址
1.2 下載相關應用
- prometheus
- pushgateway/node_exporter
- alertmanager
1.3 環境
hostname | ipaddr | 用途 |
---|---|---|
vms31 | 192.168.26.31 | prometheus |
vms10 | 192.168.26.10 | k8s-master |
vms11 | 192.168.26.11 | k8s-node |
vms12 | 192.168.26.12 | k8s-node |
1.4 上傳相關應用到vms31
[root@vms31 ~]# cd /opt/ [root@vms31 opt]# rz -y [root@vms31 opt]# ls alertmanager-0.23.0.linux-amd64.tar.gz node_exporter-1.2.2.linux-amd64.tar.gz prometheus-2.30.3.linux-amd64.tar.gz pushgateway-1.4.2.linux-amd64.tar.gz
1.5 安裝配置prometheus
[root@vms31 opt]# tar xf prometheus-2.30.3.linux-amd64.tar.gz [root@vms31 opt]# cd prometheus-2.30.3.linux-amd64/ [root@vms31 prometheus-2.30.3.linux-amd64]# cp prometheus /usr/local/bin/ [root@vms31 prometheus-2.30.3.linux-amd64]# vim prometheus.yml ... # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: "prometheus" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ["192.168.26.31:9090"] # 使用pushgateway模組獲取 - job_name: "pushgateway" static_configs: - targets: ["192.168.26.31:9091"] labels: instance: pushgateway # 使用node exporter模組獲取 - job_name: "node exporter" static_configs: - targets: ["192.168.26.31:9100","192.168.26.10:9100","192.168.26.11:9100","192.168.26.12:9100"]
1.6 安裝pushgateway
[root@vms31 opt]# cd /opt/
[root@vms31 opt]# tar xf pushgateway-1.4.2.linux-amd64.tar.gz
1.7 安裝AlertManager
[root@vms31 pushgateway-1.4.2.linux-amd64]# cd /opt/
[root@vms31 opt]# tar xf alertmanager-0.23.0.linux-amd64.tar.gz
1.8 安裝node exporter
[root@vms31 opt]# cd /opt/ [root@vms31 opt]# tar xf node_exporter-1.2.2.linux-amd64.tar.gz
1.9 將node exporter拷貝到其它裝置並設定開機啟動
for ip in 192.168.26.10 192.168.26.11 192.168.26.12; do scp node_exporter $ip:/usr/local/sbin/;done
[root@vms31 system]# vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target
[Service]
ExecStart=/usr/local/sbin/node_exporter
User=root
Type=simple
[Install]
WantedBy=multi-user.target
for ip in 192.168.26.10 192.168.26.11 192.168.26.12; do scp /usr/lib/systemd/system/node_exporter.service $ip:/usr/lib/systemd/system/node_exporter.service;done
systemctl enable --now node_exporter
1.10 啟動Prometheus和pushgateway
[root@vms31 ~]# cd /opt/prometheus-2.30.3.linux-amd64/
[root@vms31 prometheus-2.30.3.linux-amd64]# ./prometheus --config.file=promeths.yml &> ./prometheus.log &
[root@vms31 prometheus-2.30.3.linux-amd64]# cd /opt/pushgateway-1.4.2.linux-amd64/
[root@vms31 pushgateway-1.4.2.linux-amd64]# ./pushgateway --web.listen-address=":9091" &> ./pushgateway.log &