在使用Innodb做为存储引擎的数据库系统中,可以使用innodb_monitor 来监控数据库的性能,启动innodb_monitor的方法为 Create table innodb_monitor (i int) engine=innodb 通过建立这个表就启动了innodb_monitor,监控的结果并不会记录到这个表中,而是记录到了mysql的err日志中,如果我们想监控更我的关于innodb的锁信息还可更进一步的建立表create table innodb_lock_monitor (i int) engine=innodb 这样在日志中会加入更多的锁信息,如果要关闭监控只要简单的删除这两个表就可以了.Drop table innodb_monitor; drop table innodb_lock_monitor;
innodb_monitor:create table innodb_monitor(x int) engine=innodb;
innodb_lock_monitor:create table innodb_lock_monitor(x int) engine=innodb;
innodb_table_monitor:create table innodb_table_monitor(x int) engine=innodb;
innodb_tablespace_monitor:create table innodb_tablespace_monitor(x int) engine=innodb;
innodb_monitor/innodb_lock_monitor:
===================================== 090805 22:24:48 INNODB MONITOR OUTPUT ===================================== Per second averages calculated from the last 19 seconds ---------- SEMAPHORES ---------- OS WAIT ARRAY INFO: reservation count 312921, signal count 308229 Mutex spin waits 0, rounds 18209349, OS waits 111906 RW-shared spins 287775, OS waits 142204; RW-excl spins 175036, OS waits 19318 ------------ TRANSACTIONS ------------ Trx id counter 0 121675664 Purge done for trx's n:o < 0 121675662 undo n:o < 0 0 History list length 10 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 0 121462143, not started, process no 8452, OS thread id 1160767840 mysql tables in use 1, locked 1 MySQL thread id 8056144, query id 78206864 localhost root ---TRANSACTION 0 137229, not started, process no 8452, OS thread id 1158199648 MySQL thread id 50, query id 377 Has read all relay log; waiting for the slave I/O thread to update it -------- FILE I/O -------- I/O thread 0 state: waiting for i/o request (insert buffer thread) I/O thread 1 state: waiting for i/o request (log thread) I/O thread 2 state: waiting for i/o request (read thread) I/O thread 3 state: waiting for i/o request (write thread) Pending normal aio reads: 0, aio writes: 0, ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 Pending flushes (fsync) log: 0; buffer pool: 0 34 OS file reads, 80820900 OS file writes, 1263117 OS fsyncs 0.00 reads/s, 0 avg bytes/read, 1.16 writes/s, 0.63 fsyncs/s ------------------------------------- INSERT BUFFER AND ADAPTIVE HASH INDEX ------------------------------------- Ibuf: size 1, free list len 0, seg size 2, 0 inserts, 0 merged recs, 0 merges Hash table size 8850487, node heap has 233 buffer(s) 0.11 hash searches/s, 0.42 non-hash searches/s --- LOG --- Log sequence number 4 3697502095 Log flushed up to 4 3697502095 Last checkpoint at 4 3697502095 0 pending log writes, 0 pending chkp writes 79595438 log i/o's done, 0.47 log i/o's/second ---------------------- BUFFER POOL AND MEMORY ---------------------- Total memory allocated 4851752298; in additional pool allocated 13195520 Dictionary memory allocated 145784 Buffer pool size 262144 Free buffers 193334 Database pages 68577 Modified db pages 0 Pending reads 0 Pending writes: LRU 0, flush list 0, single page 0 Pages read 70, created 120513, written 2829967 0.00 reads/s, 0.21 creates/s, 0.84 writes/s Buffer pool hit rate 1000 / 1000 -------------- ROW OPERATIONS -------------- 0 queries inside InnoDB, 0 queries in queue 1 read views open inside InnoDB Main thread process no. 8452, id 1157658976, state: waiting for server activity Number of rows inserted 12233742, updated 57497659, deleted 1, read 69720050 0.05 inserts/s, 0.05 updates/s, 0.00 deletes/s, 0.05 reads/s ---------------------------- END OF INNODB MONITOR OUTPUT ============================
=========================================== 090805 22:26:56 INNODB TABLE MONITOR OUTPUT =========================================== -------------------------------------- TABLE: name SYS_FOREIGN, id 0 11, columns 7, indexes 3, appr.rows 0 COLUMNS: ID: DATA_VARCHAR prtype 1835012 len 0; FOR_NAME: DATA_VARCHAR prtype 1835012 len 0;REF_NAME: DATA_VARCHAR prtype 1835012 len 0; N_COLS: DATA_INT len 4;DB_ROW_ID: DATA_SYS prtype 256 len 6; DB_TRX_ID: DATA_SYS prtype 257 len 6; DB_ROLL_PTR:DATA_SYS prtype 258 len 7; INDEX: name ID_IND, id 0 11, fields 1/6, uniq 1, type 3 root page 46, appr.key vals 0, leaf pages 1, size pages 1 FIELDS: ID DB_TRX_ID DB_ROLL_PTR FOR_NAME REF_NAME N_COLS INDEX: name FOR_IND, id 0 12, fields 1/2, uniq 2, type 0 root page 47, appr.key vals 0, leaf pages 1, size pages 1 FIELDS: FOR_NAME ID INDEX: name REF_IND, id 0 13, fields 1/2, uniq 2, type 0 root page 48, appr.key vals 0, leaf pages 1, size pages 1 FIELDS: REF_NAME ID...省略若干输出--------------------------------------TABLE: name test/test, id 0 81, columns 4, indexes 1, appr.rows 3 COLUMNS: i: DATA_INT DATA_BINARY_TYPE len 4; DB_ROW_ID: DATA_SYS prtype 256 len 6;DB_TRX_ID: DATA_SYS prtype 257 len 6; DB_ROLL_PTR: DATA_SYS prtype 258 len 7; INDEX: name GEN_CLUST_INDEX, id 0 23, fields 0/4, uniq 1, type 1 root page 3, appr.key vals 3, leaf pages 1, size pages 1 FIELDS: DB_ROW_ID DB_TRX_ID DB_ROLL_PTR i-----------------------------------END OF INNODB TABLE MONITOR OUTPUT==================================
================================================ 090805 22:28:16 INNODB TABLESPACE MONITOR OUTPUT ================================================ FILE SPACE INFO: id 0 size 65536, free limit 6208, free extents 89 not full frag extents 6: used pages 69, full frag extents 0 first seg id not used 0 1067667 SEGMENT id 0 1067666 space 0; page 903; res 1 used 1; full ext 0 fragm pages 1; free extents 0; not full extents 0: pages 0 ...省略若干输出 SEGMENT id 0 144216 space 0; page 1307; res 1 used 1; full ext 0 fragm pages 1; free extents 0; not full extents 0: pages 0 NUMBER of file segments: 37 Validating tablespace Validation ok --------------------------------------- END OF INNODB TABLESPACE MONITOR OUTPUT =======================================