innotop是一个非常好用的开源MySQL命令行监控工具,使用Perl开发,拥有很多的监控模式和选项,能够监控MySQL(InnoDB)多个方面的性能指标,连续不断地刷新数据,查看实时统计信息,帮忙管理员快速找出MySQL的问题。
innotop能够监控的指标:
- QPS/TPS
- innodb buffer使用情况
- 执行的命令统计信息
- 查询列表,类似于show processlist
- 锁等待信息
- 死锁信息
- 外键错误信息
- innodb I/O信息
- 事务信息
- 主从复制信息
源码地址:
当前版本:
innotop Ver 1.12.0
源码安装:
yum install -y perl-DBD-MySQL cd innotop/ perl Makefile.PL make make install
使用方法:
innotop 的参数与mysql客户端的参数相似,使用起来也很方便,执行innotop –help 可以查看它的帮助信息,如下:
[root@localhost innotop]# innotop --help Usage: innotop <options> <innodb-status-file> --askpass Prompt for a password when connecting to MySQL --[no]color -C Use terminal coloring (default) --config -c Config file to read --count Number of updates before exiting --delay -d Delay between updates in seconds --help Show this help message --host -h Connect to host --[no]inc -i Measure incremental differences --mode -m Operating mode to start in --nonint -n Non-interactive, output tab-separated fields --password -p Password to use for connection --port -P Port number to use for connection --skipcentral -s Skip reading the central configuration file --socket -S MySQL socket to use for connection --spark Length of status sparkline (default 10) --timestamp -t Print timestamp in -n mode (1: per iter; 2: per line) --user -u User for login if not current user --version Output version information and exit --write -w Write running configuration into home directory if no config files were loaded innotop is a MySQL and InnoDB transaction/status monitor, like 'top' for MySQL. It displays queries, InnoDB transactions, lock waits, deadlocks, foreign key errors, open tables, replication status, buffer information, row operations, logs, I/O operations, load graph, and more. You can monitor many servers at once with innotop.
使用示例:
innotop -h 127.0.0.1 -u admin -p’123456′
进入终端命令行模式后,按?键,显示快捷命令选项,通过这些快捷键能够切换到不同的模式,显示不同的监控指标,比如InnoDB锁等待,InnoDB死锁,执行的命令汇总,打开的表,复制状态等等。
[RO] Dashboard (? for help) Switch to a different mode: A Dashboard I InnoDB I/O Info Q Query List B InnoDB Buffers K InnoDB Lock Waits R InnoDB Row Ops C Command Summary L Locks S Variables & Status D InnoDB Deadlocks M Replication Status T InnoDB Txns F InnoDB FK Err O Open Tables U User Statistics Actions: d Change refresh interval q Quit innotop k Kill a query's connection r Reverse sort order n Switch to the next connection s Choose sort column p Pause innotop x Kill a query Other: TAB Switch to the next server group / Quickly filter what you see ! Show license and warranty = Toggle aggregation # Select/create server groups @ Select/create server connections $ Edit configuration settings Clear quick-filters Press any key to continue
常用的快捷键示例:C(Command Summary)
B(InnoDB Buffers)
Q(Query List)
总结:
整体来看,innotop 安装使用都比较简单、方便,功能也很强大,按按快捷键就能切换到不同的监控模式,显示不同的监控信息,对于数据库管理员来说,的确是一个不错的工作助手。