First 授权
mysql -uroot -p #登录mysql starquest
执行命令
GRANT REPLICATION CLIENT, PROCESS ON . TO 'exporter'@'%' identified by '123456';
GRANT SELECT ON performance_schema.* TO 'exporter'@'%';
flush privileges;
image.png注意 如果有问题 请将'localhost' 改为 '%'
14.1解压安装
tar -zxvf mysqld_exporter-0.10.0.linux-amd64.tar.gz
groupadd prometheus2
useradd -g prometheus2 -m -d /home/monitor/node_exporter/ -s /sbin/nologin prometheus2
mv mysqld_exporter-0.10.0.linux-amd64 mysqld_exporter
rm -rf mysqld_exporter-0.10.0.linux-amd64.tar.gz
14.2 自启动
创建配置信息
cd /home/monitor/mysqld_exporter
vim .my.cnf
[client]
user=exporter
password=123456
touch /usr/lib/systemd/system/mysqld_exporter.service
chown prometheus2:prometheus2 /usr/lib/systemd/system/mysqld_exporter.service
chown -R prometheus2:prometheus2 /home/monitor/mysqld_exporter
vim /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
After=network.target
[Service]
Type=simple
ExecStart=/home/monitor/mysqld_exporter/mysqld_exporter -config.my-cnf=/home/monitor/mysqld_exporter/.my.cnf
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动
systemctl daemon-reload
systemctl enable mysqld_exporter.service
systemctl start mysqld_exporter.service
systemctl status mysqld_exporter.service
systemctl stop mysqld_exporter.service
systemctl restart mysqld_exporter.service
14.3 添加到Prometheus
-
job_name: '10.2_mysqld'
static_configs:
- targets: ['x.x.x.2:9104']
14.4 添加grafana
Import dashboard 11323 选择数据源 Prometheus
网友评论