P
P
PQR2017-07-03 12:43:45
MySQL
PQR, 2017-07-03 12:43:45

Slow_query_log_file (MariaDB) is not being written, I did research, I didn't get to the bottom, can you help?

I have ubuntu 14.04 and MariaDB 10.0.30.
In the /etc/mysql/my.cnf file I configured:

slow_query_log=1
slow_query_log_file     = /var/log/mysql/mariadb-slow.log
long_query_time = 10
#log_slow_rate_limit    = 1000
log_slow_verbosity      = query_plan

The server has been running for a long time, but there is no /var/log/mysql/mariadb-slow.log file in fact - maybe I don't have slow queries?
I found out the other day that MySQL has a slow query counter inside, which can be viewed by the command. SHOW GLOBAL STATUS;
I see: Slow_queries 8878
Where are all these 8878 queries? Why is there no log?
Just in case, I decided to check if the settings from my.cnf were applied to the server? I made a request
show variables like '%slow%';
and suddenly I see:
slow_query_log_file = master-slow.log
is not at all what I set up! Why?
But this master-slow.log file is not in the /var/log/mysql/ folder either, maybe you need to look in some other folder?
In this article https://mariadb.com/kb/en/mariadb/slow-query-log-o...I read about the log_output variable, which needs to be set to "file", checked it with a query SHOW VARIABLES LIKE '%log_output%';- everything is correct here log_output=FILE
Finally, in the same article, the log_queries_not_using_indexes setting is indicated and in my case it is OFF - apparently that's why there is nothing in the log, because all my slow queries are queries that do not use indexes? ( upd: this is not so, read on ) I set it to ON with the command set global log_queries_not_using_indexes = 'ON', waited, the counter of slow queries that I look through SHOW GLOBAL STATUS;increased, but the master-slow.log and /var/log/mysql/mariadb-slow.log files are still missing!
I'm confused, where to dig next? The main question now is: why in my.cnf I explicitly specified slow_query_log_file = /var/log/mysql/mariadb-slow.log, and the query show variables like '%slow_query_log_file%'; shows a completely different "master-slow.log" value?
UPD a few days later
Thanks for the comments and hints below, did some more research:
0) ran the command on a live server
set global slow_query_log_file = /var/log/mysql/mariadb-slow.log
And the file did appear! This removed the suspicion that there was a problem accessing the /var/log/mysql/ folder. But for now, the question remains why, when the server starts, the same value is not taken from my.cnf
1) at the bottom of my.cnf there is a line !includedir /etc/mysql/conf.d/, I looked that in the /etc/mysql/conf.d/ folder - there are three files mariadb.cnf mysqld_safe_syslog.cnf tokudb.cnf, but inside there are no overwriting settings associated with slow queries
2) my assumption about log_queries_not_using_indexes, which I wrote above turned out to be wrong, I clarify the situation so that others do not get confused after reading this epic:
- slow queries are logged regardless of the value of log_queries_not_using_indexes
- if you enable log_queries_not_using_indexes=On, then in addition to slow queries, all queries that do not use indexes will be written to the same log file (regardless of their execution time)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Swartalf, 2017-07-04
@Swartalf

1. When changing the config, you need to reload / restart mysql.
2. Through the search, find the file where the logs are now being written 3. Check the directory where the logs should be located for the presence of write permissions for the Mysql user. 4. my.cnf can be located not only in /etc/mysql, see if there is a config that overwrites your settings find / -name 'master-slow.log'

R
ratmanovsky, 2021-01-14
@ratmanovsky

For those who faced the same problem and found this thread in 2021.
You must specify the option WITHOUT "= 1" in the configuration file:
slow_query_log
https://mariadb.com/kb/en/slow-query-log-overview/
Config path for OS Debian 10, MariaDB 10.3.27
/etc/mysql/mariadb. conf.d/50-server.cnf
Block[mysqld]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question