环境背景:

IP os
192.168.0.15 centos 7.7.1908

架构图

1-prometheus部署 - 图1

一. 官网下载prometheus相关组件,这里选择的版本都是最新版本

  1. [root@bogon opt]# cd /opt
  2. [root@bogon opt]# wget https://github.com/prometheus/prometheus/releases/download/v2.25.0/prometheus-2.25.0.linux-amd64.tar.gz
  3. [root@bogon opt]# wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
  4. [root@bogon opt]# wget https://github.com/prometheus/pushgateway/releases/download/v1.4.0/pushgateway-1.4.0.linux-amd64.tar.gz
  5. [root@bogon opt]# tar xvf prometheus-2.25.0.linux-amd64.tar.gz
  6. [root@bogon opt]# ln -s prometheus-2.25.0.linux-amd64 prometheus
  7. [root@bogon opt]# cd prometheus

二. 编写prometheus服务脚本

cat > /usr/lib/systemd/system/prometheus.service <<EOF
[Unit]
Description=prometheus
Documentation=
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/prometheus
ExecStart=/opt/prometheus/prometheus
ExecStop=/bin/kill -KILL \$MAINPID
ExecReload=/bin/kill -HUP \$MAINPID
KillMode=control-group
Restart=on-failure
RestartSec=3s

[Install]
WantedBy=multi-user.target
EOF

三. 启动

[root@bogon prometheus]# systemctl enable prometheus
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /usr/lib/systemd/system/prometheus.service.
[root@bogon prometheus]# systemctl start prometheus  
[root@bogon prometheus]# systemctl status prometheus

四. 访问http://192.168.0.15:9090/

至此,最简单的prometheus server就部署完成了