Linux技术之prometheus

prometheus

基本原理:通过http周期性的抓取被监控的主机的状态,会使用网页上的metrics指标,保存到本地的存储中,之后prometheus将metrics中的数据拉取过来,变成图表可视化。

监控类的软件

随着k8s流行起来之后的一个监控系统

拥有强大的查询语言 PromQL  每个节点都有自治能力

是一个开源的监控系统 

github下载节点和服务器端的文件包

node_exporter-0.15.1.linux-amd64.tar.gz
prometheus-2.0.0.linux-amd64.tar.gz

部署

主服务器

tar -zxvf prometheus-2.0.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local
mv prometheus-2.0.0.linux-amd64 prometheus
cd prometheus
./prometheus --version
vi prometheus.yml

增加如下内容:(因为prometeus是服务端节点的结构,所以服务端需要在配置文件添加后续节点服务器的连接的配置  targets的内容是节点服务器的IP地址)

增加一个用户

groupadd prometheus
useradd -g prometheus -s /sbin/nologin prometheus

赋予权限

cd ~
chown -R prometheus:prometheus /usr/local/prometheus/

创建prometheus的运行数据目录

mkdir -p /var/lib/prometheus
chown -R prometheus:prometheus /var/lib/prometheus/

设置其开机启动

touch /usr/lib/systemd/system/prometheus.service
chown prometheus:prometheus /usr/lib/systemd/system/prometheus.service
vi /usr/lib/systemd/system/prometheus.service

官方提供的配置文件内容如下:

systemctl enable prometheus
systemctl start prometheus
setenforce 0
systemctl stop firewalld
systemctl status prometheus

此时服务器端9090端口已经开放 可以用于管理操作

自己ip:9090  可以对其进行管理

 

 

节点linux的部署(客户机)

tar -zxvf node_exporter-0.15.1.linux-amd64.tar.gz -C /usr/local/   //解压到
cd /usr/local/
mv node_exporter-0.15.1.linux-amd64 node_exporter   //可以改文件夹名字 太长了
cd node_exporter
useradd -g prometheus -s /sbin/nologin prometheus   //添加一个用户
chown -R prometheus:prometheus /usr/local/node_exporter/    //赋予权限
vi /usr/lib/systemd/system/node_exporter.service

systemctl enable node_exporter
systemctl start node_exporter
systemctl status node_exporter

部署完成以后 服务器端是up状态即表示成功

 

grafana安装和使用(图形化的管理软件)

grafana-4.6.2-1.x86_64.rpm 放到server1某个目录中  进入到该目录

yum localinstall grafana-4.6.2-1.x86_64.rpm

配置文件地址

/etc/grafana/grafana.ini
systemctl enable grafana-server
systemctl start grafana-server
systemctl status grafana-server
netstat -ano | grep more
[ip地址]:3000

使用web进行

 

默认用户名和密码都是admin

Grafana也可以操作prometheus的一些东西

其可以管理很多的数据 包括prometheus的数据:

 

 

 Dashboard处可以import json文件用于分析

json文件下载地址

https://grafana.com/dashboards/405

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Simon_Smith

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值