架构
MySql的地位和重要性就不言而喻了,作为开源产品深受广大中小企业以及互联网企业喜爱,所以这里我们也有必要对其进行相应的监控。
由于最近更换了CentOS7,这里对MySql重新安装一遍,顺便做个记录,CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装mysql-community-release-el7-5.noarch.rpm包:
rpm -ivh mysql-community-release-el7-5.noarch.rpm
chown -R root:root /var/lib/mysql
mysql > update user set password=password('123456') where user='root';
https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz
tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz
mysqld_exporter需要连接Mysql,首先为它创建用户并赋予所需的权限:
GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'exporter'@'localhost' identified by '123456';
GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
./mysqld_exporter -config.my-cnf=".my.cnf" &
https://github.com/prometheus/mysqld_exporter
Prometheus+Grafana+node_exporter安装参考文档: