Hi, I want to share a Docker Compose configuration to run Percona Server for MySQL + PMM + QAN.
I use this to develop my application, very handy, you can immediately see database queries and metrics in PMM.
version: '3.7'
services:
mysql:
image: "percona/percona-server:8.3.0-1.1-multi"
volumes:
- mysqldata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: database
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot", "-proot-password"]
interval: 5s
timeout: 5s
retries: 20
ports:
- "3306:3306"
command: >
--performance-schema --innodb_monitor_enable=all
--slow_query_log --slow_query_log_file=/mysql/slowlogs/slow.log --long_query_time=0
pmm-server:
image: percona/pmm-server:2
platform: "linux/amd64"
container_name: pmm-server
restart: always
ports:
- 80:80
- 443:443
volumes:
- pmm-data:/srv
environment:
- DISABLE_TELEMETRY=0
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 5
pmm-client-mysql:
image: percona/pmm-client:2
platform: "linux/amd64" // MacOS ARM processor compatibility mode
container_name: pmm-client-mysql
depends_on:
mysql:
condition: service_healthy
pmm-server:
condition: service_healthy
environment:
PMM_AGENT_SERVER_ADDRESS: pmm-server
PMM_AGENT_SERVER_USERNAME: admin
PMM_AGENT_SERVER_PASSWORD: admin
PMM_AGENT_SERVER_INSECURE_TLS: 1
PMM_AGENT_CONFIG_FILE: config/pmm-agent.yaml
PMM_AGENT_SETUP: 1
PMM_AGENT_SETUP_FORCE: 1
PMM_AGENT_PRERUN_SCRIPT: "pmm-admin status --wait=10s; pmm-admin add mysql --query-source=perfschema --username=root --password=password --host=mysql --port=3306 MYSQL_SERVICE"
volumes:
mysqldata:
pmm-data:
I’m using a macOS Arm laptop, you may need to modify the Image field to suit your OS.
PMM can be opened in a browser at localhost, and the application can also connect to the database at localhost.