mysql安装后,默认pool的大小是128M,可以通过show variables like ‘innodb_buffer_pool%’;命令查看。
1 2 3 4 5 6 7 8 9
showvariableslike'innodb_buffer_pool%'; # innodb_buffer_pool_dump_at_shutdown OFF # innodb_buffer_pool_dump_now OFF # innodb_buffer_pool_filename ib_buffer_pool # innodb_buffer_pool_instances 8 # innodb_buffer_pool_load_abort OFF # innodb_buffer_pool_load_at_startup OFF # innodb_buffer_pool_load_now OFF # innodb_buffer_pool_size 134217728
可以通过show global status like ‘%innodb_buffer_pool_pages%’; 查看已经被占用的和空闲的。共计8000多个page。
重要的查询命令可以看到这些信息,show engine innodb status; Database pages表示LRU列表中页的数量,pages made young显示了LRU列表中页移动到前端的次数,Buffer pool hit rate表示缓冲池的命中率,100%表示良好,该值小于95%时,需要考虑是否因为全表扫描引起了LRU列表被污染。里面还有其他的参数,可以自行查阅一下代表什么意思。
------------------------ LATEST DETECTED DEADLOCK ------------------------ 190425 18:00:13 *** (1) TRANSACTION: TRANSACTION 231E7C5DF, ACTIVE 0 sec starting index read mysql tables in use 1, locked 1 LOCK WAIT 4 lock struct(s), heap size 1248, 3 row lock(s) MySQL thread id 1346996, OS thread handle 0x7fd968454700, query id 760545285 10.10.x.x app_user updating DELETE FROM db_0.table_0 WHERE ORDER_ID IN ( 456787464 , 456787465 ) *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 5 page no 6064 n bits 824 index `orderId_index` of table `db_0`.`table_0` trx id 231E7C5DF lock_mode X waiting
1 2 3 4 5 6 7 8 9 10 11 12 13
Record lock, heap no 180 PHYSICAL RECORD: n_fields 2; compact format; info bits 32 0: len 8; hex 80000015eb6a1041; asc j A;; 1: len 8; hex 800000002018fce2; asc ; *** (2) TRANSACTION: TRANSACTION 231E7C5DD, ACTIVE 0 sec starting index read, thread declared inside InnoDB 1 mysql tables in use 1, locked 1 5 lock struct(s), heap size 1248, 4 row lock(s) MySQL thread id 1348165, OS thread handle 0x7fd96669f700, query id 760545283 10.10.x.x app_user updating DELETE FROM db_0.table_0 WHERE ORDER_ID IN ( 456787464 , 456787465 ) *** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 5 page no 6064 n bits 824 index `orderId_index` of table `db_0`.`table_0` trx id 231E7C5DD lock_mode X locks rec but not gap
1 2 3 4 5
Record lock, heap no 180 PHYSICAL RECORD: n_fields 2; compact format; info bits 32 0: len 8; hex 80000015eb6a1041; asc j A;; 1: len 8; hex 800000002018fce2; asc ;; *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 5 page no 6064 n bits 824 index `orderId_index` of table `db_0`.`table_0` trx id 231E7C5DD lock_mode X waiting
1 2 3 4
Record lock, heap no 180 PHYSICAL RECORD: n_fields 2; compact format; info bits 32 0: len 8; hex 80000015eb6a1041; asc j A;; 1: len 8; hex 800000002018fce2; asc ;; *** WE ROLL BACK TRANSACTION (1)
------------ TRANSACTIONS ------------ Trx id counter 2409176 Purge done for trx's n:o < 2409171 undo n:o < 0 state: running but idle History list length 31 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 421224214038352, not started 0 lock struct(s), heap size 1136, 0 row lock(s) ---TRANSACTION 421224214044736, not started 0 lock struct(s), heap size 1136, 0 row lock(s) ---TRANSACTION 421224214039264, not started 0 lock struct(s), heap size 1136, 0 row lock(s) ---TRANSACTION 2409171, ACTIVE 1549 sec fetching rows, thread declared inside InnoDB 3871 mysql tables in use 1, locked 0 0 lock struct(s), heap size 1136, 0 row lock(s) MySQL thread id 653597, OS thread handle 140289889908480, query id 2528936 127.0.0.1 root Sending data SELECT /*!40001 SQL_NO_CACHE */ * FROM `table`
1 2 3 4
Trx id counter 当前事物ID Purge done for trx's 正在清理掉的transaction ID History list length 记录了undo spaces内未清掉的事务个数,Purge的原则是记录没有被其它事务继续使用。 LIST OF TRANSACTIONS FOR EACH SESSION 每个session的事物状态
Log sequence number 最新产生的日志序列号 Log flushed up to 已刷到磁盘的重做日志的日志号 Pages flushed up to 已刷到磁盘的页的日志号 Last checkpoint at 最后一次检查点位置,数据和日志一致的状态 pending 当前挂起的日志读写操作
---------------------- INDIVIDUAL BUFFER POOL INFO ---------------------- ---BUFFER POOL 0 Buffer pool size 147438 Free buffers 1024 Database pages 139530 Old database pages 51486 Modified db pages 0 Pending reads 0 Pending writes: LRU 0, flush list 0, single page 0 Pages made young 8790743, not young 77467460 0.00 youngs/s, 0.00 non-youngs/s Pages read 1856892, created 916430, written 30727167 0.00 reads/s, 0.00 creates/s, 0.00 writes/s No buffer pool page gets since the last printout Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s LRU len: 139530, unzip_LRU len: 0 I/O sum[6]:cur[0], unzip sum[0]:cur[0] ---BUFFER POOL 1 ---BUFFER POOL 2 ---BUFFER POOL 3
-------------- ROW OPERATIONS -------------- 0 queries inside InnoDB, 0 queries in queue 0 read views open inside InnoDB Process ID=444943, Main thread ID=139899621590784, state: sleeping Number of rows inserted 172887566, updated 227534242, deleted 56676133, read 709667077 8.77 inserts/s, 8.04 updates/s, 0.00 deletes/s, 10.92 reads/s
queries,表示innodb内核中有多少个线程,队列中有多少个线程。
read views open inside InnoDB,表示有多少个read view 被打开,一个read view 包含事物开始点数据库内容的MVCC快照。
Process ID=444943,表示内核的主线程状态。
Number of rows inserted、updated、deleted、read,表示多少行被插入,更新和删除,读取及每秒信息,可用于监控。
可通过以下命令查看:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
(root@localhost) [(none)] >show global status like 'Innodb_rows_%'; +----------------------+-----------+ | Variable_name | Value | +----------------------+-----------+ | Innodb_rows_deleted | 56676133 | | Innodb_rows_inserted | 172887566 | | Innodb_rows_read | 709667077 | | Innodb_rows_updated | 227534242 | +----------------------+-----------+
(root@localhost) [(none)] >show global status like 'Uptime'; +---------------+---------+ | Variable_name | Value | +---------------+---------+ | Uptime | 1757270 | +---------------+---------+ END OF INNODB MONITOR OUTPUT
InnoDB信息结束语。
1 2 3 4
---------------------------- END OF INNODB MONITOR OUTPUT ============================ 如果看不到这行输出,可能是有大量事务或者有一个大的死锁截断了输出信息。