一、部署prometheus
官方文档:https://prometheus.io/docs/introduction/first_steps/
下载地址:https://github.com/prometheus/prometheus/releases
[root@centos7 ~]# tar zxf prometheus-2.45.2.linux-amd64.tar.gz
[root@centos7 ~]# mv prometheus-2.45.2.linux-amd64 /usr/local/prometheus
[root@centos7 ~]# ll -h /usr/local/prometheus/
total 225M
drwxr-xr-x 2 1001 docker 38 Dec 19 22:31 console_libraries
drwxr-xr-x 2 1001 docker 173 Dec 19 22:31 consoles
-rw-r--r-- 1 1001 docker 12K Dec 19 22:31 LICENSE
-rw-r--r-- 1 1001 docker 3.7K Dec 19 22:31 NOTICE
-rwxr-xr-x 1 1001 docker 116M Dec 19 22:09 prometheus
-rw-r--r-- 1 1001 docker 934 Dec 19 22:31 prometheus.yml
-rwxr-xr-x 1 1001 docker 109M Dec 19 22:10 promtool
systemctl管理prometheus
[root@centos7 ~]# cat > /usr/lib/systemd/system/prometheus.service << EOF
[Unit]
Description=Prometheus
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/prometheus/prometheus \\
--config.file=/usr/local/prometheus/prometheus.yml \\
--storage.tsdb.path=/data/prometheus
[Install]
WantedBy=multi-user.target
EOF
[root@centos7 ~]# systemctl daemon-reload
[root@centos7 ~]# systemctl start prometheus.service
[root@centos7 ~]# systemctl enable prometheus.service
访问http://localhost:9090/targets
二、部署node_exporter
下载地址:https://github.com/prometheus/node_exporter/releases
[root@centos7 ~]# tar zxf node_exporter-1.7.0.linux-amd64.tar.gz
[root@centos7 ~]# mv node_exporter-1.7.0.linux-amd64 /usr/local/node_exporter
[root@centos7 ~]# cat > /usr/lib/systemd/system/node_exporter.service << EOF
[Unit]
Description=node_exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target
EOF
[root@centos7 ~]# systemctl start node_exporter.service
[root@centos7 ~]# systemctl enable node_exporter.service
三、安装grafana
下载地址:https://grafana.com/grafana/download
官方文档:https://grafana.com/docs/grafana/latest/setup-grafana/installation/
[root@centos7 ~]# yum localinstall -y grafana-7.3.3-1.x86_64.rpm
[root@centos7 ~]# systemctl start grafana-server.service
[root@centos7 ~]# systemctl enable grafana-server.service
[root@centos7 ~]# netstat -lnpt|grep 3000
tcp6 0 0 :::3000 :::* LISTEN 3307/grafana-server
访问http://localhost:3000,默认帐密是admin/admin
四、grafana出图
初次访问grafana主页,会提示修改密码,也可跳过,后续再改
1. 配置数据源
2. 创建仪表板
标签:教程,22,prometheus,grafana,centos7,Prometheus,root,1001,搭建 From: https://www.cnblogs.com/niuyx/p/17935958.html