prometheus监控mysql

mysql_exporter

项目地址:https://github.com/prometheus/mysqld_exporter

grafana地址: https://grafana.com/grafana/dashboards/11323

mysql_exporter是用来收集MysQL或者Mariadb数据库相关指标的,mysql_exporter需要连接到数据库并有相关权限

mysql创建权限账户

mysql -uroot -p123456

CREATE USER exporter@localhost IDENTIFIED BY devops;


GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO exporter@localhost;



FLUSH PRIVILEGES;

部署

下载软件

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz

tar xf mysqld_exporter-0.13.0.linux-amd64.tar.gz -C /opt/

ln -s /opt/mysqld_exporter-0.13.0.linux-amd64 /opt/mysqld_exporter

准备启动文件

[root@ops opt]# cat /usr/lib/systemd/system/mysqld_exporter.service 
[Unit]
Description=mysqld_exporter Exporter
Wants=network-online.target
After=network-online.target

[Service]
Environment=DATA_SOURCE_NAME=exporter:devops@tcp/
ExecStart=/opt/mysqld_exporter/mysqld_exporter
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mysqld_exporter
[Install]
WantedBy=default.target

启动

systemctl start mysqld_exporter.service 
systemctl enable mysqld_exporter.service 

systemctl status mysqld_exporter.service 

 

prometheus监控mysql

上一篇:基于Docker搭建MySQL主从复制


下一篇:Photoshop 制作一个漂亮的水晶3D图标