Percona监控工具初探

Percona在2016年4月发布了一个监控套件,可以同时对多个MySQL、MongoDB实例进行监控

参考资料: 
1. https://www.percona.com/blog/2016/04/18/percona-monitoring-and-management/ 
2. https://www.percona.com/doc/percona-monitoring-and-management/index.html 
3. https://www.percona.com/doc/percona-monitoring-and-management/install.html 
安装过程描述的非常详尽,参考此文档足以

环境

操作系统版本CentOS 6.7 
MySQL版本为 MySQL 5.7

1. 安装

Percona监控工具初探_第1张图片

1.1 PMM Server

负责将收集到的数据存储、聚合和展现 
假定安装在192.168.100.1上 
1)

docker percona/pmm-server:1.0.6
  • 1

2)

docker create \
   -v /opt/prometheus/data \
   -v /opt/consul-data \
   -v /var/lib/mysql \
   -v /var/lib/grafana \
   --name pmm-data \
   percona/pmm-server:1.0.6 /bin/true
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3)

$ docker run -d \
   -p 80:80 \
   --volumes-from pmm-data \
   --name pmm-server \
   --restart always \
   percona/pmm-server:1.0.6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

到此,docker已经启动,可以访问

Component URL 备注
PMM landing page http://192.168.100.1 跳转页
Query Analytics (QAN web app) http://192.168.100.1/qan/ SQL分析
Metrics Monitor (Grafana) http://192.168.100.1/graph/ 
user name: admin password: admin
监控指标图表
Orchestrator http://192.168.100.1/orchestrator MySQL集群拓扑结构

其它: 
进入docker能够发现

UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Nov22 ?        00:00:00 /bin/bash /opt/entrypoint.sh
root        13     1  0 Nov22 ?        00:00:28 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/supervisor
mysql       16    13  0 Nov22 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe
pmm         17    13  0 Nov22 ?        00:05:23 /opt/consul agent -server -data-dir=/opt/consul-data -bootstrap -c
grafana     18    13  0 Nov22 ?        00:01:28 /usr/sbin/grafana-server --homepath=/usr/share/grafana --config=/e
root        19    13  0 Nov22 ?        00:00:00 nginx: master process nginx
root        20    13  0 Nov22 ?        00:00:00 /usr/sbin/cron -f
pmm         24    13  0 Nov22 ?        00:00:00 bash -c sleep 5 && /usr/local/percona/qan-api/start
pmm         28    13 10 Nov22 ?        02:11:57 /opt/prometheus/prometheus -config.file=/opt/prometheus/prometheus
pmm         40    13  0 Nov22 ?        00:00:00 bash -c sleep 7 && /usr/local/orchestrator/orchestrator http
root        50    13  2 Nov22 ?        00:36:27 /opt/node_exporter/node_exporter -web.listen-address=localhost:910
www-data   105    19  0 Nov22 ?        00:00:04 nginx: worker process
www-data   106    19  0 Nov22 ?        00:00:04 nginx: worker process
www-data   107    19  0 Nov22 ?        00:00:05 nginx: worker process
www-data   108    19  0 Nov22 ?        00:00:03 nginx: worker process
mysql      427    16  0 Nov22 ?        00:06:55 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-
pmm        458    24  0 Nov22 ?        00:00:00 bash /usr/local/percona/qan-api/start
pmm        471   458  0 Nov22 ?        00:03:10 /usr/local/percona/qan-api/bin/percona-qan-api -importPath github.
pmm        480   471  0 Nov22 ?        00:00:00 perl /usr/local/percona/qan-api/src/github.com/percona/qan-api/ser
pmm        499    40  0 Nov22 ?        00:03:44 /usr/local/orchestrator/orchestrator http
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

依照我的推断,从client端收集到的监控数据存储在MysQL中,然后经过聚合以后,在grafana中进行展现,因此为防止收集到监控数据丢失,可以在docker启动时,用-v参数把/var/lib/mysql,/var/lib/grafana 两个目录挂到宿主机上

1.2 PMM Client

负责收集MySQL的状态数据,并发给PMM Server 
假定安装在192.168.200.1上 
1) 安装percona仓库

sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
  • 1

2)安装client包

sudo yum install pmm-client
  • 1

3)配置监控

sudo pmm-admin add mysql --user root --password xxxx --host 127.0.0.1 --port 3306
  • 1

看到这里大家可能会想可以按host和port进行配置,pmm-client 是否无须部署到MySQL对应的机器上,其实这种说法是对的

pmm-client收的监控数据来源有这么几块 
a. MySQL所在机器的系统指标 
b. MySQL的performance_schema库 
c. slow-log(慢查询日志)

所以如果我们想收集a和c中的指标的话,最好还是将pmm-client部署在MySQL所在机器

4)查看配置后的结果

sudo pmm-admin list
  • 1
pmm-admin 1.0.6

PMM Server      | 192.168.100.1:80
Client Name     | wx-test-social18
Client Address  | 192.168.200.1
Service manager | unix-systemv

---------------- ----------------- ------------ -------- ----------------------------- ------------------------
SERVICE TYPE     NAME              CLIENT PORT  RUNNING  DATA SOURCE                   OPTIONS
---------------- ----------------- ------------ -------- ----------------------------- ------------------------
linux:metrics    wx-test-social18  42000        YES      -
mysql:queries    wx-test-social18  42001        YES      root:***@tcp(127.0.0.1:3306)  query_source=perfschema
mysql:metrics    wx-test-social18  42002        YES      root:***@tcp(127.0.0.1:3306)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

2. 交互界面

2.1 访问http://192.168.100.1/qan/

可以查看Query的分析结果 
Percona监控工具初探_第2张图片

2.2 访问http://192.168.100.1/graph/

部分系统指标 
Percona监控工具初探_第3张图片
MySQL的指标数据 
Percona监控工具初探_第4张图片
单表的统计情况 
Percona监控工具初探_第5张图片

你可能感兴趣的:(mysql)