如何正确的安装与使用Prometheus-创新互联

如何正确的安装与使用Prometheus?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

创新互联建站坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站建设、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的腾冲网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

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=` 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。

如何正确的安装与使用Prometheus

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:

如何正确的安装与使用Prometheus

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联网站建设公司,的支持。


新闻名称:如何正确的安装与使用Prometheus-创新互联
网站路径:http://lszwz.com/article/ddjsgs.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款