Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519446
  • 博文数量: 240
  • 博客积分: 791
  • 博客等级: 军士长
  • 技术积分: 1694
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-23 18:21
文章分类

全部博文(240)

文章存档

2013年(21)

2012年(219)

我的朋友

分类:

2012-07-03 09:35:52

 Mysql_slow_log_parser.txt 
txt脚本的名字要改名为pl

使用方式:

./Mysql_slow_log_parser.pl /data/mysqldata/3306/data/zsd-slow.log

之前zsd-slow.log的内容:

/usr/local/mysql55/bin/mysqld, Version: 5.5.25-log (Source distribution). started with:
Tcp port: 3306  Unix socket: /data/mysqldata/3306/mysql.sock
Time                 Id Command    Argument
# Time: 120702 12:10:27
# User@Host: root[root] @ localhost []
# Query_time: 1.558936  Lock_time: 0.000077 Rows_sent: 0  Rows_examined: 262144
use test;
SET timestamp=1341245427;
insert into t1 select * From t1;
# Time: 120702 12:10:31
# User@Host: root[root] @ localhost []
# Query_time: 3.077640  Lock_time: 0.000083 Rows_sent: 0  Rows_examined: 524288
SET timestamp=1341245431;
insert into t1 select * From t1;
# Time: 120702 12:10:38
# User@Host: root[root] @ localhost []
# Query_time: 6.081219  Lock_time: 0.000075 Rows_sent: 0  Rows_examined: 1048576
SET timestamp=1341245438;
insert into t1 select * From t1;
# Time: 120702 12:10:58
# User@Host: root[root] @ localhost []
# Query_time: 2.402953  Lock_time: 0.000152 Rows_sent: 1048576  Rows_examined: 2097152
SET timestamp=1341245458;
select * from t1 order by name;
# Time: 120702 12:13:18
# User@Host: root[root] @ localhost []
# Query_time: 13.259154  Lock_time: 0.000144 Rows_sent: 0  Rows_examined: 2097152
SET timestamp=1341245598;
insert into t1 select * From t1;
# Time: 120702 12:16:03
# User@Host: root[root] @ localhost []
# Query_time: 25.903786  Lock_time: 0.000089 Rows_sent: 0  Rows_examined: 4194304
SET timestamp=1341245763;
insert into t1 select * From t1;

之后输出的内容:

 Starting...
### 3 Queries
### Total time: 22.418013, Average time: 7.472671
### Taking 3.077640 , 6.081219 , 13.259154  seconds to complete
### Rows analyzed 524288, 1048576 and 2097152
SET timestamp=XXX;
insert into tXXX select * From tXXX;

SET timestamp=1341245598;
insert into t1 select * From t1;


### 1 Query
### Total time: 2.402953, Average time: 2.402953
### Taking 2.402953  seconds to complete
### Rows analyzed 2097152
SET timestamp=XXX;
select * from tXXX order by name;

SET timestamp=1341245458;
select * from t1 order by name;


### 1 Query
### Total time: 1.558936, Average time: 1.558936
### Taking 1.558936  seconds to complete
### Rows analyzed 262144
use test;
SET timestamp=XXX;
insert into tXXX select * From tXXX;

use test;
SET timestamp=1341245427;
insert into t1 select * From t1;


这个脚本可以很好的汇总和分析慢查询日志,晚上写个定时的脚本,输出发送邮件给自己,可以很好的查看,Mysql服务器慢查询的问题。
阅读(490) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~