Gerando log das “queries” lentas do MySQL | DeServ – Info
Lomadee, uma nova esp閏ie na web. A maior plataforma de afiliados da Am閞ica Latina.

Gerando log das “queries” lentas do MySQL

By Fl谩vio Silva

Primeiramente verifique se a vari谩vel que gera o log est谩 habilitada.

root@debian:~# mysql -u root -p
Enter password: *********

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6967
Server version: 5.0.67-0.dotdeb.1 (Dotdeb)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>show variables like '%log%' ;
+---------------------------------+----------------+
| Variable_name                   | Value          |
+---------------------------------+----------------+
| back_log                        | 50             |
| binlog_cache_size               | 32768          |
| expire_logs_days                | 10             |
| innodb_flush_log_at_trx_commit  | 1              |
| innodb_locks_unsafe_for_binlog  | OFF            |
| innodb_log_arch_dir             |                |
| innodb_log_archive              | OFF            |
| innodb_log_buffer_size          | 1048576        |
| innodb_log_file_size            | 5242880        |
| innodb_log_files_in_group       | 2              |
| innodb_log_group_home_dir       | ./             |
| innodb_mirrored_log_groups      | 1              |
| log                             | OFF            |
| log_bin                         | OFF            |
| log_bin_trust_function_creators | OFF            |
| log_error                       |                |
| log_queries_not_using_indexes   | OFF            |
| log_slave_updates               | OFF            |
| log_slow_queries                | OFF            |
| log_warnings                    | 1              |
| max_binlog_cache_size           | 4294963200     |
| max_binlog_size                 | 104857600      |
| max_relay_log_size              | 0              |
| relay_log                       |                |
| relay_log_index                 |                |
| relay_log_info_file             | relay-log.info |
| relay_log_purge                 | ON             |
| relay_log_space_limit           | 0              |
| sync_binlog                     | 0              |
+---------------------------------+----------------+
29 rows in set (0.00 sec)

mysql> \q
Bye

Note que o valor log_slow_queries est谩 em OFF.

Dessa forma, para habilitar, evite o arquivo /etc/mysql/my.cnf e altere/adicione as seguintes linhas:

root@debian:~# vi /etc/mysql/my.cnf

log_slow_queries = /var/log/mysql/mysql-slow.log   # Arquivo de Log
long_query_time  = 5                               # Tempo em segundos
#log-queries-not-using-indexes

Obs.: Lembrando que as queries que ser茫o mostradas, s茫o apenas as que tiverem tempo de pesquisa superior a long_query_time.


Tags: , , , ,

Deixe uma Resposta