1.需要在数据库上创建对应用户及权限
create user 'mysql_monitor'@'%' IDENTIFIED BY 'mysql_monitor';
GRANT REPLICATION CLIENT, PROCESS, SELECT ON *.* TO 'mysql_monitor'@'%' IDENTIFIED BY 'mysql_monitor';
FLUSH PRIVILEGES;
2.安装mysqld_export
cd /iba/software/
tar zxf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv mysqld_exporter-0.10.0.linux-amd64/ mysqld_exporter
cd mysqld_exporter/
# 在 mysql 上创建一个专门用于监控的用户,
cat .my.cnf
[client]
host=127.0.0.1
port=3306
user=mysql_monitor
password=mysql_monitor
# 启动
nohup /usr/local/mysqld_exporter/mysqld_exporter -config.my-cnf="/usr/local/mysqld_exporter/.my.cnf" &