MySQL性能监控

news/2024/5/18 22:22:00 标签: mysql, prometheus

1. 创建监控用户

mysql> CREATE USER 'mysqld_exporter'@'localhost' IDENTIFIED BY 'Mysqld_exporter@123' WITH MAX_USER_CONNECTIONS 3;
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> \q

2. 验证登录

mysql -umysqld_exporter -p

3. 安装mysqld_exporter

下载地址:

官网:Download | Prometheus

github:https://github.com/prometheus/mysqld_exporter

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.1/mysqld_exporter-0.15.1.linux-amd64.tar.gz
tar -zxvf mysqld_exporter-0.15.1.linux-amd64.tar.gz
mv mysqld_exporter-0.15.1.linux-amd64 /home/mysqld_exporter

4. 创建mysqld_exporter配置文件

vim /home/mysqld_exporter/my.cnf


[client]
user=mysqld_exporter # 创建的用户名
password=Mysqld_exporter@123 # 密码

5. 创建mysqld_exporter.service

vim /usr/lib/systemd/system/mysqld_exporter.service

[Unit]
Description=mysql Monitoring SystemDocumentation=mysql Monitoring System
[Service]
ExecStart=/home/mysqld_exporter/mysqld_exporter \
--collect.info_schema.processlist \
--collect.info_schema.innodb_tablespaces \
--collect.info_schema.innodb_metrics \
--collect.perf_schema.tableiowaits \
--collect.perf_schema.indexiowaits \
--collect.perf_schema.tablelocks \
--collect.engine_innodb_status \
--collect.perf_schema.file_events \
--collect.binlog_size \
--collect.info_schema.clientstats \
--collect.perf_schema.eventswaits \
--config.my-cnf=/home/mysqld_exporter/my.cnf
[Install]
WantedBy=multi-user.target

6. 启动mysqld_exporter

systemctl daemon-reload
systemctl enable mysqld_exporter --now

7. 修改prometheus配置

增加以下配置:

- job_name: mysql 
  params:
    auth_module: [client.servers]
  static_configs:
    - targets:
      - 192.168.33.131:9104
      - 192.168.33.96:9104

8. Granafa监控面板

地址:Dashboards | Grafana Labs


http://www.niftyadmin.cn/n/5278546.html

相关文章

【Ubuntu】为Docker安装NVIDIA运行时环境(NVIDIA Container Runtime for Docker)

在Ubuntu系统上,为Docker安装NVIDIA运行时环境(NVIDIA Container Runtime for Docker)通常涉及以下步骤: 安装Docker(如果您还没有安装): 首先,确保您的系统已经安装了Docker。您可以…

leetCode算法—10. 正则表达式匹配

10.给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 ‘.’ 和 ‘*’ 的正则表达式匹配。 难度:困难 *** 给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 ‘.’ 和 ‘*’ 的正则表达式匹配。 ‘.’ 匹配任意单个字符 ‘*’ 匹…

Postman使用总结--关联

当接口和接口之间,有依赖关系时,需要借助 postman 关联技术来实现

杰发科技AC7840——在Eclipse环境下使用Jlink调试

序 杰发给的代码里面已经做代码相关配置,搭建好eclipse环境即可运行,搭建步骤还是比较简单的。 参考文章 如何使用Eclipse搭配JLink来调试HelloWold应用程序?-电子发烧友网 软件链接 杰发科技Eclipse的sample代码里面的doc文章&#xff…

Java异常类分类,所有子类的父类是什么

1.异常的层次机构: 所有异常的父类是Throwable,它有两个子类,分别是Error和Exception。 2.Error: 表示系统错误,通常不能处理和恢复。比如StackOverFlowError或者OutOfMemoryError,出了问题只能结束程序…

力扣:203. 移除链表元素(Python3)

题目: 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val val 的节点,并返回 新的头节点 。 来源:力扣(LeetCode) 链接:力扣(LeetCode)官网 …

多表插入、删除操作(批量)——后端

多表插入 场景:当添加一个菜品时,还需要记录菜品的口味信息,因此需要对菜品表(dish)和口味表(dish_flavor)同时进行插入操作。 两个表的字段: 代码思路:由DishControll…

农夫山姆(0006)

题意 原来体积是ABC,现在体积是(A-1)* (B-2)*(C-2),输入一个现在的体积n,要求现在的体积比原来减少了多少,输出一个减小的最小值和最大值 输入 4 输出 28 41 说明 注意问题的答案可能足够大,所以必须使用 64 位…