5 kinds mysql log analysis tool for Competition

5 kinds mysql log analysis tool for Competition

Excerpt: linux.chinaitlab.com   been Views: 79


By the yangyi provided on 2009-08-13 22:18:05


mysql slow log is used to record a long execution time (more than long_query_time sec) sql a logging tool.                
Enable slow log
There are two ways to enable:
1, by the in my.cnf log-slow-queries [= file_name]
2, when the mysqld process starts, specify the -log-slow-queries [= file_name] option
Compare the five common tools
mysqldumpslow, mysqlsla, myprofi, mysql-explain-slow-log, mysqllogfilter
mysqldumpslow . slow query log analysis tools, mysql official output graph below:
The main function is to slow sql of different statistics
Occurrences (Count), 
Perform the most time (Time), 
The total cumulative time consuming (Time), 
Lock wait time (Lock), 
The total number of rows sent to the client (Rows), 
The total number of scanning lines (Rows), 
Sql statement itself and the user (abstract bit format, such as limit 1, 20, N represents a limit N).

mysqlsla , hackmysql.com launch of a log analysis tool (The site also maintains mysqlreport, mysqlidxchk and other more practical tool for mysql)
Overall, very powerful data reporting, is very conducive to analyze the causes of slow queries, including the implementation of frequency, amount of data, query consumption.
 
Format as follows:
The total number of queries (queries total), the number of de-duplicated sql (unique)
Sort the contents of the output report (sorted by)
The most significant slow sql statistics, including the average execution time, lock wait time, the total number of result rows, the total number of scan lines.
 
The percentage of the total number of executions sql and the log number of slow Count.
Time, execution time, including total time, average time, minimum, maximum time, the time accounted for a percentage of the total time of slow sql.
95% of Time, the removal of the fastest and slowest sql, coverage accounted for 95 percent of the execution time of sql.
Lock Time, time waiting for the lock.
95% of Lock, 95% of slow sql lock wait time.
Rows sent, the number of result rows statistics, including average, minimum, maximum number.
The Rows Examined, the number of lines scanned.
Database, which belong to the database
Users, which user, IP, accounting for the percentage of all users perform sql
Query abstract, the abstract sql statement
Query sample, sql statement
 
除了以上的输出, 官方还提供了很多定制化参数, 是一款不可多得的好工具.
 
mysql-explain-slow-log, 德国人写的一个perl脚本.
http://www.willamowius.de/mysql-tools.html
功能上有点瑕疵, 不仅把所有的 slow log 打印到屏幕上, 而且统计也只有数量而已. 不推荐使用.    
mysql-log-filter, google code上找到的一个分析工具.提供了 python 和 php 两种可执行的脚本.
http://code.google.com/p/mysql-log-filter/
功能上比官方的mysqldumpslow, 多了查询时间的统计信息(平均,最大, 累计), 其他功能都与 mysqldumpslow类似.
特色功能除了统计信息外, 还针对输出内容做了排版和格式化, 保证整体输出的简洁. 喜欢简洁报表的朋友, 推荐使用一下.    
myprofi, 纯php写的一个开源分析工具.项目在 sourceforge 上.
http://myprofi.sourceforge.net/            
功能上, 列出了总的慢查询次数和类型, 去重后的sql语句, 执行次数及其占总的slow log数量的百分比.
从整体输出样式来看, 比mysql-log-filter还要简洁. 省去了很多不必要的内容. 对于只想看sql语句及执行次数的用户来说, 比较推荐.
总结
工具/功能 General statistics Advanced statistics script Advantage
mysqldumpslow stand by not support perl mysql official comes
mysqlsla stand by stand by perl Powerful, full data report, strong customization capabilities.
mysql-explain-slow-log stand by not support perl no
mysql-log-filter stand by Partially supported python or php Without loss of function of the premise, simple to maintain output
myprofi stand by not support php Very concise

Original Address: https: //blog.csdn.net/samxx8/article/details/6868724

Guess you like

Origin www.cnblogs.com/jpfss/p/12077812.html