Innotop って何ぬねの
LinuxにTopというコマンドがある。Windowsでいうところのタスクマネージャのように、リアルタイムで状況確認するための基本コマンドだ。そしてMytopというMySQL版Topコマンドのようなものがあり、そんなMytopをインスパイアしてできたと作者が仰っている。
それがInnotopなのな。
とりあえずMytopを
どんなんかな~?実行してみよう。
MySQL on localhost (5.1.73-log) up 4+19:39:33 [05:07:50]
Queries: 2.4M qps: 6 Slow: 30.2k Se/In/Up/De(%): 44/07/27/01
qps now: 16 Slow qps: 2.0 Threads: 17 ( 1/ 0) 69/00/06/00
Key Efficiency: 99.8% Bps in/out: 902.1/ 3.3k Now in/out: 1.6k/25.0k
Id User Host/IP DB Time Cmd Query or State
-- ---- ------- -- ---- --- ----------
120839 wp localhost wp 0 Query show full processlist
120872 wp localhost wp 0 Sleep
サンプルがちょっと悲しいかな、全く何も溜まってないので全く参考にならなくてすまない。
以下は忘備録的なMyTopのインストールメモです、MyTOPはもともと使っていたので今回改めてローカルに入れてみたのね。
$ cd /tmp
$ wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
$ tar zxvf mytop-1.6.tar.gz
$ cd mytop-1.6
$ perl Makefile.PL
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
$ sudo yum install perl-ExtUtils-MakeMaker.x86_64
$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Term::ReadKey 2.1 not found.
Writing Makefile for mytop
$ sudo yum install -y perl-TermReadKey.x86_64
$ make
cp mytop blib/script/mytop
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/mytop
Manifying blib/man1/mytop.1
$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..1
ok 1
$ sudo make install
Installing /usr/local/share/man/man1/mytop.1
Installing /usr/local/bin/mytop
Appending installation info to /usr/lib64/perl5/perllocal.pod
※つかいかた
mytop -uユーザー名 -pパスワード -dデータベース名 -s表示更新秒数
超超超超 超適当だが、RH6系ならこれでOKでしょう。愛の革命である。
では Innotop を
$ wget https://innotop.googlecode.com/files/innotop-1.9.1-1.el6.noarch.rpm
$ rpm -ivh innotop-1.9.1-1.el6.noarch.rpm
エラー: 依存性の欠如:
perl(Term::ReadKey) は innotop-1.9.1-1.el6.noarch に必要とされています
perl(Time::HiRes) は innotop-1.9.1-1.el6.noarch に必要とされています
perl-TermReadKey は innotop-1.9.1-1.el6.noarch に必要とされています
perl-Time-HiRes は innotop-1.9.1-1.el6.noarch に必要とされています
$ sudo yum install perl-Time-HiRes.x86_64 ReadKey
$ sudo rpm -ivh innotop-1.9.1-1.el6.noarch.rpm
準備中... ########################################### [100%]
1:innotop ########################################### [100%]
innotop -u <username> -p <password> -h <hostname>
びっくりした?さらに短いのであった。
流石にこれでは終わらないよと。
まだ使い方も知らないのに使い方をとは何たることかと思いますが、ほかに言いようもないので。
以下、ざっくりと使いかた
$ innotop -u root
まずダッシュボードというのが表示され@キーでセッティングができる。-write オプションをつけて起動することでコンフィグファイルが作成される。
You can enter the name of a new connection to create it.
_____________________ Choose from _____________________
localhost DBI:mysql:;;mysql_read_default_group=client
Choose connections for this mode:
$ ls -la /home/takeken/.innotop
合計 16
drwxrwxr-x. 3 takeken takeken 4096 9月 25 03:21 2014 .
drwx-----x. 15 takeken takeken 4096 9月 25 03:21 2014 ..
-rw-------. 1 takeken takeken 2758 9月 25 03:21 2014 innotop.conf
drwxrwxr-x. 2 takeken takeken 4096 9月 25 03:19 2014 plugins
参考サイトのように複数のホストに接続してチェックすることも可能なようだ。
かなり素敵なもののようだ。
参考サイト
YaKst
Innotop – MySQLのためのリアルタイムで高機能な調査ツール
ぶっちゃけ参考サイトを見た方が参考になるということは早めにここで言っておくよ。
ではショートカットキーなどなど
起動時の画面、Aキー(矢印キーの上)でダッシュボード
Dashboard (? for help) localhost, 14d, 2.03k QPS, 47/2/0 con/run/cac thds, 5.1.73-log
Uptime MaxSQL ReplLag QPS Cxns Run Miss Lock Tbls Repl SQL
14d 2.03k 47 1 9.34 0 233 Off
Qキーでクエリーモード
When Load Cxns QPS Slow Se/In/Up/De% QCacheHit KCacheHit BpsIn BpsOut
Now 0.18 47 1.06k 0 99/ 0/ 0/ 0 0.00% 100.00% 98.44k 312.83k
Total 0.00 200 95.99 8.46k 39/ 2/ 2/15 3.85% 100.00% 22.65k 163.85k
Cmd ID State User Host DB Time Query
Query 1084 Copying to tmp tab zabbix localhost zabbix 00:03 select distinct t.triggerid,t.description,t.expression,t.error,t.priority,t.type,t.value,t.state,t.lastchange,t.status from hosts h,items i,functions f,triggers t
Query 21073924 statistics zabbix localhost zabbix 00:00 SELECT DISTINCT i.itemid,i.hostid,i.name,i.key_,i.value_type FROM items i,functions f WHERE f.itemid=i.itemid AND f.triggerid='25764'
RキーでローOPSモード
[RO] InnoDB Row Ops (? for help) localhost, 18m, InnoDB 37s :-), 2.43 QPS, 46/0/0 con/run/cac thds, 5.1.73-log
____________________ InnoDB Row Operations ____________________
Ins Upd Read Del Ins/Sec Upd/Sec Read/Sec Del/Sec
447978 6164 8613385 0 365.18 3.54 1466.47 0.00
___________________ Row Operation Misc ____________________
Queries Queued Queries Inside Rd Views Main Thread State
0 0 1 sleeping
_____________________________ InnoDB Semaphores _____________________________
Waits Spins Rounds RW Waits RW Spins Sh Waits Sh Spins Signals ResCnt
2704 88722 171928 1370 7992 1612 2423 7872 5929
____________________________ InnoDB Wait Array _____________________________
Thread Time File Line Type Readers Lck Var Waiters Waiting? Ending?
IキーでInnoDB IOスレッドモード
[RO] InnoDB I/O Info (? for help) localhost, 11m, InnoDB 24s :-), 94.06 QPS, 45/0/0 con/run/cac thds, 5.1.73-log
____________________ I/O Threads ____________________
Thread Purpose Thread Status
0 insert buffer thread waiting for i/o request
1 log thread waiting for i/o request
2 read thread waiting for i/o request
3 read thread waiting for i/o request
4 read thread waiting for i/o request
5 read thread waiting for i/o request
6 write thread waiting for i/o request
7 write thread waiting for i/o request
8 write thread waiting for i/o request
9 write thread waiting for i/o request
____________________________ Pending I/O _____________________________
Async Rds Async Wrt IBuf Async Rds Sync I/Os Log Flushes Log I/Os
0 0 0 0 0 0
________________________ File I/O Misc _________________________
OS Reads OS Writes OS fsyncs Reads/Sec Writes/Sec Bytes/Sec
25807 20496 4738 12.62 15.54 20655
______________________ Log Statistics ______________________
Sequence No. Flushed To Last Checkpoint IO Done IO/Sec
488391487586 488391485562 488372267940 2329 3.54
Dキー(矢印キーの左)でデッドロックモード
InnoDB Deadlocks (? for help) localhost, 14d, InnoDB 0s :-), 59.33 QPS, 46/0/0 con/run/cac thds, 5.1.73-log
______________________ Deadlock Transactions ______________________
ID Timestring User Host Victim Time Undo LStrcts Query Text
____________________ Deadlock Locks ____________________
ID Waiting Mode DB Table Index Special Ins Intent
Mキーでレプリケーションモード。
参考サイトのようにレプリケーションを作っていたら一括で見れる。素敵。
ここでは作ってないから空だけどね。
[RO] Replication Status (? for help) localhost, 11m, 100.31 QPS, 45/1/0 con/run/cac thds, 5.1.73-log
____________________ Slave SQL Status ____________________
Master On? TimeLag Catchup Temp Relay Pos Last Error
___________ Slave I/O Status ____________
Master On? File Relay Size Pos State
______ Master Status _______
File Position Binlog Cache
Bキー(矢印キーの下)でバッファモード。
InnoDB Buffers (? for help) localhost, 14d, InnoDB 0s :-), 2.01k QPS, 47/0/0 con/run/cac thds, 5.1.73-log
____________________________ Buffer Pool _____________________________
Size Free Bufs Pages Dirty Pages Hit Rate Memory Add'l Pool
64.00k 0 57259 38287 1000 / 1000 1.02G 0
_______________________ Page Statistics ________________________
Reads Writes Created Reads/Sec Writes/Sec Creates/Sec
82398572 184370653 2902397 0.00 0.00 0.00
_______________________ Insert Buffers ________________________
Inserts Merged Recs Merges Size Free List Len Seg. Size
32045780 32045439 22191372 47 2890 2938
___________________ Adaptive Hash Index ___________________
Size Cells Used Node Heap Bufs Hash/Sec Non-Hash/Sec
2.11M 8277 4905000.00 6115000.00
Cキー(カーソル下キー)でこまんどさあまりーモード。
[RO] Command Summary (? for help) localhost, 6m, 60.61 QPS, 45/1/0 con/run/cac thds, 5.1.73-log
___________________ Command Summary ____________________
Name Value Pct Last Incr Pct
Com_select 12779 55.13% 247 53.12%
Com_show_status 3410 14.71% 117 25.16%
Com_update 2081 8.98% 32 6.88%
Com_begin 1502 6.48% 21 4.52%
Com_commit 1502 6.48% 21 4.52%
Com_insert 919 3.96% 24 5.16%
Com_admin_commands 622 2.68% 1 0.22%
Com_set_option 136 0.59% 1 0.22%
Com_show_tables 62 0.27% 1 0.22%
Com_change_db 50 0.22% 0 0.00%
Com_show_engine_status 39 0.17% 0 0.00%
このように色々と使い道がありそうで、ざっとショートカットキーで見た感じでもチューニングの時にも重宝するのではないかとみられる。
日々の運用管理にも使えるであろう。
では本番サーバーにインストールしようと思います!
今日はここまでっす。