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 /opt/
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.1/mysqld_exporter-0.15.1.linux-amd64.tar.gz
tar zxf mysqld_exporter-0.15.1.linux-amd64.tar.gz
cd mysqld_exporter-0.15.1.linux-amd64/
# 在 mysql 上创建一个专门用于监控的用户,
[root@cdh-01 mysqld_exporter-0.15.1.linux-amd64]# cat .mysql_pri.cnf
[client]
user=root
password=admin123456
host=192.168.1.139
port=13306
[root@cdh-01 mysqld_exporter-0.15.1.linux-amd64]# cat .mysql_sec_1.cnf
[client]
user=root
password=admin123456
host=192.168.1.139
port=13307
[root@cdh-01 mysqld_exporter-0.15.1.linux-amd64]# cat .mysql_sec_2.cnf
[client]
user=root
password=admin123456
host=192.168.1.139
port=13308
# 启动
nohup ./mysqld_exporter --web.listen-address=192.168.1.199:9104 --config.my-cnf=./.mysql_pri.cnf &
nohup ./mysqld_exporter --web.listen-address=192.168.1.199:9105 --config.my-cnf=./.mysql_sec_1.cnf &
nohup ./mysqld_exporter --web.listen-address=192.168.1.199:9106 --config.my-cnf=./.mysql_sec_2.cnf &
标签:exporter,mysql,192.168,cnf,mysqld,linux,安装
From: https://www.cnblogs.com/sddll/p/18068496