How to Deploy Percona Database Performance Monitor with Docker

If you are a database administrator, you may want to be able to track the performance of these servers. Jack Wallen shows you how with Percona and Docker.

Image: Yaran/Adobe Stock

One of the responsibilities of database administrators is to monitor the performance of their databases. But how do we do this? Thanks to many open-source projects, there are many ways to handle this task. Once this method through the Percona monitoring and management system, which includes:

  • Support for MySQL, MariaDB, PostgreSQL, MongoDB and ProxySQL
  • ACID Compliance
  • Multi-version concurrency control
  • Support for triggers, views, subqueries, stored procedures and more
  • Support for InnoDB resource groups
  • Supports InnoDB, XtraDB and MyRocks storage engines for MySQL/MariaDB and WiredTire, MMAPv1, InMemory and RocksDB for MongoDB
  • SQL roles
  • Monitors both query analysis and metrics
  • Supports checks for common security issues

SEE: Recruitment Kit: Database Engineer (TechRepublic Premium)

If you need a database performance monitor, Percona might just be what you’re looking for, and I’ll show you how to get this system up and running with the help of Docker.

What you’ll need to deploy Percona

The only things you will need to deploy this database performance monitor are at least a machine that supports Docker and a user with sudo privileges. I will demonstrate using two instances of Ubuntu Server 22.04. With these elements ready, let’s get the ball rolling.

How to install Docker

The first thing to do is to install the GPG key for the official Docker repository with:

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Next, add the official Docker repository with the command:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install the necessary dependencies with the command:

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y

Finally, we can install the latest version of the Docker engine:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli -y

Add your user to the docker group with:

sudo usermod -aG docker $USER

Log out and log back in for the changes to take effect.

How to deploy Percona

First, create a volume for deployment with:

docker create -v /srv --name pmm-data percona/pmm-server:latest /bin/true

Next, deploy Percona with:

docker run -d -p 8000:80 -p 8443:443 --volumes-from pmm-data --name pmm-server --restart always percona/pmm-server:latest

How to Access the Percona Web Interface

You should now be able to access the Percona web interface by pointing a browser to https://SERVER:8443, where SERVER is the IP address of the hosting server. You will need to login using the default credentials of admin/admin.

Upon successful authentication, you will be prompted to change the administrator user password. This is essential not only for security, but also to connect the Percona monitoring agent.

How to deploy the Percona monitoring agent

In order for Percona to monitor the performance of your database servers, you must connect these servers to the monitor. For this, we will continue with Docker. There are three pieces of information you will need for this:

  • Percona server IP address
  • Administrator username for Percona, which is admin
  • Password for the Percona admin user, which you changed on first login

You will also need to ensure that Docker is installed on the database server you want to monitor. You can use the same instructions as before to do this. With Docker installed, run the latest Percona PMM client with:

docker pull percona/pmm-client:2

Create a volume for persistent data with:

docker create --volume /srv --name pmm-client-data percona/pmm-client:2 /bin/true

Finally, deploy the PMM agent with the following command (making sure to modify SERVER and PWORD to suit your deployment):

docker run -d
--name pmm-client
-e PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml
--volumes-from pmm-client-data

Where SERVER is the IP address of the hosting Percona monitoring server you deployed earlier and PWORD is the new password you created for the admin user.

We can now connect the client to the server with the command:

docker exec pmm-client pmm-admin config --server-insecure-tls --server-url=https://admin:PWORD@SERVER:8443

Where PWORD is the administrator password you created and SERVER is the IP address of your Percona server.

You should see, in the output:

Checking local pmm-agent status...

pmm-agent is running.
Registering pmm-agent on PMM Server…
Configuration file /usr/local/percona/pmm2/config/pmm-agent.yaml updated.
Reloading pmm-agent configuration…
Configuration reloaded.
Checking local pmm-agent status…
pmm-agent is running.

At this point, you should see the new node appear in your Percona dashboard (Figure A).

Figure A

Our new node is available for monitoring with Percona.

Congratulations, thanks to Docker you now have a working database performance monitor. For more information on Percona, be sure to check out the official documentation here.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech tips for professionals from Jack Wallen.