zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

mysql的`show engine innodb status`分析脚本 分享

mysql 分析 分享 脚本 status InnoDB Engine show
2023-06-13 09:14:13 时间

需求:

每次使用 show engine innodb status 查看mysql状态的时候, 要找的数据每次都找很久, 而且很多参数都忘了是啥意思. 很是浪费时间. 所以整了这么个脚本.

项目下载:

项目地址: https://github.com/ddcw/innodb_status

二进制包下载: https://github.com/ddcw/innodb_status/releases/download/v0.1/innodb_status_v0.1_linux_x86_64.tar.gz

使用演示

本次演示使用二进制包.

[root@ddcw21 innodb_status]#./innodb_status -h 127.0.0.1 -P 3308 -p 123456
说明:
采集时间: 2022-10-28 19:35:12
下面涉及到的 每秒平均值 计算时间均为最近 38 秒内

master线程:
系统繁忙程度(越大越繁忙): 0.015
日志写入和刷新次数: 35811

SEMAPHORES信号量:
rw_s_spin_wait_count 0
rw_s_spin_round_count 12520
rw_s_os_wait_count 576
rw_x_spin_wait_count 0
rw_x_spin_round_count 17802
rw_x_os_wait_count 374
rw_sx_spin_wait_count 258
rw_sx_spin_round_count 1598
rw_sx_os_wait_count 13
每次空转等待的锁: rw_s:12520.00  rw_x:17802.00 rw_sx:6.19

事务(含锁)
TODO

文件IO
Pending normal 异步IO READ (对应read thread) :  [0, 0, 0, 0]
Pending normal 异步IO WRITE(对应WRIET thread):  [0, 0, 0, 0]
挂起(pending)的redo log flush: 0
挂起(pending)的tablespace flush: 0
OS总读次数: 10929  速度: 0.00 次/秒.  平均每次读 0 字节
OS总写次数: 404751  速度: 0.00 次/秒. 
OS总flush次数: 318585  速度: 0.00 次/秒. 

insert/change buffer和自适应hash索引
已合并页的数量: 1 页.   ibuf空闲列表长度: 275 页.  ibuf大小: 277 页.  合并插入次数: 1387
合并操作次数: insert buffer: 6339  delete buffer: 6390   purge buffer: 5769
无需合并操作的次数: insert buffer: 0  delete buffer: 0   purge buffer: 0
使用hash索引的查询 0.00次/秒  未使用hash使用的查询 0.00次/秒   自适应hash索引使用率0.0%

日志信息(redo)
最新产生的LSN: 13646056317
已刷盘的LSN: 13646056317
最老的LSN: 13646056317
最新检查点LSN: 13646056308
redo已完成的IO次数: 287837  速度:0.00次/秒

BUFFER POOL AND MEMORY(不含具体实例的,只含汇总的)
buffer pool 实例数(对应参数:innodb_buffer_pool_instances):  8
总内存: 1099431936 字节
系统(字典)使用: 183930 字节
buffer pool: 65528 页
free buffer: 53262 页
LRU        : 11747 页
old LRU    : 4490 页
脏页(flush list)            : 0 页
等待读入的页(pending read)  : 0 页
等待的写(pending write) : LRU: 0 页.   flush_list(等待刷新的脏页): 0 页.   单页: 0 页
LRU made young(LRU中移动到前部的页数,就是经常使用的页) 15 页(速度:0.00/s),   non-young 0 页(速度:0.00/s)
从磁盘读取的页: 10891(0.00/s)   在内存中创建的页(无数据): 856(0.00/s)     写入磁盘的页: 111161(0.00/s)
缓存命中率:数据库太闲,无此数据.
预读速度: 0.00/s   (因未被访问)驱除速度: 0.00/s   随机预读速度: 0.00/s

行操作ROW OPERATIONS
read view:  0
主进程ID: 3624 (sleeping)
插入行数: 335725(0.00/s)   更新行数: 665155(0.00/s)   删除行数: 332509(0.00/s)   读行数: 138694488(0.00/s)

也支持标准输入的.(管道符)

mysql -h127.0.0.1 -P3308 -p123456 -e 'show engine innodb status' | ./innodb_status
太长了,截不全

或者

mysql -h127.0.0.1 -P3308 -p123456 -e 'show engine innodb status' > /tmp/innodb_status.txt
cat /tmp/innodb_status.txt | ./innodb_status

或者

./innodb_status -f /tmp/innodb_status.txt