一:安装promethues 二:安装grafana 三:安装node_exporter 四:安装mysqld_exporter 4.1:环境: CentOS Linux release 7.9.2009 (Core) mysqld_exporter-0.12.1.linux-amd64.tar.gz 4.2:下载地址:https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
4.3:解压并拷贝文件: tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz cp mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter /usr/local/bin/
4.4:创建exporter使用的数据库用户并授权:
CREATE USER 'mysql_exporter'@'localhost' IDENTIFIED BY 'Mysql_exporter_passw0rd';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_exporter'@'localhost';
FLUSH PRIVILEGES;
4.5:生成一个mysqld_exporter启动可以读取到的配置文件 cat [client] user=mysql_exporter password=Mysql_exporter_passw0rd
4.6:创建Unit文件
# cat /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
Documentation=https://prometheus.io/
After=mysqld.target
[Service]
ExecStart=/usr/local/bin/mysqld_exporter --config.my-cnf=/etc/mysql-export-user.cnf
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
Restart=always
[Install]
WantedBy=multi-user.target