其他分享
首页 > 其他分享> > 企业级监控 - Prometheus部署

企业级监控 - Prometheus部署

作者:互联网

服务端部署

下载安装Prometheus(https://prometheus.io/download/ )

[root@centos-prometheus ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.31.1/prometheus-2.31.1.linux-amd64.tar.gz 
[root@centos-prometheus ~]# tar zxf prometheus-2.31.1.linux-amd64.tar.gz
[root@centos-prometheus ~]# mkdir -p  /opt/prometheus
[root@centos-prometheus ~]# mv prometheus-2.31.1.linux-amd64 /opt/prometheus/prometheus
[root@centos-prometheus ~]# groupadd prometheus && useradd -g prometheus prometheus -d /opt/prometheus/

配置成系统服务

[root@centos-prometheus ~]# vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/opt/prometheus/prometheus/bin/prometheus --config.file=/opt/prometheus/prometheus/conf/prometheus.yml --storage.tsdb.path=/opt/prometheus/prometheus/data
Restart=on-failure

[Install]
WantedBy=multi-user.target

配置数据目录及配置文件

[root@centos-prometheus ~]# mkdir /opt/prometheus/prometheus/{data,conf,bin}
[root@centos-prometheus ~]# cd /opt/prometheus/prometheus/
[root@centos-prometheus prometheus]# mv prometheus promtool bin/
[root@centos-prometheus prometheus]# mv prometheus.yml conf/
[root@centos-prometheus prometheus]# chown prometheus:prometheus /opt/prometheus/prometheus/data
[root@centos-prometheus prometheus]# ln -s /opt/prometheus/prometheus/conf /etc/prometheus

启动Prometheus

[root@centos-prometheus ~]# systemctl daemon-reload
[root@centos-prometheus ~]# systemctl start prometheus.service
[root@centos-prometheus ~]# systemctl enable prometheus.service

查看启动状态并访问测试

[root@centos-prometheus ~]# netstat -lntp | grep prometheus
tcp6     0     0     :::9090         :::*         LISTEN         29320/prometheus

浏览器访问:http://172.16.1.10:9090


部署node_exporter(主机监控)

下载安装node_exporter(https://prometheus.io/download/)

[root@centos-prometheus ~]# wget https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
[root@centos-prometheus ~]# tar zxf node_exporter-1.2.2.linux-amd64.tar.gz
[root@centos-prometheus ~]# mv node_exporter-1.2.2.linux-amd64 /opt/prometheus/node_exporter

配置成系统服务

[root@centos-prometheus ~]# vim /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
ExecStart=/opt/prometheus/node_exporter/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target

启动node_exporter服务

[root@centos-prometheus ~]# systemctl daemon-reload
[root@centos-prometheus ~]# systemctl start node_exporter.service
[root@centos-prometheus ~]# systemctl enable node_exporter.service

查看启动状态并访问:http://172.16.1.10:9100/metrics 

[root@centos-prometheus ~]# netstat -lntp | grep node_exporter
tcp6     0     0     :::9100         :::*         LISTEN         30096/node_exporter

部署blackbox_exporter(黑盒监控)

GitHub主页:https://github.com/prometheus/blackbox_exporter 
下载地址:https://github.com/prometheus/blackbox_exporter/releases

下载安装blackbox_exporter

[root@centos-prometheus ~]# https://github.com/prometheus/blackbox_exporter/releases/download/v0.19.0/blackbox_exporter-0.19.0.linux-amd64.tar.gz
[root@centos-prometheus ~]# tar zxf blackbox_exporter-0.19.0.linux-amd64.tar.gz
[root@centos-prometheus ~]# mv blackbox_exporter-0.19.0.linux-amd64 /opt/prometheus/blackbox_exporter

配置成系统服务

[root@centos-prometheus ~]# vim /etc/systemd/system/blackbox_exporter.service
[Unit]
Description=blackbox_exporter
After=network.target

[Service]
WorkingDirectory=/opt/prometheus/blackbox_exporter
ExecStart=/opt/prometheus/blackbox_exporter/blackbox_exporter \
    --config.file=/opt/prometheus/blackbox_exporter/blackbox.yml

[Install]
WantedBy=multi-user.target

启动黑盒监控

[root@centos-prometheus ~]# systemctl start blackbox_exporter.service
[root@centos-prometheus ~]# systemctl enable blackbox_exporter.service

标签:opt,exporter,blackbox,centos,prometheus,企业级,Prometheus,监控,root
来源: https://www.cnblogs.com/wubolive/p/15577103.html