The slow_query_log_file log becomes very large and it is inconvenient to analyze its input items. We want to generate a slow_query_log_file file every day and analyze the log file every day. How to cut by day? We have come up with this method to switch the log format to the hostname-slow _ date. log format. The default format is host
The slow_query_log_file log becomes very large and it is inconvenient to analyze its input items. We want to generate a slow_query_log_file file every day and analyze the log file every day. How to cut by day? We have come up with this method to switch the log format to the hostname-slow _ date. log format. The default format is host
The slow_query_log_file log becomes very large and it is inconvenient to analyze its input items. We want to generate a slow_query_log_file file every day and analyze the log file every day. How to cut by day? We have come up with such a way to switch the log format to this form of hostname-slow _ date. log, the default format is hostname-slow.log. So how to implement it? It is actually very simple. Use the default mysql command.
Mysql> show variables like '% query % log % ';
+ --------------------- + ------------------------------------------ +
| Variable_name | Value |
+ --------------------- + ------------------------------------------ +
| Slow_query_log | OFF |
| Slow_query_log_file |/usr/local/mysql/data/aeolus1-slow.log |
+ --------------------- + ------------------------------------------ +
Mysql> set global slow_query_log_file = '/usr/local/mysql/data/aeolus1-slow_2013-07-19.log ';
Query OK, 0 rows affected (0.03 sec)
Mysql> show variables like '% query % log % ';
+ --------------------- + --------------------------------------------------- +
| Variable_name | Value |
+ --------------------- + --------------------------------------------------- +
| Slow_query_log | ON |
| Slow_query_log_file |/usr/local/mysql/data/aeolus1-slow_2013-07-19.log |
+ --------------------- + --------------------------------------------------- +
2 rows in set (0.01 sec)
OK. The setting is successful. The idea is like this.
Write a shell script to define the time so that logs can be generated by nature.