Prometheus监控mariadb
  1D6o7E39IQo1 2023年11月02日 47 0
安装mariadb 及 mariadb-server

Prometheus监控mariadb_ALERTMANAGER

Prometheus监控mariadb_ALERTMANAGER_02

导入监控插件
[root@k8smaster1 mariadb]# tar -zxvf mysqld_exporter-0.10.0.linux-amd64.tar.gz
复制exporter到 bin 目录下
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]# cp mysqld_exporter /usr/local/bin/
配置可执行权限
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]# chmod +x /usr/local/bin/mysqld_exporter
启动mariadb
[root@k8smaster1 ~]# systemctl start mariadb
You have new mail in /var/spool/mail/root
[root@k8smaster1 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2023-07-18 20:54:41 CST; 6s ago
  Process: 19777 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 19640 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 19776 (mysqld_safe)
    Tasks: 20
   Memory: 103.8M
   CGroup: /system.slice/mariadb.service
           ├─19776 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─19941 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: MySQL manual for more instructions.
Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: Please report any problems at http://mariadb.org/jira
Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: The latest information about MariaDB is available at http://mariadb.org/.
Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: You can find additional information about the MySQL part at:
Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: http://dev.mysql.com
Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: Consider joining MariaDB's strong and vibrant community:
Jul 18 20:54:39 k8smaster1 mariadb-prepare-db-dir[19640]: https://mariadb.org/get-involved/
Jul 18 20:54:39 k8smaster1 mysqld_safe[19776]: 230718 20:54:39 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Jul 18 20:54:39 k8smaster1 mysqld_safe[19776]: 230718 20:54:39 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jul 18 20:54:41 k8smaster1 systemd[1]: Started MariaDB database server.
[root@k8smaster1 ~]#
创建mariadb 用户
MariaDB [(none)]> CREATE USER 'mysql_exporter'@'localhost' IDENTIFIED BY 'Abcdef123!.';

Prometheus监控mariadb_ALERTMANAGER_03

mysql_exporter 授权
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_exporter'@'localhost';

Prometheus监控mariadb_ALERTMANAGER_04

配置mysql_exporter 免密访问
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]# vim my.cnf
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]# pwd
/root/mariadb/mysqld_exporter-0.10.0.linux-amd64
You have new mail in /var/spool/mail/root
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]# cat my.cnf 
[client]
user=mysql_exporter
password=Abcdef123!.
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]#
启动 mysql_exporter
[root@k8smaster1 mysqld_exporter-0.10.0.linux-amd64]# nohup ./mysqld_exporter --config.my-cnf=./my.cnf &

Prometheus监控mariadb_ALERTMANAGER_05

更新 Prometheus-alertmanager 配置文件
- job_name: 'mysql'
      static_configs:
      - targets: ['192.168.1.170:9104']

Prometheus监控mariadb_MYSQL_06


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  jmWSp8RIQOBK   2023年11月02日   35   0   0 MySQLdocker
1D6o7E39IQo1
作者其他文章 更多

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13