首页 > 编程学习 > prometheus监控mariadb

prometheus监控mariadb

发布时间:2022/8/12 13:38:35

创建数据库账号

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查看监控

Copyright © 2010-2022 ngui.cc 版权所有 |关于我们| 联系方式| 豫B2-20100000