【问题标题】:Empty Slow Query Log清空慢查询日志
【发布时间】:2016-07-21 05:34:39
【问题描述】:

下午好,

我们正在尝试访问位于“/var/log/mysql/localhost-slow.log”的慢查询日志文件,但看起来该文件为空。 “my.cnf”文件显示“!includedir /etc/my.cnf.d”,在该目录中我们有以下文件:

mysql-clients.cnf;
server.cnf;
tokudb.cnf;

查看“server.cnf”文件,它似乎已正确设置为写入慢查询日志:

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]
slow-query-log = 1
slow-query-log-file = /var/log/mysql/localhost-slow.log
long_query_time = 1
log-queries-not-using-indexes
# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

[mariadb-5.5]

我们已尝试设置 GLOBAL general_log = 'ON';但这没有帮助。知道可能是什么问题吗?

【问题讨论】:

    标签: mysql mariadb


    【解决方案1】:

    验证它是否真的在读取该文件:

    mysqld --verbose --help | head -33
    

    你可能会看到

    Default options are read from the following files in the given order:
    

    后跟文件路径列表。

    【讨论】:

    • Rick,谢谢这是输入:Default options are read from the following files in the given order: /etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf - 这是否意味着没有读取 server.cnf?
    • 我们也运行了show variables like '%log%';,看起来一切都很好:`slow_query_log | ON slow_query_log_file | /var/log/mysql/localhost-slow.log long_query_time | 1.000000 min_examined_row_limit | 100 `We' 也运行 select sleep(2); 然后 show status like 'Slow_queries'; 但结果是:Slow_queries | 0
    • min_examined_row_limit = 100 过滤掉了你的睡眠。
    • 我以前只听说过min_examined_row_limit 不为零。似乎没有必要,并且可能会消除应该调查的查询。
    • 我也是这么想的,并将其设置为默认值 (0)...仍然没有记录,但是在运行 select sleep(1); 然后运行 ​​show status like 'Slow_queries; 时,我现在可以看到睡眠后的慢查询跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-21
    • 1970-01-01
    相关资源
    最近更新 更多