One responsibility of database administrators is keeping tabs on the performance of their databases. But how does one do that? Thanks to numerous open-source projects, there are plenty of ways to manage this task. Once such method is via the Percona Monitoring and Management system, which features:
- 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 the InnoDB, XtraDB, and MyRocks storage engines for MySQL/MariaDB and WiredTire, MMAPv1, InMemory and RocksDB for MongoDB
- SQL Roles
- Monitors for 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 just might be exactly what you’re looking for and I’m going to 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’ll need to deploy this database performance monitor are at least one machine that supports Docker and a user with sudo privileges. I’ll be demonstrating using two instances of Ubuntu Server 22.04. With those bits at the ready, let’s get the ball rolling.
How to install Docker
The first thing 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
Log out and log back in for the changes to take effect.
How to deploy Percona
First, create a volume for the 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 be required to log in using the default credentials of admin/admin.
Upon successful authentication, you’ll be prompted to change the admin user password. This is essential not just for security, but for connecting the Percona monitoring agent.
How to deploy the Percona monitoring agent
For Percona to be able to monitor the performance of your database servers, you have to connect those servers to the monitor. For that, we’ll continue with Docker. There are three bits of information you’ll need for this:
- IP Address of Percona server
- Admin username for Percona, which is
admin
- Password for Percona admin user, which you changed upon the first login
You’ll 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 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 change SERVER and PWORD to fit 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 show up 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 about Percona, make sure to check out the official documentation here.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.