How to Setup Percona Monitoring and Management for MySQL on Rocky Linux?

I have tried to document step by step how to setup Percona Monitoring and Management for MySQL on Rocky Linux. I hope it will be useful for those who need it!

High Level Steps

1-Check Environment
2-Install PMM Server
2.1-Disable Firewall & Selinux
2.2-Pull Latest PMM Docker Image
2.3-Create Docker Container to Keep Data
2.4-Check PMM Server IP
2.5-Go to PMM Login Page and Change Default Password
3-Install PMM Client on Target DB Server
3.1-Disable Firewall & Selinux
3.2-Download and Install Percona Repo Package
3.3-Install Percona Monitoring and Management Client
3.4-Verify the Installation
4-Register PMM Client with PMM Server
5-Create PMM User for Monitoring on Target Database
6-Register the Server on Target Server to Enable Monitoring
6.1-Check Available Options
6.2-Add MySQL to Monitoring
6.3-Check pmm-admin list
7-Check PMM Portal for Newly Added Database
8-PMM Server Shutdown/Startup Commands

1-Check Environment

ROLEHOSTNAMEIPOS
PMM Serverrocky95-pmm192.168.1.160Rocky Linux 9.5
MySQL Serverrocky95-mysql8192.168.1.161Rocky Linux 9.5

2-Install PMM Server

2.1-Disable Firewall & Selinux

# Disable & Check Firewall
sudo systemctl status firewalld
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl status firewalld

# Disable & Check Selinux
vi /etc/selinux/config
SELINUX=disabled
reboot
sestatus

2.2-Pull Latest PMM Docker Image

yum install podman-docker
docker pull percona/pmm-server:2
docker images

2.3-Create Docker Container to Keep Data

I will keep PMM Data in /data/pmm directory.

mkdir -p /data/pmm

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

docker volume ls

docker run --detach --restart always --publish 443:443 --volumes-from pmm-data --name pmm-server percona/pmm-server:2

docker ps

docker inspect pmm-data | egrep "Source|Destination"

2.4-Check PMM Server IP

ip addr

2.5-Go to PMM Login Page and Change Default Password

https://192.168.1.160/graph/login

3-Install PMM Client on Target DB Server

3.1-Disable Firewall & Selinux

# Disable & Check Firewall
sudo systemctl status firewalld
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl status firewalld

# Disable & Check Selinux
vi /etc/selinux/config
SELINUX=disabled
reboot
sestatus

3.2-Download and Install Percona Repo Package

sudo yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm

3.3-Install Percona Monitoring and Management Client

sudo yum install pmm2-client

3.4-Verify the Installation

sudo pmm-admin -v

4-Register PMM Client with PMM Server

## Syntax
sudo pmm-admin config --server-insecure-tls --server-url=https://admin:<password>@pmm.example.com

## Run Below Command
## My PMM Server Ip is 192.168.1.160
## Use Own Admin Password
sudo pmm-admin config --server-insecure-tls --server-url=https://admin:admin2025@192.168.1.160:443

5-Create PMM User for Monitoring on Target Database

##### For MySQL 8.0 #####
# 192.168.1.161 is my target MySQL database to be monitored
mysql -u root -p
CREATE USER 'pmm'@'192.168.1.161' IDENTIFIED BY 'Welc0me1!' WITH MAX_USER_CONNECTIONS 10;
GRANT SELECT, PROCESS, REPLICATION CLIENT, RELOAD, BACKUP_ADMIN ON *.* TO 'pmm'@'192.168.1.161';
FLUSH PRIVILEGES;

6-Register the Server on Target Server to Enable Monitoring

6.1-Check Available Options

pmm-admin add --help

6.2-Add MySQL to Monitoring

# Use Your Own Host IP Address
sudo pmm-admin add mysql --username=pmm --password=Welc0me1! --host=192.168.1.161 --port=3306 --query-source=perfschema

6.3-Check pmm-admin list

pmm-admin list

7-Check PMM Portal for Newly Added Database

https://192.168.1.160/graph/login

8-PMM Server Shutdown/Startup Commands

# Shutdown PMM Server
docker ps -a
docker stop pmm-server
docker ps -a

# Startup PMM Server
docker ps -a
docker start pmm-server
docker ps -a

# Check PMM Home Page
https://192.168.1.160/graph/login