How to Deploy Percona Database Performance Monitor with Docker

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

Concept of computer programming or software or game development
Image: Yaran/Adobe Stock

One responsibility of database administrators is to monitor the performance of their databases. But how is that done? Thanks to numerous open source projects, there are many ways to manage this task. Once said method is through the Percona Monitoring and Management system, which has:

  • Compatibility with MySQL, MariaDB, PostgreSQL, MongoDB and ProxySQL
  • ACID Compliance
  • Multiple version concurrency control
  • Support for triggers, views, subqueries, stored procedures, and more
  • InnoDB resource pool support
  • Supports InnoDB, XtraDB and MyRocks storage engines for MySQL/MariaDB and WiredTire, MMAPv1, InMemory and RocksDB for MongoDB
  • SQL functions
  • Monitors for query analysis and metrics
  • Supports checks for common security issues

SEE: Hiring Kit: Database Engineer (TechRepublic Premium)

If you need a database performance monitor, Percona might be exactly 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 will need to implement Percona

The only thing you will need to implement this database performance monitor is at least one machine that supports Docker and a user with sudo privileges. I will be demonstrating using two instances of Ubuntu Server 22.04. With those bits ready, let’s get the ball rolling.

How to install Docker

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

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | 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] https://download.docker.com/linux/ubuntu $(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 containerd.io -y

Add your user to the docker group with:

sudo usermod -aG docker $USER

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

How to implement Percona

First, create a volume for the deployment with:

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

Next, implement 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 be prompted to login with the default credentials of admin/admin.

Upon successful authentication, you will be prompted to change the password for the admin user. 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 those servers to the monitor. For that, we will continue with Docker. There are three bits of information you’ll need for this:

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

You’ll also need to make sure 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, deploy 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 (be sure to change SERVER and PWORD to match your deployment):

docker run -d \
--rm \
--name pmm-client \
-e PMM_AGENT_SERVER_ADDRESS=SERVER \
-e PMM_AGENT_SERVER_USERNAME=admin \
-e PMM_AGENT_SERVER_PASSWORD=PWORD \
-e PMM_AGENT_SERVER_INSECURE_TLS=1 \
-e PMM_AGENT_SETUP=1 \
-e PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml \
--volumes-from pmm-client-data \
percona/pmm-client:2

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

Now we can connect the client to the server with the command:

docker exec pmm-client pmm-admin config --server-insecure-tls --server-url=https://admin:[email protected]: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…
Registered.
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 on your Percona board (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 to get the latest tech tips for business professionals from Jack Wallen.

Leave a Comment