开启慢SQL监控

由于Druid输出的慢SQL只能设定一个判定标准,而实际情况是我们需要根据不同的条件从慢SQL日志中筛选,可以通过grep、sed等命令编写脚本实现。
统计慢SQL
1 2 3 4 5 6 7
| grep -E "slow sql [1-9][0-9]{5}" file_name
grep -E "slow sql [1-9][0-9]{5}" file_name |wc -l
zgrep -E "slow sql [1-9][0-9]{5}" file_name.zip |wc -l
|

慢SQL详情输出到单独文件
1 2 3 4 5
| grep -n -E "slow sql" hug-interview-slowlog.log
sed -n '762,770p' hug-interview-slowlog.log
|
