Percona Monitoring and management Overview
Percona Monitoring and Management (PMM) is an open source platform for managing and monitoring MySQL and MongoDB performance. It was developed by Percona in collaboration with experts in managed database services, support, and consulting. PMM is a free open source solution that you can run in your own environment for maximum security and reliability. It provides comprehensive time-based analysis for MySQL and MongoDB servers to ensure that your data is working as efficiently as possible.
Percona monitors and manages the architecture
The PMM platform is based on a simple client-server model for efficient scalability. It includes the following modules:
- The PMM Client is installed on each database host that you want to monitor. It collects server metrics, general system metrics, and query analytics data to get a complete performance overview. The collected data is sent to the PMM server.
- The PMM Server is the core of the PMM, aggregating collected data and presenting it in the form of tables, dashboards, and graphs on the Web interface.
The PMM is a collection of tools designed to work together seamlessly. Some are developed by Percona, some are third-party open source tools.
- The following diagram illustrates the current structure of the PMM:
Write the picture description here
PMM Client
The PMM client package works with most popular Linux distributions:
- RPM for Red Hat Enterprise Linux (CentOS, Oracle Linux, Amazon Linux, etc.)
- DEB for Debian-based distributions (including Ubuntu, etc.)
The PMM client software package contains the following contents:
- Pmm-admin is a command line tool for managing PMM clients, for example, adding and deleting database instances to monitor.
- Percona-qan-agent is a service that manages query analysis (QAN) agents while collecting query performance data. It also connects to the QAN API in the PMM server and sends the collected data.
- Node_exporter is a Prometheus exporter that collects general system indicators. For more information, please refer to https://github.com/prometheus/node_exporter.
- Mysqld_exporter is Prometheus EXPORTER that collects MySQL server metrics. For more information, please refer to https://github.com/percona/mysqld_exporter.
- Mongodb_exporter is Prometheus Exporter that collects MongoDB server metrics. For more information, please refer to https://github.com/percona/mongodb_exporter.
- Proxysql_exporter is a Prometheus exporter that collects ProxySQL performance indicators. For more information, please refer to https://github.com/percona/proxysql_exporter.
PMM Server
The PMM server will run as a machine for your central monitoring host. It is distributed as a device by:
- Can be used to run Docker images of containers
- It can be run in VirtualBox or another hypervisor
- Amazon Machine Image (AMI) that can be run through Amazon Web Services (AWS)
The PMM server consists of the following tools:
-
Query analysis (QAN) enables you to analyze MySQL query performance over time. In addition to the client QAN proxy, this includes the following:
- The QAN API is the back end for storing and accessing query data collected by percona-Qan-Agent running on the PMM client
- QAN Web App is a Web application for visualizing collected Query Analytics data.
-
The Metrics Monitor (MM) provides a historical view of the metrics that are critical to a MySQL or MongoDB server instance. It includes the following:
- Prometheus is a third-party time series database that connects to exporters running on PMM clients and aggregates collected metrics.
- Consul provides a PMM client that can remotely list, add, and remove apis for Prometheus hosts.
- Grafana is a third-party dashboard and graphical builder for visualizing data aggregated by Prometheus in an intuitive Web interface.
- The Percona dashboard is the Grafana dashboard developed by Percona
-
Orchestrator is a tool for managing and visualizing the MySQL replication topology.
Deployment scheme (https://www.percona.com/doc/percona-monitoring-and-management/architecture.html#id13)
Reference:
[1] https://prometheus.io/docs/introduction/overview/
[2] https://www.consul.io/docs/
[3] https://www.consul.io/docs/
[4] https://github.com/outbrain/orchestrator/wiki/Orchestrator-Manual
Deploy Percona monitoring and management
The following procedure describes how to correctly deploy the PMM:
-
Run the PMM Server on the host to access the collected data, view time-based charts, and perform performance analysis.
The following options are available:
- Run the PMM server using Docker
- Run the PMM server using VirtualBox
- Run the PMM server using Amazon Machine Image (AMI)
Install and run PMM Server (Docker)
- Use Docker to run PMM Server
PMM server Docker image publicly hosted at https://hub.docker.com/r/percona/pmm-server/. To run PMM Server from a Docker image, the host must be able to run Docker 1.13 or higher and have network access rights. For more information on using Docker, see the Docker documentation (https://docs.docker.com/).
- CentOS 6 Install Docker
yum --enablerepo=epel -y install docker-io
/etc/rc.d/init.d/docker start
chkconfig docker on
Copy the code
Note: When using the PMM-Server image, use the specific version label, not the latest label. The current stable release is 1.1.3.
Step 1. Create a PMM data container
- To create a container for persistent PMM data, run the following command:
docker create \
-v /opt/prometheus/data \
-v /opt/consul-data \
-v /var/lib/mysql \
-v /var/lib/grafana \
--name pmm-data \
percona/pmm-server:1.13. /bin/true
Copy the code
- This container is not running, just make sure you retain all PMM data when upgrading to a newer PMM server image. Do not delete or recreate this container unless you intend to wipe out all PMM data and start over.
Step 2. Create and run the PMM server container
- To run the PMM server, use the following command:
docker run -d \
-p Awesome!:80 \
--volumes-from pmm-data \
--name pmm-server \
--restart always \
percona/pmm-server:1.13.
Copy the code
Note: port 666 is custom, because machine 80 is already occupied
Verify that the PMM is properly installed and running
Verify that the PMM server is running by connecting to the PMM Web interface using the IP address of the host running the container, And then on to monitor all installed on the database host PMM Client | Component urls | | | — — — — — – | — – | | PMM landing page | * http://192.168.0.99:port | | Query Analytics Fresh web app) | | | * http://192.168.0.99/qan/ Metrics Monitor (Grafana) | http://192.168.0.99/graph/User name: The admin Password: admin | | Orchestrator | | http://192.168.0.99/orchestrator
Example Delete the PMM server
Before stopping and deleting the PMM server, ensure that the relevant PMM client does not collect any data by deleting all instances of monitoring, as described in deleting monitoring services.
Docker stop PMM-server && docker rm PMM-server docker rm PMM-data # Delete PMM data containerCopy the code
Upgrade the PMM server
docker stop pmm-server # first stop
docker rm pmm-server Do not perform this operation if you want to preserve the collected data
docker run -d \
-p 999:80 \
--volumes-from pmm-data \
--name pmm-server \
--restart always \
--init \
percona/pmm-server:1.13.
Copy the code
Install the PMM client on Red Hat and CentOS
The PMM client is a set of agents and exporters installed on the MySQL or MongoDB host that you want to monitor. The component collects various data about general system and database performance and sends this data to the appropriate PMM server component. Note: Agents should not be installed on database servers with the same hostname because the PMM server uses the hostname to identify the collected data.
Install the PMM client
The PMM client should run on any modern Linux distribution, but the PMM client package provided by Percona can only be installed automatically from the repository of the most popular Linux distributions:
- The system has no percona yum source and needs to be added
sudo yum install https://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-4.noarch.rpm
Copy the code
- Install the PMM-Client software package
sudo yum install pmm-client -y
Copy the code
Connect the PMM client to the PMM server
Use pmM-admin config –help to view the help
[root@backup-server ~]# sudo pmm-admin config --server 192.168.0.99:666
OK, PMM server is alive.
PMM Server The Client Name | | 192.168.0.99:666 backup-server
Client Address | 192.168.0.47
Copy the code
Start data collection
After connecting the client to the PMM server, enable data collection from the database instance by adding monitoring services. To enable general system metrics, MySQL metrics, and query analysis, run:
Manage the PMM client
Check the network connection between PMM client and PMM server. Pmm-admin check-network # Configure how the PMM Client communicates with the PMM server. Pmm-admin config # Print help for any commands and exits pmM-admin help # Print information about the PMM client pmM-admin info # Print all monitoring services added for this PMM client PMM-admin list # PMM -admin Ping # Check whether the PMM server is alive. Pmm-admin purge # Purge metrics from PMM server Pmm-admin rm # Delete the monitoring service PMM-admin Repair # Restart the PMM PMM-admin restart # Print the password used by the PMM Client pMM-admin show-passwords # Enable the monitoring service Pmm-admin Start # Stop the monitoring service PMM-admin Stop # Clean the PMM Client PMM-admin uninstall before uninstallationCopy the code
- Add MySQL query analysis service
By default, there is no initial mysql user to be used by PMM-client. You need to create the user by yourself. You can log in to mysql to create the user
GRANT ALL PRIVILEGES ON *.* TO 'pmm'@'192.168.0.47' IDENTIFIED BY 'pmmpassword';
Succeeded in creating a user
[root@backup-server ~]# sudo pmm-admin add mysql:metrics --user pmm --password pmmpassword --host 192.168.0.47
Mysql > add user to monitor mysql server
OK, now monitoring MySQL metrics using DSN pmm:* * *@tcp(192.168.0.47:3306)
[root@backup-server ~]# sudo pmm-admin add mysql:queries --user pmm --password pmmpassword --host 192.168.0.47
Copy the code
- View the services monitored by the current server
[root@backup-server ~]# pmm-admin list
pmm-admin 1.1.3
PMM Server The Client Name | | 192.168.0.99:666 backup-server
Client Address | 192.168.0.47
Service Manager | unix-systemv
-------------- -------------- ----------- -------- ------------------------------- ------------------------------------------
SERVICE TYPE NAME LOCAL PORT RUNNING DATA SOURCE OPTIONS
-------------- -------------- ----------- -------- ------------------------------- ------------------------------------------
mysql:queries backup-server - YES pmm:* * *@tcp(192.168.0.47:3306) query_source=slowlog, query_examples=true
linux:metrics backup-server 42000 YES -
mysql:metrics backup-server 42002 YES pmm:* * *@tcp(192.168.0.47:3306) tablestats=OFF
Copy the code
An error screen
QAN API error: “qh.Profile: No query classes for selected instance and time range. Please check whether your MySQL settings match the recommended.”.Check the /var/log/qan-api.log file in docker container for more information
# slow_query_log = 1 long_query_time = 2 # slow_query_log = 2 # mysql5.6 /etc/init.d/mysql restartCopy the code
Continue to visit http://192.168.0.99:666 to see the status of monitoring mysql
Write the picture description here
Write the picture description here
Write the picture description here
Follow-up tutorial on monitoring MongoDB…
Author: quietly is my girlfriend links: www.jianshu.com/p/97233bac2… The copyright of the book belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.