How to deploy the Percona database performance monitor with Docker
If you’re a database administrator, you might want to be able to track the performance of these servers. Jack Wallen shows you how to do it with Percona and Docker.
One job of database administrators is to keep track of the performance of their databases. But how does one do it? Thanks to numerous open source projects, there are many ways to accomplish this task. One such method is through the Percona monitoring and management system, which provides:
- 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 analytics 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 what you’re looking for, and I’ll show you how to get this system up and running using Docker.
What you need to deploy Percona
The only things you need to deploy this database performance monitor are at least a computer that supports Docker and a user with sudo privileges. I will demonstrate 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 required 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
Log out and back in for the changes to take effect.
How to deploy Percona
First, create a volume for mounting 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 must log in with the default credentials of admin/admin.
After successful authentication, you will be prompted to change the admin user password. This is not only important for security reasons, but also for the connection of 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 proceed with Docker. To do this, you need three pieces of information:
- IP address of the Percona server
- Admin username for Percona, that is
admin
- Password for the Percona Admin user that you changed when you first logged in
You also need to make sure Docker is installed on the database server you want to monitor. You can use the same instructions from earlier to do this. With Docker installed, pull down the latest Percona pmm client with:
docker pull percona/pmm-client:2
Create a persistent data volume with:
docker create --volume /srv --name pmm-client-data percona/pmm-client:2 /bin/true
Finally, deploy the PMM agent with the following command (make sure to change SERVER and PWORD according to 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 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 admin 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 in your Percona dashboard (Figure A).
Figure A
Congratulations, thanks to Docker you now have a database performance monitor up and running. For more information on Percona, see the official documentation here.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for the latest tech advice for business professionals from Jack Wallen.