prometheus监控mariadb

创建数据库账号

create user 'mysql_exporter'@'localhost' IDENTIFIED BY 'imnot007*';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_exporter'@'localhost';

下载mysql_exporter

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.14.0/mysqld_exporter-0.14.0.linux-amd64.tar.gz

准备mysqld_exporter环境

[root@k8s-master ~]# tar -zxvf mysqld_exporter-0.14.0.linux-amd64.tar.gz 

[root@k8s-master ~]# cp mysqld_exporter-0.14.0.linux-amd64/mysqld_exporter /usr/local/bin/

[root@k8s-master ~]# cat /root/.my.cnf 
[client]
user=mysql_exporter
password=imnot007*

[root@k8s-master ~]# cat /etc/systemd/system/mysqld_exporter.service
[unit]
Description=Prometheus Node Exporter
After=network.target

[Service]
ExecStart=/usr/local/bin/mysqld_exporter --config.my-cnf=/root/.my.cnf

[install]
WantedBy=multi-user.target

配置prometheus

# vim prometheus.yml
- job_name: "prometheus-mysql-metrics"
    static_configs:
      - targets: ["10.211.55.20:9104"]

产看prometheus

Grafana导入模板

grafana查看监控

posted @ 2022-08-12 13:31  Maniana  阅读(155)  评论(0编辑  收藏  举报