首页 > 代码库 > 正确安全清空在线慢查询日志slow log的流程
正确安全清空在线慢查询日志slow log的流程
查看慢查询日志的状态:
mysql> show variables like ‘%slow%‘; +---------------------+-----------------------------+ | Variable_name | Value | +---------------------+-----------------------------+ | log_slow_queries | ON | | slow_launch_time | 2 | | slow_query_log | ON | | slow_query_log_file | /data1/mysql/mysql-slow.log | +---------------------+-----------------------------+ 4 rows in set (0.00 sec) mysql> show variables like ‘%long_query_time%‘; +-----------------+-----------+ | Variable_name | Value | +-----------------+-----------+ | long_query_time | 10.000000 | +-----------------+-----------+ 1 row in set (0.00 sec)
先停慢查询功能:
mysql> set global slow_query_log=0; Query OK, 0 rows affected (0.05 sec) mysql> show variables like ‘%slow%‘; +---------------------+-----------------------------+ | Variable_name | Value | +---------------------+-----------------------------+ | log_slow_queries | OFF | | slow_launch_time | 2 | | slow_query_log | OFF | | slow_query_log_file | /data1/mysql/mysql-slow.log | +---------------------+-----------------------------+ 4 rows in set (0.00 sec)
重新设置慢查询日志的路径:
mysql> set global slow_query_log_file=‘/data1/mysql/mysql-slow01.log‘; Query OK, 0 rows affected (0.00 sec)
开启慢查询工能:
mysql> set global slow_query_log=1; Query OK, 0 rows affected (0.53 sec) mysql> show variables like ‘%slow%‘; +---------------------+-------------------------------------------+ | Variable_name | Value | +---------------------+-------------------------------------------+ | log_slow_queries | ON | | slow_launch_time | 2 | | slow_query_log | ON | | slow_query_log_file | /data1/mysql/mysql-slow01.log | +---------------------+-------------------------------------------+ 4 rows in set (0.00 sec)
查看生成的慢查询日志:
# ls cp_aurora ib_logfile1 mysql-bin.000057 mysql.pid test emove mysql mysql-bin.000058 mysql-slow01.log zabbix ibdata1 mysql-bin.000055 mysql-bin.index mysql-slow.log ib_logfile0 mysql-bin.000056 mysql-error.log performance_schema
正确安全清空在线慢查询日志slow log的流程
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。