Home Page

Tips page
c
cellulari
debian
egittologia
emacs
emacs-latex
hardware
html
inglese
java
latex
linux
matlab
misc
mysql

*Check delle tabelle e recover da un crash
*Check dello stato del mysql server
*Comandi utili da sapere utilizzando MySQL
*Connettersi a MySQL da remoto
*Import ed export/backup di un database
*Limit the number of rows returned
*Oracle rownum in MySQL
*Recupero della password di root di mysql

network
octave
programming
python
security
sed
tech
webapps
windows

University Page

Programming

Debian & Linux

Some works

About me

Del.icio.us Bookmarks

BOINC Combined Statistics

Site Statistics

Contact me sending an e-mail (antispam defense activated)

debian

hacker emblem

blogger

GeoURL

View Sandro Tosi's profile on LinkedIn

This is my Google PageRank

Title: Check dello stato del mysql server
Author: Sandro Tosi
Last modified: 2007-08-26

Tenere sotto  controllo lo stato  del database server  e` un'attivita`
importante di  ogni DBA  (database administrator). Ecco  dunque alcuni
comandi utili per svolgere questo compito con mysql.


Lista dei processi attivi
-------------------------

mysql> show processlist;
+-----+-------+-----------+------+---------+------+-------+------------------+
| Id  | User  | Host      | db   | Command | Time | State | Info             |
+-----+-------+-----------+------+---------+------+-------+------------------+
| 199 | morph | localhost | test | Query   | 0    | NULL  | show processlist |
+-----+-------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

Mostra  la lista  dei processi  attivi, per  esempio  sessioni utenti,
thread di replicazione (in caso di architettura master-slave), etc.

Nel caso sia necessario e` possibile anche killare una sessione:

mysql> kill <id>;


Informazioni di stato del db server
-----------------------------------

mysql> show status;
+--------------------------+----------+
| Variable_name            | Value    |
+--------------------------+----------+
| Aborted_clients          | 0        |
...
| Uptime                   | 852328   |
+--------------------------+----------+
133 rows in set (0.00 sec)

Mostra una lista di variabili  di status del database server; molti di
esse devono essere monitorate per stabilire la salute del server.

E` possibile filtrare queste variabili per nome:

mysql> show status like 'Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_queries_in_cache | 6        |
| Qcache_inserts          | 6        |
| Qcache_hits             | 1        |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 3727     |
| Qcache_free_memory      | 16757360 |
| Qcache_free_blocks      | 1        |
| Qcache_total_blocks     | 19       |
+-------------------------+----------+
8 rows in set (0.00 sec)


Informazioni di configurazione del db server
--------------------------------------------

mysql> show variables;
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| back_log                | 50       |
...
| wait_timeout            | 28800    |
+-------------------------+----------+
143 rows in set (0.00 sec)

Mostra una lista delle variabili dell'istanza mysql.

Anche  in questo  caso, e`  possibile  filtrare solo  le variabili  di
interesse:

mysql> show variables like 'version%';
+--------------------+---------------------+
| Variable_name      | Value               |
+--------------------+---------------------+
| version            | 4.0.24_Debian-9-log |
| version_comment    | Source distribution |
| version_compile_os | pc-linux-gnu        |
+--------------------+---------------------+
3 rows in set (0.00 sec)


E` anche possibile impostare il valore di una variabile a run-time:

mysql> set <variable_name>=<value>