惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
Vercel News
Vercel News
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
云风的 BLOG
云风的 BLOG

博客园 - Caraxes

共享打印机的另一种方式 简易防火墙映射测试 Windows屏幕字体锯齿化的调整 Windows轻量级WebDAV服务器搭建 解决一个mysql数据库连接打开慢的问题记录 Mysql 赋予用户访问单表SELECT权限 UNIX换行和DOS换行的批量转换 Centos Mysql 8.0.43安装 关闭windows 更新驱动程序的方法 CentOS7下OpenSSH10.0p2升级实践 特殊符号的输入 tomcat启动一次问题的处理。 如何禁用键盘左侧Win键 Windows设置分页文件到D盘无效的解决方法 npm中文站的映射 使用ffmpeg批量生成视频的缩略图 解决内网HTTP由NG转发HTTPS后,部分跳转还是HTTP的问题 Linux LVM方式管理磁盘 Vscode Debug乱码的问题修复 一个切换不同JAVA版本的方法 ffmpeg提取音频 GO应用WINDOWS下添加程序图标 Linux 证书文件查看参考 批量查看HTTPS的SSL证书的有效期脚本 Linux系统下安装Java环境 修改Jar包里面的配置文件
手动部署MySQL Exporter实战
Caraxes · 2026-06-10 · via 博客园 - Caraxes

下载

到官网下载:https://link.zhihu.com/?target=https%3A//prometheus.io/download/%23mysqld_exporter

部署

下载完成后上传到/home/app/目录下
使用命令解压
tar -zxvf mysqld_exporter-0.18.0.linux-amd64.tar.gz
并把目录名称改为mysqld_exporter
mv mysqld_exporter-0.18.0.linux-amd64 mysqld_exporter

登陆mysql执行以下命令创建一个新账户;
GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'mysqld_exporter'@'127.0.0.1' identified by '12345678';
GRANT SELECT ON performance_schema.* TO 'mysqld_exporter'@'localhost';
flush privileges;
示例密码时:12345678,请修改为复杂密码。
本例是部署数据库服务器本地,其他情况请修改自行脚本。

配置

在mysqld_exporter目录,创建一个数据库配置文件localhost_db.cnf
示例:

[client]
user=mysqld_exporter
password=12345678
host=127.0.0.1
port=3306

注意:需要确保localhost_db.cnf的权限是:
-rw-r-----

在/etc/systemd/system创建一个服务文件 mysql_exporter.service

[Unit]
Description=mysql_exporter
After=network.target

[Service]
Type=simple
User=root
ExecStart=/home/app/mysqld_exporter/mysqld_exporter \
	--config.my-cnf=/home/app/mysqld_exporter/localhost_db.cnf \
	--web.listen-address=:9105
Restart=on-failure

[Install]
WantedBy=multi-user.target

执行以下命令启动服务
systemctl daemon-reload
systemctl enable mysql_exporter
systemctl start mysql_exporter

检查

执行
curl -s http://127.0.0.1:9105/metrics | grep mysql_up
需要看到
mysql_up 1
否则就是失败。
失败时候,请执行
mysql --defaults-file=/home/app/mysqld_exporter/localhost_db.cnf -e "SELECT VERSION();"
检查数据库是否能正确连接。