Mysql – How to enable slow query log in MySQL Galera

galeraloggingMySQLmysql-replication

I want to enable slow query logging in MySQL Galera.

In order to do so, I have enabled it through my.cnf:

log_slow_queries       = /var/log/mysql/mysql-slow.log
long_query_time = 1
log-queries-not-using-indexes

Then, I tried to restart one server

sudo services mysql restart

The galera node fails to restart and writes to error.log:

mysqld_safe WSREP: Failed to recover position: 2015-08-29 12:07:37
27805 [Warning] Using unique option prefix myisam-recover instead of
myisam-recover-options is deprecated and will be removed in a future
release. Please use the full name instead. 2015-08-29 12:07:37 27805
[Note] Plugin 'FEDERATED' is disabled. 2015-08-29 12:07:37 27805
[ERROR] Function 'innodb' already exists 2015-08-29 12:07:37 27805 …

Once I remove the query logging from my.cnf, the server starts just fine and joins the cluster OK.

Is there a special procedure in enabling the query log in Galera? If so, how to do it?

Best Answer

If you are using Galera with MySQL 5.6, log_slow_queries was removed.

Here is what the MySQL 5.6 Documentation says on that option

The --log-slow-queries option was removed in MySQL 5.6.1 (along with the log_slow_queries system variable). Instead, use the --slow_query_log option to enable the slow query log and the --slow_query_log_file=file_name option to set the slow query log file name.

Make you place the correct options under [mysqld] group header and not under [mysqld_safe]