Get the App
SLTechnology News&Howtos  ›  Database  › 

How Grafana+Prometheus monitors MySql services

Shulou Source: shulou.com Published: 2022-05-31 15:49:27 11月10日 Update

This article mainly shows you "how Grafana+Prometheus monitors MySql services". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how Grafana+Prometheus monitors MySql services".

Architecture

Prometheus installation

Download address: https://prometheus.io/download

Execute the following command:

# # download wget https://github.com/prometheus/prometheus/releases/download/v2.0.0-rc.3/prometheus-2.0.0-rc.3.linux-amd64.tar.gz## Custom decompression Directory tar-xvf prometheus-2.0.0-rc.3.linux-amd64.tar.gz

Configure prometheus,vi prometheus.yml

IP corresponds to the server of our private network, and the port is the listening port of the corresponding exporter.

Run Prometheus

After the startup is successful, we can access it through the built-in web interface of Prometheus, http://ip:9090. If the following interface appears, the configuration is successful (ignore Linux1/2, which is the monitoring of the service)

MySql installation

The status and importance of MySql is self-evident, as an open source product is loved by the majority of small and medium-sized enterprises and Internet enterprises, so it is necessary for us to monitor it accordingly.

Due to the recent replacement of CentOS7, MySql is reinstalled here, and by the way, there seems to be no mysql in CentOS7's yum source by default. To solve this problem, we need to download the repo source for mysql.

List all version information:

Lsb_release-a

Download the repo source for mysql:

Wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

Install the mysql-community-release-el7-5.noarch.rpm package:

Rpm-ivh mysql-community-release-el7-5.noarch.rpm

Install mysql:

Yum install mysql-server-y

Modify permissions, otherwise an error will be reported:

Chown-R root:root / var/lib/mysql

Restart the mysql service:

Service mysqld restart

Log in and reset the password:

Novice quickly build "artifact" of MySql service

Mysqld_exporter installation

Download and extract:

Mysqld_exporter needs to connect to Mysql, first create a user for it and give it the required permissions:

Create the .my.cnf file vi .my.cnf:

[client] user=exporterpassword=123456

Run mysqld_exporter:

. / mysqld_exporter-config.my-cnf= ".my.cnf" & Prometheus configuration

Modify prometheus.yml to join the MySql node:

Restart Prometheus after saving, and check targets:

Finally, log in to grafana to view MySql monitoring information:

The above is all the contents of the article "how Grafana+Prometheus monitors MySql Services". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Services monitoring content articles configuration success enterprise information permissions interface ports learning help login operation important necessary self-evident small and medium-sized enterprises Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Shulou Information Microsoft macOS