目录
一、Prometheus部署实验
1.1 部署实验
##实验准备
##关闭防火墙
[root@docker ~]# systemctl stop firewalld.service
[root@docker ~]# setenforce 0
##时间同步
[root@docker ~]# ntpdate ntp1.aliyun.com
##在官网下载安装包将其解压
[root@prometheus opt]# tar zxf prometheus-2.27.1.linux-amd64.tar.gz -C /usr/local/
[root@prometheus opt]# cd /usr/local/prometheus-2.27.1.linux-amd64/
[root@prometheus prometheus-2.27.1.linux-amd64]# ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
##查看规则文件
[root@prometheus prometheus-2.27.1.linux-amd64]# cat prometheus.yml
##开启监控
[root@prometheus prometheus-2.27.1.linux-amd64]# ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
[root@prometheus prometheus-2.27.1.linux-amd64]# ./prometheus
网页中输入监控地址
1.2 部署监控其它节点(静态)
静态发现默认:static_config :静态配置形式的服务发现
① 基于文件的服务发现;
② 基于DNS的服务发现;
③ 基于API的服务发现:Kubernetes、Consul、Azure、重新标记 、target重新打标记、 metric重新打标记
④ 基于K8S的服务发现
##prometheus想要监控其他节点,则需要借助node_exporter
##在节点服务器上将安装包放入并解压
[root@apache opt]# tar zxf node_exporter-1.1.2.linux-amd64.tar.gz
##切换目录
[root@apache opt]# cd node_exporter-1.1.2.linux-amd64
[root@apache node_exporter-1.1.2.linux-amd64]# cp node_exporter /usr/local/bin
##两台节点服务器启动服务
[root@apache node_exporter-1.1.2.linux-amd64]# ./node_exporter
##关闭Prometheus服务器中添加节点信息
[root@prometheus prometheus-2.27.1.linux-amd64]# vim prometheus.yml
##添加完成后重启服务
[root@prometheus prometheus-2.27.1.linux-amd64]# ./prometheus
- job_name: 'nodes'
static_configs:
- targets:
- 192.168.162.121:9100
- 192.168.162.122:9100
单个节点收集的数据展示
1.3 部署监控其它节点(动态)
##如果Prometheus监控在后台运行直接
kill -9 Prometheus
##创建目录存放编写的yml文件
[root@prometheus prometheus-2.27.1.linux-amd64]# mkdir files_sd
[root@prometheus prometheus-2.27.1.linux-amd64]# cd files_sd/
[root@prometheus files_sd]# mkdir targets
##将写好的yml文件导入
[root@prometheus files_sd]# ls
prometheus.yml targets
[root@prometheus files_sd]# cd targets/
[root@prometheus targets]# cat prometheus_server.yaml
- targets:
- 192.168.162.123:9090
labels:
app: prometheus
job: prometheus
[root@prometheus targets]#
1.4 基本界面功能