二、Promethus(普罗米修斯)监控MySql数据库

  • A+
所属分类:prometheus 监控

普罗米修斯监控MySql数据库

环境基于第一个偏文章的环境搭建的,https://www.giaogg.cn/515.html

1、在node1节点安装 mysqld_exporter组件

下载地址https://prometheus.io/download/

[root@node1 ~]# tar -zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /usr/local/
[root@node1 ~]# mv /usr/local/mysqld_exporter-0.11.0.linux-amd64/ /usr/local/mysqld_exporter

2、安装mariadb数据库

[root@node1 ~]# yum install -y mariadb mariadb-server 
[root@node1 ~]# systemctl start mariadb
[root@node1 ~]# mysql
MariaDB [(none)]> grant select,replication client,process ON *.* to 'test'@'localhost' identified by '000000';

创建一个mariadb配置文件,填入连接的用户名和密码

[root@node1 ~]# vi /usr/local/mysqld_exporter/.my.cnf
[client]
user=test
password=000000

启动mysqld_exporter
[root@node1 ~]# nohup /usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf &

确认端口(9104)
[root@node1 ~]# ss -antlp |grep 9104
LISTEN     0      128         :::9104                    :::*                   users:(("mysqld_exporter",pid=3072,fd=3))

3、在prometheus服务器配置文件添加被监控的mariadb配置段

[root@master ~]# vi /usr/local/prometheus/prometheus.yml 
  - job_name: 'mariadb'
    static_configs:
    - targets: ['10.0.0.12:9104']

重启服务
[root@master ~]#  pkill prometheus 
[root@master ~]# /usr/local/prometheus/prometheus --config.file="/usr/local/prometheus/prometheus.yml" &

4、web界面查看

二、Promethus(普罗米修斯)监控MySql数据库

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: