四、prometheus安装mysqld-exporter
安装mysqld-explorter首先要求这台机器上有数据库
安装数据库
yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
mysql #直接登录mysql
GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'localhost' identified by '123456';
GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'%' identified by '123456';
GRANT SELECT ON *.* TO 'mysql_monitor'@'%' ;
exit;
注:mysql 用户权限说明:
(1)、 replication client 权限 #拥有此权限可以查询master server、slave server状态。
(2)、 PROCESS权限 #通过这个权限,用户可以执行SHOW PROCESSLIST和KILL命令。默认情况 下,每个用户都可以执行SHOW PROCESSLIST命令,但是只能查询本用户的进程。如: mysql> show processlist; 另外,管理权限 process不能够指定某个数据库,on后面必须跟*.* (3)、 select 权限 #必须有select的权限,才可以使用select * from table 查看数据
1.下载地址

或使用
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.19.0/mysqld_exporter-0.19.0.linux-amd64.tar.gz
下载
2.解压缩
tar vzxf mysqld_exporter-0.19.0.linux-amd64.tar.gz
mv mysqld_exporter-0.19.0.linux-amd64 /usr/local/
3.创建隐藏配置文件.my.cnf,用于mysqld_exporter连接mysql采集数据
vim /usr/local/mysqld_exporter-0.19.0.linux-amd64/.my.cnf
输入:
[client]
user=mysql_monitor
password= 123456
4.配置成systemctl启动mysqld_exported
vim /etc/systemd/system/mysqld_exporter.service
5.重新加载 Systemd 配置
systemctl daemon-reload
6.启动并设置为开机自启
systemctl start mysqld_exporter
systemctl enable mysqld_exporter
7.网页打开查看是否正确
http://192.168.40.180:9090

看到上面的截图表示正常
更多推荐

所有评论(0)