MySQL慢日志分析工具mysqlsla

作者:Chris

install #

##############install mysqlsla################

git clone https://github.com/daniel-nichter/hackmysql.com.git
cd hackmysql.com/mysqlsla/
yum install -y perl perl-DBI perl-Time-HiRes perl-DBD-MySQL
perl Makefile.PL 
make
make install
cd /data/mysql/binlog/
mysqlsla -lt slow  -sf "+select" -top 100  slow

crontab #


30 09 * * *    sh /opt/slowlog/mysqlsla.sh

cat opt/slowlog/mysqlsla.sh

#!/bin/bash

DATE=`date +%Y%m%d`

DATE2=`date +"%Y%m%d" -d "-1day"`

cd /opt/slowlog

gunzip -c /nas/DB120/logs/slowlog/slowquery_3.log.$DATE*  > slowquery120

/usr/local/bin/mysqlsla -lt  slow -top 10 -sort t_sum  slowquery120 > 120_slow_t_sum_$DATE2.sql

/usr/local/bin/mysqlsla -lt  slow -top 10 -sort c_sum  slowquery120 > 120_slow_c_sum_$DATE2.sql

您的评论

Build by Loppo 0.6.14