监控远程mysql服务
一、被监控点部署mysql_exporter
1、下载
[root@web02 /opt]# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
2、解压
[root@web02 /opt]# mkdir /prometheus_mysql/ [root@web02 /opt]# tar xf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /prometheus_mysql/ [root@web02 /opt]# cd /prometheus_mysql/ [root@web02 /prometheus_mysql]# mv mysqld_exporter-0.12.1.linux-amd64/* ./ [root@web02 /prometheus_mysql]# rm -rf mysqld_exporter-0.12.1.linux-amd64/
3、mysql创建监控用户并授权
# 8.0之前 grant select,replication client,process ON *.* to 'mysql_monitor'@'localhost' identified by 'abc123'; # 8.0之后 create user 'mysql_monitor'@'localhost' identified by 'abc123'; grant select,replication client,process ON *.* to 'mysql_monitor'@'localhost'; #刷新权限 flush privileges; # (注意:授权ip为localhost,因为不是prometheus服务器来直接找mariadb 获取数据,⽽是prometheus服务器找mysql_exporter,mysql_exporter 再找mariadb。所以这个localhost是指的mysql_exporter的IP)