PMM配置监控PG数据库
作者:互联网
1. 架构图
2.网址
https://www.percona.com/software/pmm/quickstart
https://www.percona.com/doc/percona-monitoring-and-management/2.x/
查看版本
https://hub.docker.com/r/percona/pmm-server/tags
3. 安装
-- 拉取镜像
docker pull percona/pmm-server:2.15
-- 创建PMM数据容器
--删除之前的
docker rm pmm-data docker create --name pmm-data \ -v /pmmdata \ percona/pmm-server:2.15 /bin/true
-- 创建PMM服务器容器
docker rm -f pmm-server docker run -d --name lhr-pmm-server -h lhr-pmm-server \ -p 280:80 -p 2443:443 \ --volumes-from pmm-data \ -e SERVER_USER=lishiyan \ -e SERVER_PASSWORD=lishiyan \ -e ORCHESTRATOR_ENABLED=true \ -e METRICS_RETENTION=48h \ --restart always \ percona/pmm-server:2.15
-- 访问web界面
admin/admin
-- 进入PMM服务器
docker exec -it pmm-server bash
-- 连接到PMM服务器
pmm-admin config --server-insecure-tls --server-url=https://admin:admin@127.0.0.1:443 pmm-admin list
以下是执行步骤
--在监控机器上执行
[root@pmm yum.repos.d]# docker create --name pmm-data \ > -v /pmmdata \ > percona/pmm-server:2.15 /bin/true 1c05c838d6e2cf75bb77a952750b48569086d001cabe0c29762aa35157d2907c [root@pmm yum.repos.d]# docker run -d --name pmm-server -h pmm-server \ > -p 280:80 -p 2443:443 \ > --volumes-from pmm-data \ > -e SERVER_USER=lishiyan \ > -e SERVER_PASSWORD=lishiyan \ > -e ORCHESTRATOR_ENABLED=true \ > -e METRICS_RETENTION=48h \ > --restart always \ > percona/pmm-server:2.15 b27905de4e0cc169d836dfa15b33301d003bc57209142b6b0be61ca179900823
监控PG数据库
--需要在监控的数据库上开启如下功能:
ALTER SYSTEM SET track_io_timing=ON; SELECT pg_reload_conf(); CREATE USER pmm WITH SUPERUSER ENCRYPTED PASSWORD 'pmm';
--配置监控的PG主机
[root@allsql01 ~]# pmm-admin config --server-insecure-tls --server-url=https://admin:admin@10.10.10.188:2443 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. [root@allsql01 ~]# pmm-admin list Service type Service name Address and port Service ID Agent type Status Metrics Mode Agent ID Service ID pmm_agent Connected /agent_id/e40485ef-9834-46e8-8749-b9bbbbbc1aac node_exporter Running push /agent_id/1b7aee5a-24e3-4e65-b131-d94b173e6e6e vmagent Running push /agent_id/2b40cc87-e805-496d-ac87-603ca998839b
--添加数据库,注意发现下边中出现waitting状态
[root@allsql01 ~]# pmm-admin add postgresql --username=pmm --password=pmm --host=10.10.10.11 --port=5432 --service-name=PG-10.10.10.11-5432 PostgreSQL Service added. Service ID : /service_id/1f06cfca-4d82-472e-9a00-28b610984716 Service name: PG-10.10.10.11-5432 [root@allsql01 ~]# pmm-admin list Service type Service name Address and port Service ID PostgreSQL PG-10.10.10.11-5432 10.10.10.11:5432 /service_id/1f06cfca-4d82-472e-9a00-28b610984716 Agent type Status Metrics Mode Agent ID Service ID pmm_agent Connected /agent_id/e40485ef-9834-46e8-8749-b9bbbbbc1aac node_exporter Running push /agent_id/1b7aee5a-24e3-4e65-b131-d94b173e6e6e postgres_exporter Running push /agent_id/640c5077-10ed-4e90-be7a-0b5d4fc2b53e /service_id/1f06cfca-4d82-472e-9a00-28b610984716 postgresql_pgstatements_agent Waiting /agent_id/f5e55c7b-54d1-4efc-9b8c-801d3a1bcd52 /service_id/1f06cfca-4d82-472e-9a00-28b610984716 vmagent Running push /agent_id/2b40cc87-e805-496d-ac87-603ca998839b
出现这个waitting状态需要配置pg优化组件,并重启数据库
shared_preload_libraries='pg_stat_statements' track_io_timing = on track_activity_query_size = 2048 pg_stat_statements.max = 10000 pg_stat_statements.track = all pg_stat_statements.track_utility = on pg_stat_statements.save = on
postgres@allsql01->pg_ctl -D /data/pgdata/11/data -l logfile restart waiting for server to shut down.... done server stopped waiting for server to start.... done server started postgres@allsql01->psql -h localhost psql (11.7) Type "help" for help. postgres=# create extension pg_stat_statements; CREATE EXTENSION [root@allsql01 ~]# pmm-admin list Service type Service name Address and port Service ID PostgreSQL PG-10.10.10.11-5432 10.10.10.11:5432 /service_id/1f06cfca-4d82-472e-9a00-28b610984716 Agent type Status Metrics Mode Agent ID Service ID pmm_agent Connected /agent_id/e40485ef-9834-46e8-8749-b9bbbbbc1aac node_exporter Running push /agent_id/1b7aee5a-24e3-4e65-b131-d94b173e6e6e postgres_exporter Running push /agent_id/640c5077-10ed-4e90-be7a-0b5d4fc2b53e /service_id/1f06cfca-4d82-472e-9a00-28b610984716 postgresql_pgstatements_agent Running /agent_id/f5e55c7b-54d1-4efc-9b8c-801d3a1bcd52 /service_id/1f06cfca-4d82-472e-9a00-28b610984716 vmagent Running push /agent_id/2b40cc87-e805-496d-ac87-603ca998839b
标签:Service,--,数据库,agent,server,PG,pmm,PMM,id 来源: https://blog.51cto.com/lishiyan/2644406