分析某个时间段内,表的选择、插入、更新、删除次数。需要用到percona-toolkit包中的一个工具pt-query-digest,脚本如下:
[root@syk ~] #, cat get_list.sh # !/bin/bash set - x # slow_file=ai-db1-slow.log slow_file=1美元 if [, $ # !=, 1,),,, then ,,,echo “使用:$ 0,slow.log”, ,,,echo ”,例如:$ 0,api-db1-slow.log”, ,,,exit 1;, fi pt-query-digest ——limit 10000, slow_file 美元;在/tmp/tmp_file bn=' grep -n “#,,,, 1, 0 x”,/tmp/tmp_file | awk -F ': ', ' {print 1美元}' ' tn=' grep -n “#, Query 1:“,/tmp/tmp_file | awk -F ': ', ' {print 1美元}' ' en=癳xpr tn 美元;安康;2” sed -n “bn, en美元”p /tmp/tmp_file 在/tmp/table_file cat /tmp/table_file | awk ,“{print 6美元”、“9”、“10美元}”,在/tmp/table_source/usr/local/mysql/bin/mysql -uroot  -pxxxxxxxx -S /tmp/mysql_3308.sock & lt; & lt; EOF use sykdb; drop table  slow_log; create table  slow_log ( cnt 才能varchar (30), type 才能varchar (30), tname 才能varchar (30) ); drop table  slow_table; create table  slow_table ( tname 才能varchar (30), select_cnt 才能varchar (30), insert_cnt 才能varchar (30), update_cnt 才能varchar (30), delete_cnt 才能varchar (30) ); load data  infile “/tmp/table_source”, into table slow_log FIELDS TERMINATED BY ', '; delete 得到slow_log where type="; insert into  slow_table (tname), select 不同(tname),得到slow_log; update slow_table  t set  t.select_cnt=(select 和(问),得到slow_log l where l.type=把≡瘛?以及l.tname=t.tname group by l.tname); update slow_table  t set  t.insert_cnt=(select 和(问),得到slow_log l where l.type=安迦搿?以及l.tname=t.tname group by l.tname); update slow_table  t set  t.update_cnt=(select 和(问),得到slow_log l where l.type=案隆?以及l.tname=t.tname group by l.tname); update slow_table  t set  t.delete_cnt=(select 和(问),得到slow_log l where l.type=吧境?以及l.tname=t.tname group by l.tname); select *,得到slow_table; EOF #最终获得of 脚本