MySQL Slow log切换
slow_query_log_file日志文件69GB,使用percona for pt-query-digest 分析卡住问题分析无响应。
[root@omsmgrpro02 logs]# du -sh *
1.2G error.log
69G slow.log
可用使用 set global slow_query_log_file修改慢日志文件名方式进行切换,操作步骤如下:
mysql> show variables like '%query%log%';
+------------------------------+---------------------------+
| Variable_name | Value |
+------------------------------+---------------------------+
| binlog_rows_query_log_events | OFF |
| slow_query_log | ON |
| slow_query_log_file | /data/mysql/logs/slow.log |
+------------------------------+---------------------------+
3 rows in set (0.00 sec)
mysql> set global slow_query_log_file='/data/mysql/logs/omsmgrpro02 _slow_2023-09-28.log' ;
Query OK, 0 rows affected (0.02 sec)
mysql> show variables like '%query%log%';
+------------------------------+---------------------------+
| Variable_name | Value |
+------------------------------+---------------------------+
| binlog_rows_query_log_events | OFF |
| slow_query_log | ON |
| slow_query_log_file | /data/mysql/logs/omsmgrpro02 _slow_2023-09-28.log |
+------------------------------+---------------------------+
3 rows in set (0.00 sec)
设置成功。