prometheus配置mysqld_exporter

1、安装mysqld_exporter
下载,解压并改名

tar -xvf mysqld_exporter-0.14.0.linux-amd64.tar.gz
mv mysqld_exporter-0.14.0.linux-amd64 mysqld_exporter

在mysqld_exporter目录下创建my.cnf

cat <<EOF >/opt/exporter/mysqld_exporter/my.cnf
[client]
user=mysql_monitor
password=123456
EOF

创建mysql用户并授权

GRANT PROCESS,REPLICATION CLIENT,SELECT ON *.* TO 'mysql_monitor'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;    
EXIT;

2、设置开机自启动
配置服务

cat <<EOF >/etc/systemd/system/mysqld_exporter.service
[Unit]
Description="mysqld_exporter"
Documentation=https://github.com/prometheus/mysqld_exporter
After=network.target

[Service]
WorkingDirectory=/opt/exporter
Type=simple
ExecStart=/opt/exporter/mysqld_exporter/mysqld_exporter --config.my-cnf=/opt/exporter/mysqld_exporter/my.cnf --web.listen-address=:9104
Restart=on-failure
RestartSec=10s
SuccessExitStatus=0
LimitNOFILE=300000

[Install]
WantedBy=multi-user.target
EOF

启动服务并设置开机自启

systemctl enable --now mysqld_exporter

查看状态

systemctl status mysqld_exporter

本地访问 http://127.0.0.1:9104/metrics有数据就安装成功了

curl http://127.0.0.1:9104/metrics

接下来去prometheus的配置文件里把这台服务器加进去就OK了


标签:暂无标签
版权属于:瑶玲OvO 所有,转载请注明文章来源。

本文链接: https://linmy.cn/index.php/prometheus/50.html

赞 (0)

评论区

发表评论

字数
0
/200
26+18=?

暂无评论,要不来一发?

回到顶部