[MySQL FAQ]系列 -- Linux命令行下快速监控mysql

其实很简单,就是利用linux下的 watch 工具来做监控,方法如下:

[yejr@localhost imysql]# watch -d -n 10 "egrep 'MySQL thread|Log|Modified db pages' innodb_status.3249 "     
Every 10.0s: egrep 'MySQL thread|Log|Modified db pages' innodb_status.3249                                               Thu Apr  9 10:01:12 2009

MySQL thread id 6, query id 71 localhost root Sending data
Log sequence number 2703 3443241402
Log flushed up to   2703 3442763607
Modified db pages       83325

或者:

[yejr@localhost imysql]#watch -d -n 10 "mysqladmin ext|egrep Innodb_data"    
Every 10.0s: mysqladmin ext|egrep Innodb_data                                                                             Thu Apr  9 10:03:55 2009
| Innodb_data_fsyncs                | 4144699     |
| Innodb_data_pending_fsyncs        | 0           |
| Innodb_data_pending_reads         | 0           |
| Innodb_data_pending_writes        | 0           |
| Innodb_data_read                  | 5567172608  |
| Innodb_data_reads                 | 298413      |
| Innodb_data_writes                | 4492881     |
| Innodb_data_written               | 18549422080 |

参数解释:

-d --differences
-n --interval

不用我多说了吧,怎么样,是不是觉得很有意思呢 :)

评论

第一个不太明白 望给解释下?第二个还蛮好用的,呵呵

1. 请问 innodb_status.3249 是怎么输出的? show innodb status默认输出在error文件,你怎么做到定时刷新到一个文件里的呢?.

查看手册的 innodb_status_file 选项