mk-query-digest - a mysql log analysis tool

Posted by Vincent on August 21, 2011

./mk-query-digest slow.log

--如此简单就可以分析mysql的慢日志,当然如果slow log很大时,这么做会消耗很大的性能。

主要参数:

--limit: default: 95%:20  Limit output to the given percentage or count.
--select: Compute aggregate statistics for these attributes.  (Query_time,Lock_time,Rows_sent,Rows_examined,user,db:Schema,ts)
--type:The type of input to parse (default slowlog). YYMMDD [HH:MM:SS]
--since: Parse only queries newer than this value (parse queries since this date).
--until: ...
--order-by:  Sort events by this attribute and aggregate function.default: Query_time:sum

Aggregate Meaning

========= ============================

sum       Sum/total attribute value
min       Minimum attribute value
max       Maximum attribute value
cnt       Frequency/count of the query

-----------------------------------------------------------------------------------------------------

./mk-query-digest --limit 2 --select Query_time,Lock_time,Rows_sent,Rows_examined,ts slow.log

./mk-query-digest --limit 2 --select Query_time,Lock_time,Rows_sent,Rows_examined,ts slow.log |grep -v '1us' |grep -v '10us'|grep -v '100us'|grep -v '1ms'|grep -v '10ms'   |grep -v '100ms'|grep -v '1s'|grep -v '10s'|grep -v 'SHOW'|grep -v 'EXPLAIN'

也可以通过tcpdump获取实时数据

tcpdump -i bond0 port 3306 -s 65535 -x -n -q -tttt -c 10000 |./mk-query-digest --type tcpdump  --limit 5

关于mk-query-digest

http://www.maatkit.org/doc/mk-query-digest.html
--

http://hi.baidu.com/liheng_2009/blog/item/5973c3896f57d06f9f2fb46c.html

 

关于tcpdump

http://www.xfocus.net/articles/200105/172.html

 


This work is licensed under a CC A-S 4.0 International License.