Grafana+prometheus system monitoring MySQL

Source: Internet
Author: User
Tags grafana

Architecture

Grafana and Prometheus prior to installation configuration, see: Grafana+prometheus to create a comprehensive three-dimensional monitoring system

MySQL Installation

MySQL's status and importance is self-evident, as open-source products by the vast number of small and medium-sized enterprises and internet companies love, so here we also need to monitor it accordingly.

Due to the recent replacement of CentOS7, MySQL is installed here again, by the way to make a record, the CentOS7 yum source default seems to be no MySQL. To solve this problem, we need to download the MySQL repo source first.

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

To 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, or you will get an error:

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

To restart the MySQL service:

service mysqld restart

Sign in and reset your password:

## 直接回车进入mysql控制台mysql -u rootmysql > use mysql;mysql > update user set password=password(‘123456‘) where user=‘root‘;mysql > exit;
Mysqld_exporter Installation

Download and unzip:

https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gztar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz

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

GRANTONTO‘exporter‘@‘localhost‘identifiedby‘123456‘GRANTSELECTONTO‘exporter‘@‘localhost‘flushprivileges;

Create a. 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:

Global:  Scrape_interval:15sEvaluation_interval:15sScrape_configs:  - job_name:PrometheusStatic_configs:      - Targets: [' localhost:9090 ']        Labels:          instance:Prometheus- job_name:Linux1Static_configs:      - Targets: [' 192.168.1.120:9100 ']        Labels:          instance:Sys1- job_name:Linux2Static_configs:      - Targets: [' 192.168.1.130:9100 ']        Labels:          instance:Sys2- job_name:Redis1Static_configs:      - Targets: [' 192.168.1.120:9121 ']        Labels:          instance:Redis1- job_name:MysqlStatic_configs:      - Targets: [' 192.168.1.120:9104 ']        Labels:          instance:Db1

To restart Prometheus after saving, view targets:

Last login Grafana view MySQL monitoring information:

Reference Documentation:
Https://github.com/prometheus/mysqld_exporter

Grafana+prometheus system monitoring MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.