手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL运行状态监控(pt-mysql-summary)

[日期:2014-08-01] 来源:Linux社区  作者:壹頁書 [字体:大 中 小]

pt-MySQL-summary也是percona-toolkit-2.2.8-1.noarch.rpm工具集的一部分。
 
安装工具集请参考: http://www.linuxidc.com/Linux/2014-07/104034.htm
 
MySQL的show status命令 仅仅是一个状态的计数器。
 通常情况下,需要采集一个间隔的show status命令,然后分析它的趋势。
 
一定时间间隔的采集可以使用mysqladmin extended-status
 但是更简单的方法是使用pt-mysql-summary工具。
 
关于pt-mysql-summary工具的介绍请参考: http://www.linuxidc.com/Linux/2014-08/104929.htm
 
下面的脚本通过一个时间间隔的状态采集,
 得到这个间隔的增、删、改、查、提交、回滚的总数,然后通过gnuplot画图工具,绘制出图形。
 
脚本如下(Probe.sh):
 
#!/bin/bash
 #采集间隔时间,单位s
 asleep=10
 user=root
 password=root
 probe_file=probe.log
 output_image=/tmp/probe.png
 while [ 1 ] ; do
    a=$(pt-mysql-summary --user $user --password $password | grep -i "com_insert\|com_delete\|com_update\|com_select\|com_commit\|com_rollback" | awk    '{if(length($4)==0) print 0 ;else print $4}' | tr -t '\n' ' '); echo $(date "+%Y-%m-%d_%H:%M:%S") $a >> $probe_file
 
    gnuplot -e "set terminal png size 3000,1000 ; set size ratio 0.9 ; set output '$output_image' ; set xtic rotate by 90 ; set xdata time ; set grid;set    timefmt '%Y-%m-%d_%H:%M:%S' ; plot 'probe.log' using 1:2 with line title 'Commit', 'probe.log' using 1:3 with line title 'Delete', 'probe.log' using    1:4 with line title 'insert','probe.log' using 1:5 with line title 'rollback','probe.log' using 1:6 with line title 'select','probe.log' using 1:7 with    line title 'update' ; "
 done;
 

运行脚本,并且使用TPCC-MySQL基准测试工具开始测试(加一些流量容易看出效果)
 
TPCC-MySQL
http://www.linuxidc.com/Linux/2014-07/104238.htm
 
关于Gnuplot画图工具的简单使用
http://www.linuxidc.com/Linux/2014-08/104930.htm
 
查看绘图的结果:

 

Gnuplot
 set size ratio 0.9        Y轴:X轴 的比值
 set xtic rotate by 90    X轴的文字旋转90度

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-08/104928.htm

linux
相关资讯       MySQL监控  pt-mysql-summary 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款