PMM서버는 3가지 설치 방식이 있지만 여기서는 Docker 방식을 이용하여 설치합니다.
다른 방식의 서버 설치 방식은 PMM 홈페이를 참조바랍니다.
https://www.percona.com/doc/percona-monitoring-and-management/2.x/index.html
CentOS 7으로 설치 되었으며 OS 버전 정보는 아래와 같이 확인
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
1. Docker 설치
PMM 설치에 앞서 Docker를 설치하고 PMM 서버가 설치된 Docker 컨테이너를 내려 받아야 한다.
-- yum 업데이트를 해서 최신 패키지정보를 업데이트 한다.
[root@localhost ~]# yum -y update
-- Docker & Docker Registry 설치
[root@localhost ~]# yum -y install docker docker-registry
-- 서비스 등록
[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
-- 서비스 실행
[root@localhost ~]# systemctl start docker
-- 상태 확인
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2022-01-27 11:28:03 KST; 52s ago
Docs: http://docs.docker.com
Main PID: 6017 (dockerd-current)
CGroup: /system.slice/docker.service
├─6017 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path...
└─6022 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/c...
2. PMM Server 설치
PMM server는 Docker로 설치된 Image만 내려받으면 되기때문에 아주 간단하다.
-- Docker Image 내려받기
[root@localhost ~]# docker pull percona/pmm-server
Using default tag: latest
Trying to pull repository docker.io/percona/pmm-server ...
latest: Pulling from docker.io/percona/pmm-server
2d473b07cdd5: Pull complete
e05cef0f5a85: Pull complete
Digest: sha256:57a7a150218e35c0126466294367c18de12fe7d4b0076ab587684cc2110691ee
Status: Downloaded newer image for docker.io/percona/pmm-server:latest
-- Image 확인
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/percona/pmm-server latest 2cfce486d2a8 6 weeks ago 1.78 GB
[root@localhost ~]#
-- PMM Data 컨테이너 생성
[root@localhost ~]# docker create -v /opt/prometheus/data -v /opt/consul-data -v /var/lib/mysql --name pmm-data percona/pmm-server /bin/true
724188b30b7c0d1d5655d328a769fe6ad16434df35b867497ef38d8644ef5a2c
-- 컨테이너 이미지 확인
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
724188b30b7c percona/pmm-server "/bin/true" 34 seconds ago Created pmm-data
-- PMM Server 컨테이너 실행
-- 외부에서 접속하는 port를 변경하여 설정이 가능하다 (80 -> 8080, 443 -> 4433)
[root@localhost ~]# docker run --detach --restart always --publish 8080:80 --publish 4433:443 --volumes-from pmm-data --name pmm-server percona/pmm-server
3ee95170ceeb8b59a5902095ff7b4338b3b06f03cd35d875f8a635e5d65a3d28
-- 현재 실행중인 컨테이너 확인
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3ee95170ceeb percona/pmm-server "/opt/entrypoint.sh" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:8080->80/tcp, 0.0.0.0:4433->443/tcp pmm-server
-- 컨테이너 중지
[root@localhost ~]# docker stop 3ee95170ceeb
-- 컨테이너 삭제
[root@localhost ~]# docker rm 3ee95170ceeb
3. PMM Server 접속
서버의 IP와 port를 확인해서 서버 콘솔을 접속한다.
url : http://서버 IP:8080
콘솔 접속시 최초 ip/password는 admin/admin이며 접속 후 password 변경화면이 나온다.
4. PMM Client 설치
PMM 서버설치가 끝났으면 Client를 설치하여 연결하면 된다.
-- yum repositories 등록
[root@mysql_test1 ~]# yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
-- pmm-client 설치
[root@mysql_test1 ~]# yum install -y pmm2-client
-- pmm-admin 설치 version 확인
[root@mysql_test1 ~]# pmm-admin --version
ProjectName: pmm-admin
Version: 2.25.0
PMMVersion: 2.25.0
Timestamp: 2021-12-13 09:38:36 (UTC)
FullCommit: 4b81157ad02975c417daef2600cb0dcd3907ffa1
[root@mysql_test1 ~]# systemctl status pmm-agent
● pmm-agent.service - pmm-agent
Loaded: loaded (/usr/lib/systemd/system/pmm-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2022-01-27 14:01:19 KST; 3min 0s ago
Main PID: 3056 (pmm-agent)
CGroup: /system.slice/pmm-agent.service
└─3056 /usr/sbin/pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml
클라이언트 설치가 끝나면 Mysql parameter를 설정하여 PMM 계정 생성 및 performance_schema를 활성활 시켜준다.
PMM 계정 생성 및 권한 부여
-- 계정 생성
root@localhost:(none) > create user pmm@'127.0.0.1' identified by 'XXXX' WITH MAX_USER_CONNECTIONS 10;
-- 권한 부여
root@localhost:(none) > GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD, show view ON *.* TO 'pmm'@'127.0.0.1' ;
root@localhost:(none) > GRANT SELECT, UPDATE, DELETE, DROP ON performance_schema.* TO 'pmm'@'127.0.0.1';
Mysql 성능 모니터링을 위해서 slow query와 performance_schema 사용을 해야한다.
slow_query_log = ON
slow_query_log_file = /log/slow_query.log
long_query_time = 1
log_output = FILE
performance_schema=ON
PMM Server 등록
-- PMM Server 연결
[root@mysql_test1 ~]# pmm-admin config --server-insecure-tls --server-url=https://admin:XXXX@10.0.2.14:4433
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.
[root@mysql_test1 ~]#
-- confile 확인
[root@mysql_test1 ~]# cat /usr/local/percona/pmm2/config/pmm-agent.yaml
# Updated by `pmm-agent setup`.
---
id: /agent_id/bad3f41d-dfb0-4384-b718-3ab13bc996a7
listen-address: 127.0.0.1
listen-port: 7777
server:
address: 10.0.2.14:4433
username: admin
password: XXXX
insecure-tls: true
paths:
paths_base: /usr/local/percona/pmm2
exporters_base: /usr/local/percona/pmm2/exporters
node_exporter: /usr/local/percona/pmm2/exporters/node_exporter
mysqld_exporter: /usr/local/percona/pmm2/exporters/mysqld_exporter
mongodb_exporter: /usr/local/percona/pmm2/exporters/mongodb_exporter
postgres_exporter: /usr/local/percona/pmm2/exporters/postgres_exporter
proxysql_exporter: /usr/local/percona/pmm2/exporters/proxysql_exporter
rds_exporter: /usr/local/percona/pmm2/exporters/rds_exporter
azure_exporter: /usr/local/percona/pmm2/exporters/azure_exporter
vmagent: /usr/local/percona/pmm2/exporters/vmagent
tempdir: /tmp
pt_summary: /usr/local/percona/pmm2/tools/pt-summary
pt_pg_summary: /usr/local/percona/pmm2/tools/pt-pg-summary
pt_mysql_summary: /usr/local/percona/pmm2/tools/pt-mysql-summary
pt_mongodb_summary: /usr/local/percona/pmm2/tools/pt-mongodb-summary
ports:
min: 42000
max: 51999
debug: false
trace: false
[root@mysql_test1 ~]#
mysqld_exporter 연동
[root@mysql_test1 ~]# pmm-admin add mysql --query-source=perfschema --username=pmm --password=XXXX
MySQL Service added.
Service ID : /service_id/4fe4ddc3-c355-4e14-85f9-07d008f952dd
Service name: mysql_test1-mysql
Table statistics collection enabled (the limit is 1000, the actual table count is 328).
Dashboard 확인하면 아래와 같이 mysql 서버가 연결이 된것을 볼 수 있다.
'Database > PMM' 카테고리의 다른 글
PMM에서 Memory 단위 표기 방법 (2) | 2022.08.16 |
---|---|
PMM(Grafana)에서 Email Alert 설정하기 (0) | 2022.06.14 |
WMI Exporter 대시보드에서 Hostname으로 서버 선택하기 (0) | 2022.06.10 |
PMM서버에 Windows Export 연동 (0) | 2022.05.31 |
PMM 이란? (DB 모니터링 솔루션) (0) | 2022.01.27 |
댓글