Infra

PMM

Dev.Congsik 2025. 6. 19. 11:41
728x90

PMM(Percona Monitoring and Management)은 MySQL, MariaDB, MongoDB 등 오픈소스 DB를 위한 성능 모니터링 및 진단 플랫폼입니다.
Prometheus + Grafana 기반으로 동작하며, 다음을 제공합니다:

  • 실시간 쿼리 성능 분석 (QAN)
  • 노드/DB 인스턴스 상태 모니터링
  • Exporter 기반 메트릭 수집
  • Replication, Slow Query, InnoDB 상태 등 시각화
  • Grafana 대시보드 제공

 

PMM 구성 요소

PMM Server 메트릭 수집, 저장, 시각화를 담당 (Docker 또는 패키지 설치)
PMM Client 각 DB 노드에 설치, 메트릭 수집 agent
pmm-agent client 내부에서 실행되며, Exporter 및 설정 전달 담당
mysqld_exporter MySQL/MariaDB의 성능 메트릭 수집
qan-agent 쿼리 성능 수집 (slow log 또는 Performance Schema 기반)

 

구축 환경

운영체제 Ubuntu 20.04+ (Docker 기반)
MariaDB 버전 10.11.13 (도커 컨테이너 7개: master + slave 6개)
PMM 클라이언트 pmm2-client_2.44.1-6.focal_amd64.deb
PMM 서버 Docker 컨테이너로 구동
서버 주소 192.168.0.19 (localhost)
MariaDB 포트 master: 43306, slave: 43307 ~ 43312

* Mariadb Master/slave 사전 구성 후 slave에서의 Mariadb Replication 모니터링을 위해 구축

 

PMM 설치과정 (Ubuntu 20.04 기준)

1. docker 설치

apt update

//docker 설치
apt install -y docker

//docker 기동
systemctl start docker
systemctl status docker
systemctl enable docker


2. PMM Server 설치 및 실행


//PMM Server용 docker 데이터 볼륨 생성

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


//docker 컨테이너 실행

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

-> 9080, 80(http) / 9443, 443(https)

 


//docker 컨테이너 확인 (pmm-server)

docker ps

CONTAINER ID   IMAGE                      COMMAND                  CREATED        STATUS     ES
4cb1133475c1   percona/pmm-server:2       "/opt/entrypoint.sh"     2 hours ago    Up 2 hours (healthy)   0.0.0.0:9080->80/tcp, :::9080->80/tcp, 0.0.0.0:9443->443/tcp, :::9443->443/tcp   pmm-server




//서버 대시보드 확인 (9080, 9443 포트 개방 후 진행)

  • 9080: Web UI (HTTP)
  • 9443: Web UI (HTTPS, PMM Client 접속용)

Web 접속: https://192.168.0.19:9443
기본 계정: admin / admin

 


3. PMM Client 설치 (각 컨테이너 내부에서 진행, master, slave 모두)

//컨테이너 접속

docker exec -it [컨테이너명] bash


//apt 업데이트 및 필요도구 설치

apt update && apt install -y wget curl gnupg lsb-release

 

//설치파일 다운로드

wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb
sudo dpkg -i percona-release_latest.generic_all.deb


//PMM Client 설치

root@30272a358a13:/# apt install -y ./pmm2-client_2.44.1-6.focal_amd64.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'pmm2-client' instead of './pmm2-client_2.44.1-6.focal_amd64.deb'
The following NEW packages will be installed:
  pmm2-client
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 0 B/94.0 MB of archives.
After this operation, 217 MB of additional disk space will be used.
Get:1 /pmm2-client_2.44.1-6.focal_amd64.deb pmm2-client amd64 2.44.1-6.focal [94.0 MB]
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package pmm2-client.
(Reading database ... 11066 files and directories currently installed.)
Preparing to unpack .../pmm2-client_2.44.1-6.focal_amd64.deb ...
Adding system user `pmm-agent' (UID 101) ...
Adding new group `pmm-agent' (GID 101) ...
Adding new user `pmm-agent' (UID 101) with group `pmm-agent' ...
Creating home directory `/usr/local/percona' ...
Unpacking pmm2-client (2.44.1-6.focal) ...
Setting up pmm2-client (2.44.1-6.focal) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

 

 

//설치 확인

root@30272a358a13:/# pmm-admin --version
ProjectName: pmm-admin
Version: 2.44.1
PMMVersion: 2.44.1
Timestamp: 2025-04-16 11:18:12 (UTC)
FullCommit: c9b7236d1d8edeb5cee7d593320731577c3035f5

 

 

//agent setup

root@30272a358a13:/# pmm-agent setup \
  --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml \
  --server-insecure-tls \
  --server-address=192.168.0.19:9443 \
  --server-username=admin \
  --server-password=admin \
  --force
INFO[2025-06-19T01:25:30.413+00:00] Loading configuration file /usr/local/percona/pmm2/config/pmm-agent.yaml.  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Temporary directory is not configured and will be set to /usr/local/percona/pmm2/tmp  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/node_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/mysqld_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/mongodb_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/postgres_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/proxysql_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/rds_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/azure_exporter  component=setup
INFO[2025-06-19T01:25:30.414+00:00] Using /usr/local/percona/pmm2/exporters/vmagent  component=setup
Checking local pmm-agent status...
pmm-agent is not running.
Registering pmm-agent on PMM Server...
Registered.
Configuration file /usr/local/percona/pmm2/config/pmm-agent.yaml updated.
Please start pmm-agent: `pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml`.




//agent 기동

root@30272a358a13:/# pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml &

 


//클라이언트 서버 연결

pmm-admin config \
  --server-insecure-tls \
  --server-url=https://admin:admin@192.168.0.19:9443 \
  --force

 


4. pmm 클라이언트 구성

//pmm 사용자 생성 (마스터에서 최초 1회만 실행)
CREATE USER 'pmm'@'127.0.0.1' IDENTIFIED BY 'pmm' WITH MAX_USER_CONNECTIONS 20;

//pmm 사용자 권한 부여, flush (마스터에서 최초 1회만 실행)
GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'127.0.0.1';
FLUSH PRIVILEGES;

-> 사용자 생성은 마스터 노드에서 한번만 진행할 것!!

 

//mariadb 서비스 pmm에 추가
pmm-admin add mysql --username=pmm --password=pmm --query-source=perfschema --service-name=teamup-mariadb-slave-chat

MySQL Service added.
Service ID  : /service_id/006ac94b-d977-47f4-9523-8c5b77942e68
Service name: teamup-mariadb-master

Table statistics collection enabled (the limit is 1000, the actual table count is 452).

 

 

 

728x90

'Infra' 카테고리의 다른 글

Scouter APM  (0) 2025.05.13