PMM 基于 Docker 部署

发布时间 2023-12-12 17:39:02作者: a120608yby

1、Docker、Docker-Compose安装

https://www.cnblogs.com/a120608yby/p/9883175.html
https://www.cnblogs.com/a120608yby/p/14582853.html

2、基于Docker-Compose部署PMM

# vim docker-compose.yml 
version: '3'

services:
  pmm-server:
    image: percona/pmm-server:latest
    container_name: pmm-server
    cap_add:
      - SYS_PTRACE
    security_opt:
      - seccomp:unconfined
    ulimits:
      memlock: 67108864
    ports:
      - '80:80'
      - '443:443'
      - '2345:2345'
      - '15432:5432'
      - '9090:9090'
      - '11000:9000'
      - '11123:8123'
    networks:
      - ops_default
    restart: always
    volumes:
      - ./pmm-data:/srv

networks:
  ops_default:
    external: true

3、启动服务

docker compose up -d

4、查看服务启动状态

docker compose ps

5、访问

访问地址:https://部署主机的IP/
默认账号:admin
默认密码:admin

6、PMM Client安装

# 下载
https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html

# 安装
dnf localinstall /usr/local/src/pmm2-client-2.41.0-6.el9.x86_64.rpm -y

7、配置连接PMM Server

# pmm-admin config --server-insecure-tls --server-url=https://admin:admin@部署主机IP:443
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.

8、配置MySQL监控用户

> CREATE USER 'pmm'@'127.0.0.1' IDENTIFIED BY 'password';
> GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'127.0.0.1';

9、将MySQL添加到PMM中

# pmm-admin add mysql --username pmm --password 'password' demo-mysql8 localhost:3306
MySQL Service added.
Service ID  : /service_id/539ff836-d99b-491f-a0bf-379eb28b1c69
Service name: demo-mysql8

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

10、查看添加的服务

# pmm-admin list
Service type        Service name        Address and port        Service ID
MySQL               demo-mysql8         localhost:3306          /service_id/539ff836-d99b-491f-a0bf-379eb28b1c69

Agent type                 Status           Metrics Mode        Agent ID                                              Service ID                                              Port
pmm_agent                  Connected                            /agent_id/140e73b3-6401-4dd9-8e84-b3e85d92eb89                                                                0 
node_exporter              Running          push                /agent_id/e58886b6-17c9-49b7-9bcf-83e809504b03                                                                42000 
mysqld_exporter            Running          push                /agent_id/d577b7a6-b2d9-4819-8cfe-d78eefbc6cfb        /service_id/539ff836-d99b-491f-a0bf-379eb28b1c69        42002 
mysql_slowlog_agent        Running                              /agent_id/00c437ab-5099-4582-aec6-866c99812c4d        /service_id/539ff836-d99b-491f-a0bf-379eb28b1c69        0 
vmagent                    Running          push                /agent_id/f85813fc-2d69-4d21-ae05-1f47006937ba                                                                42001

11、查看服务监控

参考:

https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html
https://www.percona.com/software/pmm/quickstart