Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure mysql monitoring for prometheus service monitoring

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to configure mysql monitoring for prometheus service monitoring". In daily operation, I believe many people have doubts about how to configure mysql monitoring for prometheus service monitoring. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to configure mysql monitoring for prometheus service monitoring". Next, please follow the editor to study!

Mysql monitoring of prometheus service monitoring

If your machine has not yet installed prometheus, refer to the following installation steps:

Introduction and installation of part 1:prometheus

After familiarizing ourselves with the above two parts, let's go to today's service monitoring, taking mariadb as an example:

Monitoring mysql requires mysql_exporter to be installed on the monitored machine

1. Upload, decompress and install mysqld_exporter

Root@xinsz08-20 ~] # tar xf mysqld_exporter-0.12.1.linux-amd64.tar.gz file name is too long. Rename it: [root@xinsz08-20 ~] # mv mysqld_exporter-0.12.1.linux-amd64 mysqld_exporter [root@xinsz08-20 ~] # cd mysqld_exporter/ [root@xinsz08-20 mysqld_exporter] # pwd / root/mysqld_exporter

two。 Install mariadb

Root@xinsz08-20 mysqld_exporter] # yum install mariadb\ *-y [root@xinsz08-20 ~] # systemctl start mariadb [root@xinsz08-20 ~] # systemctl enable mariadb [root@xinsz08-20 ~] # ss-natlp | grep 3306 / / check whether the port is open LISTEN 080 0.0.0.0 yum install mariadb 3306 0.0.0.0 grep: (("mysqld", pid=67872,fd=22))

3. Create a mysql account in the database to collect data

[root@xinsz08-20 ~] # mysql MariaDB [(none)] > grant select,replication client,process ON *. * to 'mysql_monitor'@'localhost' identified by' 12345678; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)] > flush privileges; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)] > exit Bye

# Note: here is the prometheus server looking for mysql_exporter, and then mysql_exporter is looking for mariadb, so localhost is used here, which refers to the ip of mysql_exporter

4. Set mysql configuration information in mysql_exporter

[root@xinsz08-20 mysqld_exporter] # pwd / root/mysqld_exporter [root@xinsz08-20 mysqld_exporter] # vim .my.cnf (created by hand) [client] user=mysql_monitor password=12345678

5. Start mysql_exporter

[root@xinsz08-20 mysqld_exporter] # nohup. / mysqld_exporter-- config.my-cnf=/root/mysqld_exporter/.my.cnf & [1] 68166

6. Configure prometheus to pull mysql node information

[root@zmedu-17 prometheus-2.16.0.linux-amd64] # pwd / root/prometheus-2.16.0.linux-amd64 [root@zmedu-17 prometheus-2.16.0.linux-amd64] # vim prometheus.yml-job_name: 'mariadb' static_configs:-targets: [' 192.168.1.20 root/prometheus-2.16.0.linux-amd64 9104']

# make changes on the server side of prometheus

Restart the prometheus service

[root@zmedu-17 prometheus-2.16.0.linux-amd64] # pkill prometheus [root@zmedu-17 prometheus-2.16.0.linux-amd64] # lsof-iroot@zmedu-17 prometheus-2.16.0.linux-amd64 9090 [root@zmedu-17 prometheus-2.16.0.linux-amd64] #. / prometheus & [1] 84662 [root@zmedu-17 ~] # ss-naltp | grep 9090 LISTEN 0 128 [::]: 9090 [: :]: * users: ("prometheus" Pid=84662,fd=9))

7. View through the web side

Http://192.168.1.17:9090

Check the number of connections in mysql and see that there is only one connection:

Mysql_global_status_aria_pagecache_blocks_unused

8. Detailed explanation of prometheus.yml configuration file

Global: # Global configuration scrape_interval: 15s # how often data is collected evaluation_interval: 15s # how often is the rule evaluated scrape_timeout:10s # timeout of each data collection # Alertmanager configuration # alarm setting alerting: alertmanagers:-static_configs: # alarm rule Alarm can also be based on dynamic mode-targets: rule_files: # rule file # collect data configuration list scrape_configs:-job_name: 'prometheus'

9. English translation of prometheusUI

Alerts: you can see the alarm rule we defined Graph: the interface queries data, generates pictures, or returns data Status: the following target: indicates our remote monitoring, and you can see the operation of exporter.

At this point, the study on "how to configure mysql monitoring for prometheus service monitoring" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report