1、node_exporter、prometheus、grafana的关系
node_exporter(在操作系统层,负责收集cpu、网络等所有信息)-》prometheus(主动拉取node_exporter)-》grafana(展示数据)
如果在线安装下载很慢甚至下载不了的话,建议现在本地使用迅雷下载后上传服务器直接解压安装。
2、配置node_exporter
1)下载node_exporter
网址:Releases · prometheus/node_exporter · GitHub
[root@xxxx ~]# wget -c https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
2)解压
[root@xxxx packages]# tar -zxvf node_exporter-1.5.0.linux-amd64.tar.gz
3)启动
[root@pxxxx ~]# cd node_exporter-1.5.0.linux-amd64/
[root@xxxx ~]#./node_exporter &
4)开启9100端口(不修改任何配置文件的情况下服务启动默认开启9100端口)
[root@performance ~]# netstat -naop|grep 9100
3、安装prometheus
1)下载
网址:https://prometheus.io/download/
[root@xxxx ~]# wget -c https://github.com/prometheus/prometheus/releases/download/v2.42.0/prometheus-2.42.0.linux-amd64.tar.gz
2)解压
[root@xxxx packages]# tar -zxvf prometheus-2.42.0.linux-amd64.tar.gz
3)配置(如果要监控多个端口就配置多个job)
[root@xxxx ~]# cd prometheus-2.42.0.linux-amd64
[root@xxxx ~]# vi prometheus.yml
# 在prometheus.yml文件中加入如下配置:
- job_name: '自己命名'
static_configs:
- targets: ['你的ip:9100']
4)启动prometheus:
[root@performance ~]#./prometheus --config.file=prometheus.yml &
5)启动9090端口
[root@performance ~]# netstat -naop|grep 9090
4、安装grafana(可视化工具配合prometheus用于数据展示)
1) 下载
[root@performance6 packages]#wget https://dl.grafana.com/oss/release/grafana-9.3.6-1.x86_64.rpm
[root@performance ~]# yum install grafana-9.3.6-1.x86_64.rpm
2) 配置开机启动:
/sbin/chkconfig –add grafana-server
3) 重载所有修改过的配置文件:
[root@performance ~]# systemctl daemon-reload
4) 启动grafana-serve:
[root@performance ~]# systemctl start grafana-server.service
5) 查看状态:
[root@performance ~]# systemctl status grafana-server.service
6) 设置开机启动:
[root@performance ~]# Systemctl enable grafana-server.service
9) 登录grafana:
username: admin
password: admin
10) 配置一个数据源:
11)导入dashboard:
官网中查询模板ID:Dashboards | Grafana Labs
使用下载量最多的
ID:11074/8919/1860
点import ---> 1860,点load- ---> 数据源一定要选你刚才创建的数据源(prometheus),然后点import
扩展:
grafana上展示多台服务器数据
在多台服务器上都安装node_exporter,后再prometheus上配置。