首页 > 系统相关 >06centos7部署安装prometheus+exproter+grafana

06centos7部署安装prometheus+exproter+grafana

时间:2023-03-12 19:11:06浏览次数:56  
标签:exporter root grafana prometheus 06centos7 usr mysqld local

一.prometheus二进制编译安装

1.关闭防火墙(或放通具体应用端口)

systemctl stop firewalld

  

2.下载prometheus安装包

官网:https://github.com/prometheus/prometheus/releases/download/v2.42.0/prometheus-2.42.0.linux-amd64.tar.gz

具体版本以自己下载的为准

tar -xf prometheus-2.21.0.linux-amd64.tar.gz -C /usr/local/
ln -s /usr/local/prometheus-2.21.0.linux-amd64 /usr/local/prometheus

  

3.创建数据存储目录

mkdir -p /data/prometheus/

  

4.编写启动shell

/usr/local/prometheus/prometheus:prometheus启动命令

/usr/local/prometheus/prometheus.yml:prometheus配置文件

/data/prometheus:tsdb数据存储路径

/usr/local/prometheus/prometheus.log:启动脚本自定义的prometheus日志

 

 

vi /usr/local/prometheus/start.sh

 

nohup /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus > /usr/local/prometheus/prometheus.log 2>&1 &

 

给启动shell添加执行权限

chmod +x start.sh

  

5.启动prometheus

bash /usr/local/prmetheus/start.sh

  

6.查看是否启动成功

方法一:查进程

 

 

 方法二:查日志

 

 

 

7.停止prometheus

方法1:直接结束prometheus进程

方法2:pkill prometheus   结束prometheus用户的所有进程

 

8.prometheus 在配置文件添加完主机后需要重启prometheus

vi /usr/local/prometheus/prometheus.yml

 

9.浏览器访问prometheus

http://192.168.186.3:9090

 

 查看被监控的主机

 

 

 

 

查看监控主机的监控项及数据

由于每个exporter都是独立的存在,exporter默认端口是9100,直接在主机url:9100/metrics 即可

http://192.168.186.4:9100/metrics

 

 

二.node-exporter安装


1.下载软件包

官网下载:https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz

tar -xf node_exporter-1.5.0.linux-amd64.tar.gz -C /usr/local/
ln -s  /usr/local/node_exporter-1.5.0.linux-amd64/ /usr/local/node_exporter/

  

2.运行node_exporter

nohup /usr/local/node_exporter/node_exporter > /usr/local/node_exporter/node_exporter.log 2>&1 &

  

3.查看进程确认是否启动成功

 

 

 

三.监控mysql(mysqld_exporter)

在Client上安装mysqld_exporter组件和MySQL

[root@client ~]# tar -xf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
[root@client ~]# mv /usr/local/mysqld_exporter-0.12.1.linux-amd64/ /usr/local/mysqld_exporter
[root@client ~]# yum -y install mariadb\*

  

启动MySQL并授权

[root@client ~]# systemctl restart mariadb
[root@client ~]# mysql -uroot
MariaDB [(none)]> grant select,replication client,process on *.* to 'mysql_monitor'@'localhost' identified by '123.com';
#授权IP为localhost,因为不是prometheus服务器直接找mariadb获取数据,而是prometheus服务器找mysql_exporter,mysql_exporter再找mariadb。所以这个localhost是指的mysql_exporter的IP
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  

创建一个mariadb配置文件,写上刚刚授权的用户名和密码

[root@client ~]# vim /usr/local/mysqld_exporter/.my.cnf

[client]
user=mysql_monitor
password=123.com

  

启动mysqld_exporter

[root@client ~]# nohup /usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf &
[root@client ~]# lsof -i:9104
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld_ex 60421 root    3u  IPv6 111828      0t0  TCP *:peerwire (LISTEN)

  

在Prometheus服务器的配置文件里添加被监控的mariadb的配置段

[root@prometheus ~]# vim /usr/local/prometheus/prometheus.yml 
  - job_name: 'mariadb'
    static_configs:
    - targets: ['10.10.11.113:9104']
[root@prometheus ~]# pkill prometheus
[root@prometheus ~]# /usr/local/prometheus/prometheus --config.file="/usr/local/prometheus/prometheus.yml" &

  

回到web管理界面 -->点Status -->点Targets -->可以看到监控mariadb了

 

 

 

 

 

 

标签:exporter,root,grafana,prometheus,06centos7,usr,mysqld,local
From: https://www.cnblogs.com/chenzhi2023/p/17208791.html

相关文章

  • Prometheus-pushgateway自定义监控项
    目录一、前言二、pushgateway安装三、pushgateway的使用四、pushgateway脚本思路一、前言pushgateway相比较exporter是主动向服务器发送请求,pushgateway本身也是一个程序......
  • prometheus监控系统
    准备官网:https://prometheus.iohttps://grafana.com创建命名空间:mkdir-p/root/prometheus&&cd/root/prometheuscat>monitor-sa.yaml<<"EOF"kind:Nam......
  • 6.prometheus监控mysql多实例
    一、背景介绍公司采用prometheus作为监控平台,经过资料查找,mysqld_exporter和mysql是[1:1],既每个mysql实例都需要起一个exporter进程来采集mysql监控数据,不过最近看github......
  • 使用docker-compose 部署grafana + prometheus +node_exporter 实现监控
    主机环境:kali6.1(debian..)一、安装应用安装docker-compose  aptinstalldocker-compose-y安装dockersudoaptupdatesudoaptinstall-ydocker.iosudosystem......
  • prometheus 监控windows
    通过ansible批量操作windows机器,部署windows_exporter-0.21.0-amd64.exe1、需要检查的点:1)、ansible登录用户名必须与系统组记录的成员名一致,要不然会一直报错,"ntlm:the......
  • prometheus监控nginx
    1.下载vtscd/optgitclonehttps://github.com/vozlt/nginx-module-vts.git2.编译nginx./configure--prefix=/app/nginx-1.22.1\--user=www\--group=www\--......
  • 72-云原生监控-Prometheus实现Docker监控
    Prometheus架构https://github.com/prometheus/prometheuscAdvisor简介cadvisor(ContainerAdvisor)是Google开源的一个容器监控工具,它以守护进程方式运行,用于收集、聚......
  • 详解Prometheus四种指标类型
    指标是用来衡量性能、消耗、效率和许多其他软件属性随时间的变化趋势。它们允许工程师通过警报和仪表盘来监控一系列测量值的演变(如CPU或内存使用量、请求持续时间、延迟......
  • Prometheus理论知识
    1、Prometheus特性:基于时间序列模型:时间模型是一系列有序的数据,通常等时间间隔采样数据基于K/V的数据模型:键值对,速度快采样数据使用数学公式:完全基于数学运算而不是其......
  • Prometheus黑盒测试【blackbox-exporter】
    官方下载地址blackbox-exporter是Prometheus官方提供的一个黑盒测试的解决方案,可用于以下使用场景:TCP:端口存活检测HTTP/HTTPS:可用性检测ICMP:主机存活检测TCP:端口存活......