使用mysqld_exporter监控MySQL并展示数据

MySQLd_exporter是Prometheus用于监控MySQL指标的一个导出器,支持对MySQL 5.5以上进行监控 。用来抓取mysql的相关信息,下面是mysqld_exporter 安装的相关信息
 
环境: 192.168.31.40 MariaDB-5.5.68 mysqld_exporter_0.12.1
 
一、下载mysqld_exporter 并安装 
官方网址:https://prometheus.io/download/

使用mysqld_exporter监控MySQL并展示数据

文章插图
 
选择对应的版本下载
使用mysqld_exporter监控MySQL并展示数据

文章插图
 
[root@node-1 ~]# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
 
#解压,移动到/usr/local 路径下 并从命名为 mysqld_exporter
[root@node-1 ~]# tar -xf mysqld_exporter-0.12.1.linux-amd64.tar.gz
[root@node-1 ~]# mv mysqld_exporter-0.12.1.linux-amd64 /usr/local/mysqld_exporter
 
二、登陆数据库,创建授权账户[root@node-1 ~]# mysql -uroot -pEnter password: Welcome to the MariaDB monitor.Commands end with ; or g.Your MariaDB connection id is 278Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.MariaDB [(none)]> grant PROCESS, REPLICATION CLIENT, SELECT on *.* to 'exporter'@'localhost' identified by 'fxkjnj';MariaDB [(none)]> flush privileges; 
#注意: 这里我只授权了本机登陆,因为 mysqld_exporter 也安装在数据库这台主机上
 
#退出验证,使用exporter 用户登陆数据库
[root@node-1 ~]# mysql -uroot -p'fxkjnj'Welcome to the MariaDB monitor.Commands end with ; or g.Your MariaDB connection id is 286Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.MariaDB [(none)]> show grants;+----------------------------------------------------------------------------------------------------------------------------------------+| Grants for root@localhost|+----------------------------------------------------------------------------------------------------------------------------------------+| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*A88C2B91E04CF458B1EFF3228824DEA7CE4ABA22' WITH GRANT OPTION || GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION|+----------------------------------------------------------------------------------------------------------------------------------------+2 rows in set (0.00 sec)MariaDB [(none)]>  
三、创建mysqld_exporter 的配置文件 my.cnf 
[root@node-1 mysqld_exporter]


    推荐阅读