First, the demand is 1 parts slow log query to develop, because slow log file is very large 10 a few g after the final discussion, give a day's slow log to develop. 1. Related script cat slow.sh#!/bin/basholdday=150421newday=150423awk -v a= $oldday -v b= $newday '/^# time:/{if (a<$ (NF-1) &&$ (NF-1) <b) c=1;else c=0}c ' /opt/mysql/ 192.168.30.10.SLOW&NBSP;>&NBSP;/OPT/SLOW.SQL2, parameter description-v var= $v Assign the V value to Var, if there are multiple variables to be assigned, write multiple-V, Each variable assignment corresponds to a-v3, export result ll /opt/slow.sql -rw-r--r-- 1 root root 527188 2015-06-02 09:03 /opt/slow.sql Analysis Tool Collection (PT-QUERY-DIGEST&NBSP;MYSQLSLA) 1, pt-query-digest (analyze mysql queries from logs, processlist, and tcpdump.) 1) Download pt-query-digest (1 perl scripts) wget &NBSP;PERCONA.COM/GET/PT-QUERY-DIGEST2) executes the script for execute permission chmod +x pt-query-digest3)./pt-query-digest / Opt/mysql/1.1.1.1.slow2, mysqlsla-2.0.31) Download Mysqlsla (1 perl scripts) the attachment in the blog is Mysqlsla.rar (http://hackmysql.com/scripts/ Mysqlsla-2.03.tar.gz source Address not available) 2) unzip TAR&NBSP;XF&NBSP;MYSQLSLA.RAR3) compile and install Cd mysqlsla-2.03 perl makefile.pl make make installps: You can actually copy the script (Mysqlsla) from the compiled machine and put the script in/usr/local/bin/ Mysqlsla4, execute MYSQLSLA&NBSP;/OPT/MYSQL/1.1.1.1.SLOW3, Mysqldumpslow (1 perl scripts) 1) dpkg -s when installing mysql-client /usr/bin/mysqldumpslowmysql-client-5.5: /usr/bin/mysqldumpslow2, Executive mysqldumpslow /opt/mysql/ 1.1.1.1.slow
This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1657402
Awk takes out the slow log (MySQL) of the specified day and uses the tool to analyze