pmm(Percona Monitoring and Management )是一个集MySQL性能指标监控和慢查询查看的套件,因界面美观、部署方便、功能全面在业界得到广泛运用;最近在客户端配置慢查询上报,使用如下命令:
pmm-admin add mysql:queries --user=XXX --password='XXX'
结果得到报错:
Error adding MySQL queries: problem with agent registration on QAN API: exit status 1
Error adding MySQL queries: GET http://IP/qan-api/instances/XXXXXX: API returned HTTP status code 500, expected 200: Instance.Get: dbm.Open: Error 1040: Too many connections
经排查是pmm-server自带的MySQL配置的最大连接数才151,而我配置了几百台db上报,把连接数打满了, 调整下就行了:
# 查看pmm-server的docker对应的container id
docker ps
# 进入container
docker exec -it <container id> /bin/bash
# 设置最大连接数
mysql -e "set global max_connections=10000"