栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Linux 下 Prometheus 安装与运维

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Linux 下 Prometheus 安装与运维

Prometheus 是一款面向云原生应用程序的开源监控工具,常用于监控微服务、操作系统、MySQL、Redis、Flink、RocketMQ / RabbitMQ / Kafka、K8S 等。

这里 Linux 选择 CentOS 7.2。

1. Prometheus安装 1.1 单机版安装
$ wget -P /usr/local http://mirrors.tuna.tsinghua.edu.cn/github-release/prometheus/prometheus/LatestRelease/prometheus-2.31.1.linux-amd64.tar.gz
$ tar -zxvf /usr/local/prometheus-2.31.1.linux-amd64.tar.gz -C /usr/local
$ ln -s /usr/local/prometheus-2.31.1.linux-amd64 /usr/local/prometheus  # 软链接
$ vim /usr/local/prometheus/prometheus.yml

编辑 prometheus.yml,将 global.scrape_interval 和 global.evaluation_interval 设置为 10s。

Prometheus 的启停命令:

$ nohup /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --web.enable-lifecycle > /usr/local/prometheus/nohup.out 2>&1 &   # 后台启动
$ fuser -n tcp 9090                         # 通过端口查询进程号
$ kill -9                   # 停止

–web.enable-lifecycle 表示开启动态更新配置功能,变更配置后通过 curl -X POST http://机器IP:9090/-/reload 重新加载 prometheus.yml。

访问 http://机器IP:9090/graph,就进入到了 Prometheus Graph 面板。

Prometheus metrics 页面:http://机器IP:9090/metrics

查看版本:

$ /usr/local/prometheus/prometheus --version
2. Grafana安装

Grafana 是开源的,功能齐全的度量仪表盘和图形编辑器,支持 Graphite,InfluxDB 和 OpenTSDB。

$ wget -P /usr/local https://repo.huaweicloud.com/grafana/7.5.10/grafana-7.5.10.linux-amd64.tar.gz
$ tar -zxvf /usr/local/grafana-7.5.10.linux-amd64.tar.gz -C /usr/local
$ ln -s /usr/local/grafana-7.5.10 /usr/local/grafana  # 软链接

Grafana 的启停命令:

$ nohup /usr/local/grafana/bin/grafana-server > /usr/local/grafana/nohup.out 2>&1 &   # 后台启动
$ fuser -n tcp 3000                         # 通过端口查询进程号
$ kill -9                      # 停止

访问 http://机器IP:3000,就进入到了 Grafana 面板,默认用户名/密码 admin/admin。

添加数据源:

点击 Grafana 面板左侧 Configuration -> Data Sources 添加即可。

添加仪表盘:

Grafana 有很多现成的仪表盘模版 https://grafana.com/grafana/dashboards/

我们可以使用现成的模版添加仪表盘,比如添加 Node Exporter for Prometheus Dashboard CN

首先将模版的 json 下载下来,然后点击 Grafana 面板左侧的 Create -> import 按钮导入 json 即可。

常用模版:

Node Exporter for Prometheus Dashboard CN
K8S for Prometheus Dashboard
Java Metrics与Docker系统接口监控概览
JVM监控大盘
NGINX Ingress controller
MySQL Overview

参考:
https://prometheus.io/
https://grafana.com/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/450536.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号