PMM逻辑架构图
安装server端
[root@localhost ~]# docker pull percona/pmm-server:2
2: Pulling from percona/pmm-server
2d473b07cdd5: Pull complete
e05cef0f5a85: Pull complete
Digest: sha256:57a7a150218e35c0126466294367c18de12fe7d4b0076ab587684cc2110691ee
Status: Downloaded newer image for percona/pmm-server:2
#创建数据卷容器
[root@localhost ~]# docker create --volume /srv --name pmm-data percona/pmm-server:2 /bin/true
8caf217e44cf0cf18c5342c917e333375ef266378a243b5fc378e75b0c2779d4
#运行server容器,防火墙放行映射的端口
[root@localhost ~]# docker run -d -p 443:443 --volumes-from pmm-data --name pmm-server --restart always percona/pmm-server:2
47ebbbcdb79016e94caf79a3c585cf96424df2f160e322b6a55ed31fe328a85a
安装client端(server端必须通过容器部署,client端可以通过容器或者二进制包部署)
[root@localhost ~]# yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum install pmm2-client
[root@localhost ~]# pmm-admin --version
ProjectName: pmm-admin
Version: 2.25.0
PMMVersion: 2.25.0
Timestamp: 2021-12-13 09:38:36 (UTC)
FullCommit: 4b81157ad02975c417daef2600cb0dcd3907ffa1
向server注册(注册强制TLS连接,默认使用443端口注册,如果需要使用其它端口,在server端IP地址后面指定端口号)
#PMM默认管理员admin@admin
[root@localhost ~]# pmm-admin config --server-insecure-tls --server-url=https://admin:admin@172.16.200.12
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.
创建数据库用户,赋权
MariaDB [(none)]> CREATE USER 'pmm'@'localhost' IDENTIFIED BY 'pass' WITH MAX_USER_CONNECTIONS 10;
Query OK, 0 rows affected (0.016 sec)
MariaDB [(none)]> GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'localhost';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.004 sec)
添加监控数据源performance schema
#修改配置文件,启用performance schema
[root@localhost ~]# vim /etc/my.cnf.d/mariadb-server.cnf
performance_schema=ON
[root@localhost ~]# systemctl restart mariadb.service
[root@localhost ~]# mysql -uroot -ppassword
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.3.9-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SHOW VARIABLES LIKE 'performance_schema';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| performance_schema | ON |
+--------------------+-------+
1 row in set (0.001 sec)
#添加监控服务
[root@localhost ~]# pmm-admin add mysql --query-source=perfschema --username=pmm --password=pass --service-name=MYSQL_NODE --host=127.0.0.1 --port=3306
MySQL Service added.
Service ID : /service_id/e74ada1c-44ed-4cf6-b3bf-ba0b37ca4f2d
Service name: MYSQL_NODE
Table statistics collection enabled (the limit is 1000, the actual table count is 307).
[root@localhost ~]# pmm-admin inventory list services
Services list.
Service type Service name Address and Port Service ID
MySQL MYSQL_NODE 127.0.0.1:3306 /service_id/e74ada1c-44ed-4cf6-b3bf-ba0b37ca4f2d
PostgreSQL pmm-server-postgresql 127.0.0.1:5432 /service_id/7b3fc98e-3e6e-4e46-865c-85fd207ab42e
组件间数据流
参考文献
https://www.percona.com/doc/percona-monitoring-and-management/2.x/index.html