开启SpotlightonMySQL-SlowQueryLog的方法
事情是从群友提问开始的:

看到这个问题 首先想到有可能工具没有连接好 但是他很快给排除了
然后我问他慢查询开关有没有开启

如果没开启的话 执行: set global slow_query_log=on; 这个他也很快搞定了
我又问他慢查询时间设置的多少 (我怀疑他设置的太长 因此并没有记入日志)他说 1 秒
我追问能否确定存在符合条件的慢查询 他说看了日志 确实存在

这时候开始感到了问题的蹊跷 赶快启动 Spotlight 连接好虚拟机里面的 MySQL
发现 Slow Query Log 确实没有获得数据 眼看装叉就要失败 但是绝对不能轻易认输
经过疯狂百度 改动了以下两处:
1. 开启 General Log

2. 在 my.cnf 配置文件里面的[mysqld]下面增加设置:

然后将 MySQL 重启 重新连接 Spotlight 查看 Slow Query Log:

至此 宣告装叉成功
文章来源:http://blog.163.com/lucia_gagaga/blog/static/264768019201681931238833/
后记:1.个人觉得general_log没有必要开启,影响MySQL性能。
2.对于线上来说,修改静态参数重启数据库需要申请停业务之类较麻烦,所以在前期规划时都要想到。
当前文章:开启SpotlightonMySQL-SlowQueryLog的方法
网页路径:http://azwzsj.com/article/jsccji.html

看到这个问题 首先想到有可能工具没有连接好 但是他很快给排除了
然后我问他慢查询开关有没有开启

如果没开启的话 执行: set global slow_query_log=on; 这个他也很快搞定了
我又问他慢查询时间设置的多少 (我怀疑他设置的太长 因此并没有记入日志)他说 1 秒
我追问能否确定存在符合条件的慢查询 他说看了日志 确实存在

这时候开始感到了问题的蹊跷 赶快启动 Spotlight 连接好虚拟机里面的 MySQL
发现 Slow Query Log 确实没有获得数据 眼看装叉就要失败 但是绝对不能轻易认输
经过疯狂百度 改动了以下两处:
1. 开启 General Log

2. 在 my.cnf 配置文件里面的[mysqld]下面增加设置:

然后将 MySQL 重启 重新连接 Spotlight 查看 Slow Query Log:

至此 宣告装叉成功
文章来源:http://blog.163.com/lucia_gagaga/blog/static/264768019201681931238833/
后记:1.个人觉得general_log没有必要开启,影响MySQL性能。
2.对于线上来说,修改静态参数重启数据库需要申请停业务之类较麻烦,所以在前期规划时都要想到。
当前文章:开启SpotlightonMySQL-SlowQueryLog的方法
网页路径:http://azwzsj.com/article/jsccji.html