一、前期准备:

grafana:前端展示平台,没有数据存储功能,但是,它有不同的展示模板,然后,把后端数据库中提供的数据,进行展示 -->展示数据

prometheus(普罗米修斯):时序数据库。数据库是存储数据,它的数据是有时间顺序。-->存数据(一般不放被测服务器)

exporter(数据收集):是通过exporter 来收集,收集不同监控数据,用不同 exporter。-->采集器(放在被测服务器上)

二、安装:prometheus

1、先启动grafana:

systemctl restart grafana-server

端口:3000

2、把 prometheus 的包上传到 非被测服务器上,即可

[root@centos7 ~]# cd /opt
[root@centos7 opt]# ls
grafana+prometheus
[root@centos7 opt]# cd grafana+prometheus/
[root@centos7 grafana+prometheus]# ls
grafana-7.4.3-1.x86_64.rpm nginx-vts-exporter-0.10.3.linux-amd64.
influxdb-1.7.0.x86_64.rpm node_exporter-1.1.1.linux-amd64.tar.gz
jmx_prometheus_javaagent-0.14.0.jar prometheus-2.20.1.linux-amd64.tar.gz
mysqld_exporter-0.12.1.linux-amd64.tar.gz redis_exporter-v1.17.1.linux-amd64.tar
nginx-module-vts.tar.gz tomcat.yml
[root@centos7 grafana+prometheus]# cd ..
[root@centos7 opt]# mkdir prometheus
[root@centos7 opt]# cd prometheus/
[root@centos7 prometheus]# ls
[root@centos7 prometheus]# ll
总用量 0
[root@centos7 prometheus]# mv /opt/grafana+prometheus/prometheus-2.20.1.linux-amd
[root@centos7 prometheus]# ll
总用量 63788
-rw-r--r--. 1 root root 65315813 7月 30 15:42 prometheus-2.20.1.linux-amd64.tar.
[root@centos7 prometheus]#

-->解压,进入解压后的 文件夹,prometheus.yml 这个文件,就是 prometheus 的配置文件

[root@centos7 prometheus]# tar -zxvf prometheus-2.20.1.linux-amd64.tar.gz
prometheus-2.20.1.linux-amd64/
prometheus-2.20.1.linux-amd64/LICENSE
prometheus-2.20.1.linux-amd64/NOTICE
prometheus-2.20.1.linux-amd64/tsdb
prometheus-2.20.1.linux-amd64/prometheus
prometheus-2.20.1.linux-amd64/console_libraries/
prometheus-2.20.1.linux-amd64/console_libraries/prom.lib
prometheus-2.20.1.linux-amd64/console_libraries/menu.lib
prometheus-2.20.1.linux-amd64/promtool
prometheus-2.20.1.linux-amd64/prometheus.yml
prometheus-2.20.1.linux-amd64/consoles/
prometheus-2.20.1.linux-amd64/consoles/node.html
prometheus-2.20.1.linux-amd64/consoles/prometheus-overview.html
prometheus-2.20.1.linux-amd64/consoles/prometheus.html
prometheus-2.20.1.linux-amd64/consoles/node-overview.html
prometheus-2.20.1.linux-amd64/consoles/index.html.example
prometheus-2.20.1.linux-amd64/consoles/node-disk.html
prometheus-2.20.1.linux-amd64/consoles/node-cpu.html
[root@centos7 prometheus]# ls
prometheus-2.20.1.linux-amd64 prometheus-2.20.1.linux-amd64.tar.gz
[root@centos7 prometheus]# cd prometheus-2.20.1.linux-amd64
[root@centos7 prometheus-2.20.1.linux-amd64]# ls
console_libraries LICENSE prometheus promtool
consoles NOTICE prometheus.yml tsdb
[root@centos7 prometheus-2.20.1.linux-amd64]# ls -l
总用量 153584
drwxr-xr-x. 2 3434 3434 38 8月 6 2020 console_libraries
drwxr-xr-x. 2 3434 3434 173 8月 6 2020 consoles
-rw-r--r--. 1 3434 3434 11357 8月 6 2020 LICENSE
-rw-r--r--. 1 3434 3434 3420 8月 6 2020 NOTICE
-rwxr-xr-x. 1 3434 3434 90933367 8月 6 2020 prometheus
-rw-r--r--. 1 3434 3434 926 8月 6 2020 prometheus.yml
-rwxr-xr-x. 1 3434 3434 51151585 8月 6 2020 promtool
-rwxr-xr-x. 1 3434 3434 15159115 8月 6 2020 tsdb

-->不做修改启动 ./prometheus  端口:9090

[root@centos7 prometheus-2.20.1.linux-amd64]# ./prometheus
level=info ts=2022-08-23T03:39:58.407Z caller=main.go:308 msg="No time or size retention was set so using the default time retention" duration=15d
level=info ts=2022-08-23T03:39:58.408Z caller=main.go:343 msg="Starting Prometheus" version="(version=2.20.1, branch=HEAD, revision=983ebb4a513302315a8117932ab832815f85e3d2)"
level=info ts=2022-08-23T03:39:58.408Z caller=main.go:344 build_context="(go=go1.14.6, user=root@7cbd4d1c15e0, date=20200805-17:26:58)"
level=info ts=2022-08-23T03:39:58.408Z caller=main.go:345 host_details="(Linux 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 centos7 (none))"
level=info ts=2022-08-23T03:39:58.408Z caller=main.go:346 fd_limits="(soft=1024, hard=4096)"
level=info ts=2022-08-23T03:39:58.408Z caller=main.go:347 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2022-08-23T03:39:58.453Z caller=main.go:684 msg="Starting TSDB ..."
level=info ts=2022-08-23T03:39:58.454Z caller=web.go:524 component=web msg="Start listening for connections" address=0.0.0.0:9090

3、安装采集器:收集硬件资源使用情况,所以,安装硬件资源的采集器:node_exporter

node_exporter安装与配置:

把包放到被收集的机器上解压,进入解压后的文件夹

[root@vircent7 ~]# cd /opt/
[root@vircent7 opt]# ls
apache-tomcat-8.5.56 containerd mysqldata
apache-tomcat-8.5.56.tar.gz install_Docker_Mysql57.sh
[root@vircent7 opt]# mkdir exporter
[root@vircent7 opt]# cd exporter/
[root@vircent7 exporter]# ls
[root@vircent7 exporter]# ls
node_exporter-1.1.1.linux-amd64.tar.gz
[root@vircent7 exporter]# tar -xzvf node_exporter-1.1.1.linux-amd64.tar.gz
node_exporter-1.1.1.linux-amd64/
node_exporter-1.1.1.linux-amd64/LICENSE
node_exporter-1.1.1.linux-amd64/NOTICE
node_exporter-1.1.1.linux-amd64/node_exporter
[root@vircent7 exporter]# ls
node_exporter-1.1.1.linux-amd64 node_exporter-1.1.1.linux-amd64.tar.gz
[root@vircent7 exporter]# cd node_exporter-1.1.1.linux-amd64
[root@vircent7 node_exporter-1.1.1.linux-amd64]# ls
LICENSE node_exporter NOTICE
[root@vircent7 node_exporter-1.1.1.linux-amd64]# ./node_exporter

-->启动 ./node_exporter   端口:9100

nohup ./node_exporter &

[root@vircent7 node_exporter-1.1.1.linux-amd64]# nohup ./node_exporter &
[1] 2210
[root@vircent7 node_exporter-1.1.1.linux-amd64]# nohup: 忽略输入并把输出追加到"nohup.out"

4、prometheus 与 exporter(被监控的服务器)网络要通:

-->进入prometheus的机器上 执行:telnet node_exporter_ip 9100

[root@centos7 prometheus-2.20.1.linux-amd64]# telnet 192.168.72.133 9100
Trying 192.168.72.133...
Connected to 192.168.72.133.
Escape character is '^]'.

5、修改prometheus.yml配置文件:填写 exporter的服务信息(ip和端口)

[root@centos7 prometheus-2.20.1.linux-amd64]# vim prometheus.yml
scrape_configs:
# 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: ['localhost:9090'] - job_name: 'node_exporter'
static_configs:
- targets: ['192.168.72.133:9100']

-->启动prometheus:./prometheus   后台进程运行  nohup./prometheus&

[root@centos7 prometheus-2.20.1.linux-amd64]# nohup ./prometheus &
[1] 2031
[root@centos7 prometheus-2.20.1.linux-amd64]# nohup: 忽略输入并把输出追加到"nohup.out"

6、在grafana的web界面中,配置展示

http://grafana_ip:3000 admin admin

添加数据源 > 选择prometheus

name

HTTP-URL:http://prometheus_ip:9090

保存配置模板import > 12884

最新文章

  1. 分享Kali Linux 2016.2第41周镜像虚拟机
  2. 网页制作常见的问题(怎样兼容IE6/IE7/火狐浏览器)
  3. Humble Numbers
  4. C++的try_catch异常
  5. noip赛前小结3
  6. python 捕获 shell/bash 脚本的输出结果
  7. asp.net中Session过期设置方法
  8. Revit 二次开发 沿弧形路径创建拉伸屋顶
  9. Ubuntu12.04下使用valgrind内存测试工具测试Qt程序
  10. CH BR8(小学生放假了-clock()/CLOCKS_PER_SEC-斜率优化常错集锦)
  11. CSS知识点摘记
  12. 关于解决“No matching provisioning profiles found”问题-ios
  13. java中 try catch finally和return联合使用时,代码执行顺序的小细节
  14. myisam和innodb的区别对比
  15. 把当前ubuntu系统做成镜像
  16. padding和margin设置成百分比
  17. 《linux就该这么学》开课,linux之路新开始
  18. LBS推荐系统的设计方法
  19. go-elasticsearch 来自官方的 golang es client
  20. SoapUI&#160;接口测试之post提交本地数据文件

热门文章

  1. Jmeter 之模块控制器
  2. Jmeter 之跨线程传参
  3. week_1
  4. python 水仙花数、菱形、99乘法表、直角三角形
  5. python实验报告(第12章)
  6. Python启动HTTP服务进行文件传输
  7. 高并发解决方案orleans实践
  8. Linux C 用GPS时间更新系统时间的方法。
  9. Docker 基础 - 1
  10. NuxtJS踩坑日记,一步一步爬出我自己挖的坑。