MySQL慢查询日志包含空语句

时间:2014-11-18 19:21:48

标签: mysql percona mysql-slow-query-log

Percona服务器(mysql Ver 14.14 Distrib 5.5.40-36.1,对于debian-linux-gnu(x86_64))除了标准预期查询之外,开始将以下语句记录到慢查询日志中。每秒都会记录语句,并且来自percona agent。我怎样才能摆脱这些条目?

# Time: 141118 21:12:03
# User@Host: percona-agent[percona-agent] @ localhost []
# Thread_id: 13316  Schema:   Last_errno: 0  Killed: 0
# Query_time: 0.003071  Lock_time: 0.000116  Rows_sent: 376  Rows_examined: 376  Rows_affected: 0  Rows_read: 376
# Bytes_sent: 10902
SET timestamp=1416337923;
SHOW /*!50002 GLOBAL */ STATUS;
# Time: 141118 21:12:04
# User@Host: percona-agent[percona-agent] @ localhost []
# Thread_id: 13316  Schema:   Last_errno: 0  Killed: 0
# Query_time: 0.001624  Lock_time: 0.000083  Rows_sent: 376  Rows_examined: 376  Rows_affected: 0  Rows_read: 376
# Bytes_sent: 10899
SET timestamp=1416337924;
SHOW /*!50002 GLOBAL */ STATUS;

慢查询日志记录配置如下:

laacz@zuze[mysql]> show global variables like '%slow%';
+------------------------------------+------------------------------------+
| Variable_name                      | Value                              |
+------------------------------------+------------------------------------+
| log_slow_admin_statements          | OFF                                |
| log_slow_filter                    | tmp_table_on_disk,filesort_on_disk |
| log_slow_queries                   | ON                                 |
| log_slow_rate_limit                | 1                                  |
| log_slow_rate_type                 | session                            |
| log_slow_slave_statements          | OFF                                |
| log_slow_sp_statements             | ON                                 |
| log_slow_verbosity                 |                                    |
| max_slowlog_files                  | 0                                  |
| max_slowlog_size                   | 134217728                          |
| slow_launch_time                   | 2                                  |
| slow_query_log                     | ON                                 |
| slow_query_log_always_write_time   | 10.000000                          |
| slow_query_log_file                | /var/log/mysql/mysql-slow.log      |
| slow_query_log_timestamp_always    | OFF                                |
| slow_query_log_timestamp_precision | second                             |
| slow_query_log_use_global_control  |                                    |
+------------------------------------+------------------------------------+
17 rows in set (0.00 sec)

1 个答案:

答案 0 :(得分:0)

Percona Server慢速日志配置变量中没有可以防止记录这些语句的过滤器。

但您可以使用pt-query-digest

从现有日志中过滤掉它们
$ pt-query-digest --filter '$event->{user} !~ /percona-agent/' 
    --no-report --output slowlog mysql-slow.log