您好,欢迎来到九壹网。
搜索
您的当前位置:首页Prometheus的安装和配置教程详解

Prometheus的安装和配置教程详解

来源:九壹网
Prometheus的安装和配置教程详解

1. 从官⽹选择Prometheus版本进⾏下载2. 实验安排

在主机192.168.153.137上安装prometheus监控192.168.153.138上的mysql服务和主机状态3. 上传软件包到137服务器并配置3.1 将软件包解压到 /usr/local ⽬录下

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

3.2 给⽬录创建软链接

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

3.3 切换到⽬录下

cd /usr/local/prometheus

3.4 修改配置⽂件 prometheus.yml,配置要监控的项

scrape_configs:

# The job name is added as a label `job=` 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 下载exporter4.2 将软件包解压到 /usr/local ⽬录下

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

4.3 启动exporter

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

4.4 下载mysqld_exporter

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

tar xzf mysqld_exporter-0.12.1.linux-amd.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-amd/.my.cnf

内容为:

[client]

user=mysql_monitor

password=mysql_monitor

4.8 运⾏mysqld_exporter服务

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

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

5. 在137主机上安装部署grafana5.1 添加promethus数据源 未完待续…

到此这篇关于Prometheus的安装和配置教程详解的⽂章就介绍到这了,更多相关Prometheus安装和配置内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务