Monitoring MySQL Queries Using Bash Script bashスクリプトを使用してMySQLのクエリの監視
Monitoring MySQL queries is a favorite pastime of MySQL administrators especially for performance reasons.監視MySQLのクエリは、お気に入りの気晴らしのMySQL管理者が特にパフォーマンス上の理由からです。 Here is a simple bash script to monitor long running MySQL queries in realtime using the ubiquitous ’show processlist’.次に示すのは、簡単なbashスクリプトを実行してMySQLのクエリを監視する長いをリアルタイムに使用して、ユビキタス'のSHOW PROCESSLIST ' 。 The best part about this script is that you can use it to log your queries over time for later evaluation.このスクリプトの大部分については、使用することをログに記録することができます。一定の期間のクエリへの評価しています。
#!/bin/bash while [ 1 ] do mysql -N -u root -p password -e 'show processlist' |grep -v 'show processlist' sleep 2 done # ! / bin / bashをながら[ 1 ]はルートのMySQL - n - u - p パスワード - e 'をSHOW PROCESSLISTの' | grep - V 'によってのSHOW PROCESSLIST '睡眠2完了 Note: Replace password with your actual password.注: パスワードを交換して実際のパスワードを入力します。
Note: -N removes column headers.注記: - n列のヘッダーを削除します。
This script excludes the show processlist thread itself.このスクリプト自体を除外するSHOW PROCESSLISTのスレッドです。 You may also exclude the Sleeping threads with the following modification:眠っても除外することがありますスレッドは、次の変更:
mysql -N -u root -p password -e ’show processlist’ | egrep -v ‘Sleep|show processlist’ルートのMySQL - n - u - p パスワード - e 'をSHOW PROCESSLISTの' | egrepの- V 'によって睡眠|のSHOW PROCESSLIST '
Note: This is not the only or best solution in market.注:これは最善の解決策ではなく、市場のみ、またはです。 There is mtop script with more functionality but written in perl. mtopにはスクリプトをPerlの他の機能が書かれています。 I am alergic to perl and also couldn’t get it working in my only attempt.私はPerlやalergicを取得できませんでしたて働いても私だけの試みです。 So here is a simple solution in bash.これについては、単純な解決策がbashを意味します。 Personally I don’t like hacking perl scripts.個人的にPerlスクリプトハッキングのは好きじゃない。
Note: You can use slow query log too but in my experience a running top like display is better at finding bottlenecks.注:あまりにもスロークエリのログを使用することができます。しかし、私の経験では、実行中のトップへのボトルネックを見つけるようなディスプレイが良いです。 Slow query log doesn’t indicate why a query took long time.スロークエリログのクエリ理由を理解することはありませんが長い時間を示しています。 It could be because it was waiting on another query to complete.それがためには、別のクエリを完了するまで待機しています。
Filed under提出されて Databaseデータベース , 、 Enterprise Softwareエンタープライズソフトウェア , 、 Headline Newsニュースの見出し , 、 How Toどのように , 、 Linuxリナックス , 、 MySQL MySQLの , 、 Open Source Softwareオープンソースのソフトウェア , 、 Programmingプログラミング , 、 RDBMS RDBMSのより多くの , 、 Tech Note技術のノート , 、 Webウェブ , 、 Web Hostingウェブホスティング , 、 Web Services Webサービス | |
| |
RSS 2.0 RSS 2.0を | |
Trackbackトラックバック this Article |この記事|
Email this Article電子メールこの記事
You may also like to readを読むようにすることも可能 |




