zoukankan      html  css  js  c++  java
  • mysql 查询较慢的日志输出分析模块

    Audit mysql query slow.
    1. start slow log.
       Two method:
        (1)edit my.cnf ,add text as belows to [mysqld].
             #if long_query_time=0, all queries will be saved to log file
             long_query_time=1
             #create the log file and give the log file mysql access authority by chown mysql.mysql file_name
             log-slow-queries[=file_name]
        (2)start mysqld with the --log-slow-queries[=file_name]  option.

    2.analyze slow log
      I have fond two method to analyze the slow log.
      (1)mysqldumpslow which is supplied by mysql.
        Use this command we can see summarizes of the log file.
        mysqldumpslow file_name  //eg: mysqldumpslow /opt/test/mysql_slow.log
       
      (2)Myprofi.http://myprofi.sourceforge.net/.
        MyProfi is a command line tool that parses mysql query log and outputs statistics of most frequently used queries,
        sorting them by number of times they appear in a log file
        Down the source code from http://myprofi.sourceforge.net/ ,and copy parser.php to centos. Use follow command to analyze the log

       //show all slow queries.
       php parser.php -slow /opt/test/mysql.log

       //show top N slow queries.
       php parser.php -top N -slow /opt/test/mysql.log  
       
       //only show select slow queries, we can also add other options such as update ,insert ,delete.
       php parser.php -top 10 -type "select" -slow /opt/test/mysql.log  
  • 相关阅读:
    Domain Model
    linux 后台运行命令
    morphia(3)-查询
    [八省联考2018] 劈配
    [BZOJ 3218] a+b Problem
    [学习笔记] KM算法
    [HNOI2013] 消毒
    [HNOI2014] 画框
    [HDU 6057] Kanade's convolution
    [模板] 任意模数多项式乘法
  • 原文地址:https://www.cnblogs.com/likwo/p/1766520.html
Copyright © 2011-2022 走看看