• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Prometheus的安装和配置教程详解

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

1. 从官网选择Prometheus版本进行下载

官网地址>> https://github.com/prometheus/prometheus/releases/

2. 实验安排

在主机192.168.153.137上安装prometheus监控192.168.153.138上的mysql服务和主机状态

3. 上传软件包到137服务器并配置

3.1 将软件包解压到 /usr/local 目录下

tar xzf prometheus-2.24.1.linux-amd64.tar.gz -C /usr/local/

3.2 给目录创建软链接

ln -s /usr/local/prometheus-2.24.1.linux-amd64/ /usr/local/prometheus

3.3 切换到目录下

cd /usr/local/prometheus

3.4 修改配置文件 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']
 #监控Linux主机状态
 - job_name: 'linux'
 static_configs:
 - targets: ['192.168.153.138:9100']
 #监控mysql服务状态
 - job_name: 'mysql'
 static_configs:
 - targets: ['192.168.153.138:9104']

3.5 启动promethus服务

./prometheus --config.file=prometheus.yml

3.6 浏览器输入 IP:9090 查看

Status->Targets页面下,我们可以看到我们配置的两个Target,它们的State为DOWN。

4. 配置138主机 4.1 下载exporter

下载地址>> https://github.com/prometheus/node_exporter/releases

4.2 将软件包解压到 /usr/local 目录下

tar xzf node_exporter-1.0.1.linux-amd64.tar.gz -C /usr/local/

4.3 启动exporter

nohup /usr/local/node_exporter-1.0.1.linux-amd64/node_exporter &

4.4 下载mysqld_exporter

下载地址>> https://github.com/prometheus/mysqld_exporter/releases

4.5 将软件包解压到 /usr/local 目录下

tar xzf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/

4.6 数据库给mysqld_exporter授权

[root@host-138 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.

MariaDB [(none)]> GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'localhost' identified by 'mysql_monitor';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT SELECT ON *.* TO 'mysql_monitor'@'localhost';
Query OK, 0 rows affected (0.00 sec)

4.7 创建 .my.cnf 配置文件

vim /usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf

内容为:

[client]
user=mysql_monitor
password=mysql_monitor

4.8 运行mysqld_exporter服务

nohup /usr/local/mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter --config.my-cnf="/usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf" &

5. 在promethus页面刷新Status->Targets页面,可以看到配置的两个Target的State为UP:

5. 在137主机上安装部署grafana

安装教程链接>>https://www.ogeek.net/article/204660.htm

5.1 添加promethus数据源 未完待续…

到此这篇关于Prometheus的安装和配置教程详解的文章就介绍到这了,更多相关Prometheus安装和配置内容请搜索极客世界以前的文章或继续浏览下面的相关文章希望大家以后多多支持极客世界!


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
比特币上的数独游戏合约的实现代码发布时间:2022-02-05
下一篇:
grafana安装及使用教程详解发布时间:2022-02-05
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap