Monitoring MySQL Queries Using Bash Script Monitoraggio mysql query utilizzando script bash
Monitoring MySQL queries is a favorite pastime of MySQL administrators especially for performance reasons. Monitoraggio query MySQL è un passatempo preferito di MySQL amministratori soprattutto per motivi di prestazioni. Here is a simple bash script to monitor long running MySQL queries in realtime using the ubiquitous ’show processlist’. Qui è un semplice script bash per monitorare a lungo MySQL in esecuzione query in tempo reale utilizzando l'onnipresente 'mostrare PROCESSLIST'. The best part about this script is that you can use it to log your queries over time for later evaluation. La parte migliore di questo script è che si può utilizzare per accedere alle vostre domande nel corso del tempo per la successiva valutazione.
#!/bin/bash while [ 1 ] do mysql -N -u root -p password -e 'show processlist' |grep -v 'show processlist' sleep 2 done #! / bin / bash mentre [1] fare mysql-N-u root-p password-e 'mostrare PROCESSLIST' | grep-v 'mostra PROCESSLIST' fatto dormire 2 Note: Replace password with your actual password. Nota: Sostituire la password con la vostra password reale.
Note: -N removes column headers. Nota:-N elimina colonne.
This script excludes the show processlist thread itself. Questo script esclude la mostra PROCESSLIST thread stesso. You may also exclude the Sleeping threads with the following modification: Si può anche escludere la Dormire fili con le seguenti modifiche:
mysql -N -u root -p password -e ’show processlist’ | egrep -v ‘Sleep|show processlist’ mysql-N-u root-p password-e 'mostrare PROCESSLIST' | egrep-v 'Veglia | mostra PROCESSLIST'
Note: This is not the only or best solution in market. Nota: Questa non è l'unica soluzione migliore o nel mercato. There is mtop script with more functionality but written in perl. Non vi è mtop script con più funzionalità, ma scritto in Perl. I am alergic to perl and also couldn’t get it working in my only attempt. Io sono a alergic perl e potrebbe anche non farlo nel mio lavoro solo tentativo. So here is a simple solution in bash. Così qui è una soluzione semplice in bash. Personally I don’t like hacking perl scripts. Personalmente non mi piace l'hacking script in perl.
Note: You can use slow query log too but in my experience a running top like display is better at finding bottlenecks. Nota: È possibile utilizzare query lente di log troppo, ma la mia esperienza in un ambiente di alto come display è meglio a trovare le strozzature. Slow query log doesn’t indicate why a query took long time. Query lente di log non indica il motivo per cui una query ha preso molto tempo. It could be because it was waiting on another query to complete. Potrebbe essere perché era in attesa su un altro termine di ricerca a completare.
Filed under Elencato sotto Database Banca dati , Enterprise Software Enterprise Software , Headline News Headline News , How To Come , Linux , MySQL , Open Source Software Software open source , Programming Programmazione , RDBMS , Tech Note Nota tech , Web , Web Hosting Web Hosting , Web Services Servizi Web | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |




