Skip to content

Instantly share code, notes, and snippets.

@pensz
Last active December 15, 2015 22:38
Show Gist options
  • Save pensz/f1715aa9e9d7c3dddfed to your computer and use it in GitHub Desktop.
Save pensz/f1715aa9e9d7c3dddfed to your computer and use it in GitHub Desktop.
MySQL general log analytic

MySQL general log analytic

项目目的

解决SQL日志分析难的问题。通过该项目达到以下目的:

  • 用户方便的按关键词、操作类型等查询MySQL执行过的SQL语句
  • 方便得到针对MySQL查询的相关统计信息

项目组成

  • app中SQL的格式化

  • app中,对要分析的SQL后面加上 # {queryname}以便后续分析使用

  • 日志存储

  • DBA通过hadoop的client将MySQL的general log放入到HDFS中

  • 日志分析

  • 自定义Inputformat处理MySQL general log

  • 在HWI中建立对应的表

  • Map Reduce job通过分析general log得到一个中间结果,用于报表统计

                          +----------------------------+
                          |                            |
                          | Custom InputFormat + HWI   |  ---> User Ad-hoc Query 
                          |                            |
   +-------------------+  |  +----------+              |             
   | MySQL general log +--+->|   HDFS   |              |            
   +-------------------+  |  +----------+              |  ---> Report        
                          |                            |         
                          +----------------------------+

TODO

  • 存储的规划(只存MySQL bin log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment