Awk takes out the slow log (MySQL) of the specified day and uses the tool to analyze

Source: Internet
Author: User

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;&GT;&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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.