PMM FOR MYSQL

DEPLOYING PERCONA MONITORING AND MANAGEMENT

In this tutorial, We are going to learn how to install and configure Percona Monitoring and Management to monitor Mysql and MongoDB metrics and queries in real-time.

To Install and Setup PMM Server, use one of the following Option:

  • Running PMM Server via Docker
  • Running PMM Server as a Virtual Appliance
  • Running PMM Server using AWS Marketplace

Here, We are going to install and Configure PMM server via Docker

Run PMM Server Via Docker

For this, First We need to install docker packages on Linux machine.

Install Docker

#rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

#yum update

#yum install docker-io -y

Start the Docker Service

#service docker start

Make sure the docker to run after the server reboot.

#chkconfig docker on

Setting Up Docker Container for PMM Server

Docker image is a collection of preinstalled software which enables running a selected version of PMM Server on your computer. A Docker image is not run directly. You use it to create a Docker container for your PMM Server. When launched, the Docker container gives access to the whole functionality of PMM.

The setup begins with pulling the required Docker image. Then, you proceed by creating a special container for persistent PMM data. The last step is creating and launching the PMM Server container.

Pull the PMM Server Image

#docker pull percona/pmm-server:latest

Create a PMM Docker Container

# docker create \
   -v /opt/prometheus/data \
       -v /opt/consul-data \
       -v /var/lib/mysql \
       -v /var/lib/grafana \
       --name pmm-data \
       percona/pmm-server:latest /bin/true

The previous commands does the following:
  • The docker create command instructs the Docker daemon to create a container from an image.
  • The -v options initialize data volumes for the container.
  • The --name option assigns a custom name for the container that you can use to reference the container within a Docker network. In this case: pmm-data.
  • percona/pmm-server:latest is the name and version tag of the image to derive the container from.
  • /bin/true is the command that the container runs.

Create and Launch PMM Server Container

$ docker run -d \
   -p 8080:443 \
   --volumes-from pmm-data \
   --name pmm-server \
   --restart always \
   percona/pmm-server:latest

The above commands does the following:

  • The docker run command runs a new container based on the percona/pmm-server:latest image.
  • The -d option starts the container in the background (detached mode).
  • The -p option maps the port for accessing the PMM Server web UI. For example, if port 80 is not available, you can map the landing page to port 8080 using -p 8080:80.
  • The -v option mounts volumes from the pmm-data container.
  • The --name option assigns a custom name to the container that you can use to reference the container within the Docker network. In this casepmm-server.
  • The --restart option defines the container’s restart policy. Setting it to always ensures that the Docker daemon will start the container on startup and restart it if the container exits.
  • percona/pmm-server:latest is the name and version tag of the image to derive the container from.

Now, We connect to PMM server Web interface using http://IPaddress of PMM Server

Verifying PMM Server

Accessing the Components of Web Interface

COMPONENT URL
PMM Landing Page http://IPAddress
Query Analytics (QAN Web App) http://IPAddress/qan
Metrics Monitor (Grafana) http://IPAddress/graph

Username:admin

Password:admin

Orchestrator http://IPAddress/orchestrator

Installation of PMM Client on all Database Hosts for Monitoring

PMM Client Setup

Install repo packages:

#yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

Install PMM Client

#yum install pmm-client -y

Connecting PMM Client to PMM Server

#pmm-admin config –server PMMSERVERIP

If you have changed the default port 80 when configuring PMM server, specify it after the server’s IP Address.

#pmm-admin config –server PMMSERVERIP:8080

Output

$ pmm-admin config --server 192.168.100.1

OK, PMM server is alive.
PMM Server      | 192.168.100.1
Client Name     | ubuntu-amd641
Client Address  | 192.168.200.1
  • When PMM client is connected to PMM server, We can start collecting data from database servers
  • After you connect the client to server, Enable data collection from database server by adding Monitoring services.

To Enable General System Metrics, Mysql Metrics & Query Metrics

#sudo pmm-admin add mysql --user root --password [email protected] (Mysql Database Username and Password)
To see what is being Monitored:

#pmm-admin list

Output

$ sudo pmm-admin list
...
PMM Server      | 192.168.100.1
Client Name     | ubuntu-amd64
Client Address  | 192.168.200.1
Service manager | linux-systemd
---------------- ----------- ----------- -------- ---------------- --------
SERVICE TYPE     NAME        LOCAL PORT  RUNNING  DATA SOURCE      OPTIONS
---------------- ----------- ----------- -------- ---------------- --------
linux:metrics    mongo-main  42000       YES      -
mongodb:metrics  mongo-main  42003       YES      localhost:27017

To Start and Stop Docker with PMM

#docker stop pmm-server && docker start pmm-server

Thanks for reading this article. Hope it helped a lot.