mylib.py

#encoding=utf-8
import os
import include
from include import * TABLESPACE_NAME='D:\\mysql_data\\test\\t.ibd'
VARIABLE_FIELD_COUNT = 1
NULL_FIELD_COUNT = 0 class myargv(object):
def __init__(self, argv):
self.argv = argv
self.parms = {}
self.tablespace = '' def parse_cmdline(self):
argv = self.argv
if len(argv) == 1:
print 'Usage: python py_innodb_page_info.py [OPTIONS] tablespace_file'
print 'For more options, use python py_innodb_page_info.py -h'
return 0
while argv:
if argv[0][0] == '-':
if argv[0][1] == 'h':
self.parms[argv[0]] = ''
argv = argv[1:]
break
if argv[0][1] == 'v':
self.parms[argv[0]] = ''
argv = argv[1:]
else:
self.parms[argv[0]] = argv[1]
argv = argv[2:]
else:
self.tablespace = argv[0]
argv = argv[1:]
if self.parms.has_key('-h'):
print 'Get InnoDB Page Info'
print 'Usage: python py_innodb_page_info.py [OPTIONS] tablespace_file\n'
print 'The following options may be given as the first argument:'
print '-h help '
print '-o output put the result to file'
print '-t number thread to anayle the tablespace file'
print '-v verbose mode'
return 0
return 1 def mach_read_from_n(page,start_offset,length):
ret = page[start_offset:start_offset+length]
return ret.encode('hex') def get_innodb_page_type(myargv):
f=file(myargv.tablespace,'rb')
fsize = os.path.getsize(f.name)/INNODB_PAGE_SIZE
ret = {}
for i in range(fsize):
page = f.read(INNODB_PAGE_SIZE)
page_offset = mach_read_from_n(page,FIL_PAGE_OFFSET,4)
page_type = mach_read_from_n(page,FIL_PAGE_TYPE,2)
if myargv.parms.has_key('-v'):
if page_type == '45bf':
page_level = mach_read_from_n(page,FIL_PAGE_DATA+PAGE_LEVEL,2)
print "page offset %s, page type <%s>, page level <%s>"%(page_offset,innodb_page_type[page_type],page_level)
else:
print "page offset %s, page type <%s>"%(page_offset,innodb_page_type[page_type])
if not ret.has_key(page_type):
ret[page_type] = 1
else:
ret[page_type] = ret[page_type] + 1
print "Total number of page: %d:"%fsize
for type in ret:
print "%s: %s"%(innodb_page_type[type],ret[type])
###

py_innodb_page_info.py

#! /usr/bin/env python
#encoding=utf-8
import mylib
from sys import argv
from mylib import myargv if __name__ == '__main__':
myargv = myargv(argv)
if myargv.parse_cmdline() == 0:
pass
else:
mylib.get_innodb_page_type(myargv) ####

include.py

#encoding=utf-8
INNODB_PAGE_SIZE = 16*1024*1024 # Start of the data on the page
FIL_PAGE_DATA = 38
FIL_PAGE_OFFSET = 4 # page offset inside space
FIL_PAGE_TYPE = 24 # File page type # Types of an undo log segment */
TRX_UNDO_INSERT = 1
TRX_UNDO_UPDATE = 2 # On a page of any file segment, data may be put starting from this offset
FSEG_PAGE_DATA = FIL_PAGE_DATA # The offset of the undo log page header on pages of the undo log
TRX_UNDO_PAGE_HDR = FSEG_PAGE_DATA PAGE_LEVEL = 26 #level of the node in an index tree; the leaf level is the level 0 */ innodb_page_type={
'':u'Freshly Allocated Page',
'':u'Undo Log Page',
'':u'File Segment inode',
'':u'Insert Buffer Free List',
'':u'Insert Buffer Bitmap',
'':u'System Page',
'':u'Transaction system Page',
'':u'File Space Header',
'':u'扩展描述页',
'000a':u'Uncompressed BLOB Page',
'000b':u'1st compressed BLOB Page',
'000c':u'Subsequent compressed BLOB Page',
'45bf':u'B-tree Node'
} innodb_page_direction={
'': 'Unknown(0x0000)',
'': 'Page Left',
'': 'Page Right',
'': 'Page Same Rec',
'': 'Page Same Page',
'': 'Page No Direction',
'ffff': 'Unkown2(0xffff)'
}
INNODB_PAGE_SIZE=1024*16 # InnoDB Page 16K
####

python py_innodb_page_info.py /usr/local/var/mysql/ibdata1

python py_innodb_page_info.py -v /usr/local/var/mysql/ibdata1

➜  ~ python py_innodb_page_info.py -v /usr/local/var/mysql/ibdata1
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <System Page>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000005, page type <Transaction system Page>
page offset 00000006, page type <System Page>
page offset 00000007, page type <System Page>
page offset 00000008, page type <B-tree Node>, page level <0001>
page offset 00000009, page type <B-tree Node>, page level <0001>
page offset 0000000d, page type <Freshly Allocated Page>
page offset 0000000e, page type <Freshly Allocated Page>
page offset 0000000f, page type <Freshly Allocated Page>
page offset 00000010, page type <Freshly Allocated Page>
page offset 0000002d, page type <System Page>
page offset 0000002e, page type <System Page>
page offset 0000002f, page type <System Page>
page offset 00000030, page type <System Page>
page offset 000001c6, page type <Undo Log Page>
page offset 00000000, page type <File Space Header>
page offset 000001e0, page type <File Segment inode>
page offset 00000108, page type <System Page>
page offset 00000109, page type <System Page>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000005, page type <B-tree Node>, page level <0000>
page offset 000001c9, page type <Undo Log Page>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 000000f3, page type <File Segment inode>
page offset 0000011c, page type <Undo Log Page>
page offset 00000034, page type <System Page>
page offset 0000015c, page type <B-tree Node>, page level <0000>
page offset 000001a1, page type <B-tree Node>, page level <0000>
page offset 0000019b, page type <B-tree Node>, page level <0000>
page offset 00000149, page type <B-tree Node>, page level <0000>
page offset 00000009, page type <B-tree Node>, page level <0001>
page offset 00000000, page type <File Space Header>
page offset 0000027f, page type <B-tree Node>, page level <0000>
page offset 0000000c, page type <B-tree Node>, page level <0001>
page offset 00000007, page type <System Page>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0001>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000005, page type <B-tree Node>, page level <0000>
page offset 0000015e, page type <Undo Log Page>
page offset 00000172, page type <Undo Log Page>
page offset 0000018a, page type <Undo Log Page>
page offset 0000012d, page type <Undo Log Page>
page offset 000001c4, page type <Undo Log Page>
page offset 00000103, page type <System Page>
page offset 00000104, page type <System Page>
page offset 000001b2, page type <Undo Log Page>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0001>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000005, page type <B-tree Node>, page level <0000>
page offset 00000006, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0001>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0001>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <File Space Header>
page offset 00000005, page type <B-tree Node>, page level <0000>
page offset 00000004, page type <B-tree Node>, page level <0000>
page offset 00000005, page type <B-tree Node>, page level <0000>
page offset 000000bb, page type <Freshly Allocated Page>
page offset 000000bc, page type <Freshly Allocated Page>
page offset 000000c0, page type <System Page>
page offset 000000c1, page type <System Page>
page offset 000000e4, page type <System Page>
page offset 000000e5, page type <System Page>
page offset 000000f3, page type <File Segment inode>
page offset 000000f4, page type <System Page>
page offset 000000f5, page type <System Page>
page offset 000000f6, page type <System Page>
page offset 000000f7, page type <System Page>
page offset 0000010d, page type <Undo Log Page>
page offset 0000010e, page type <B-tree Node>, page level <0000>
page offset 0000010f, page type <B-tree Node>, page level <0000>
page offset 00000110, page type <B-tree Node>, page level <0000>
page offset 00000111, page type <B-tree Node>, page level <0000>
page offset 00000112, page type <Undo Log Page>
page offset 00000113, page type <B-tree Node>, page level <0001>
page offset 00000114, page type <B-tree Node>, page level <0001>
page offset 00000115, page type <Undo Log Page>
page offset 00000116, page type <B-tree Node>, page level <0000>
page offset 00000117, page type <Undo Log Page>
page offset 00000118, page type <Undo Log Page>
page offset 00000119, page type <Undo Log Page>
page offset 0000011a, page type <Undo Log Page>
page offset 00000148, page type <B-tree Node>, page level <0000>
page offset 00000149, page type <B-tree Node>, page level <0000>
page offset 0000014a, page type <Undo Log Page>
page offset 0000014b, page type <B-tree Node>, page level <0000>
page offset 0000014c, page type <B-tree Node>, page level <0000>
page offset 0000014d, page type <Undo Log Page>
page offset 0000014e, page type <Undo Log Page>
page offset 0000014f, page type <Undo Log Page>
page offset 00000150, page type <Undo Log Page>
page offset 00000157, page type <File Segment inode>
page offset 00000158, page type <Undo Log Page>
page offset 00000159, page type <Undo Log Page>
page offset 0000015a, page type <B-tree Node>, page level <0000>
page offset 0000015b, page type <Undo Log Page>
page offset 0000015c, page type <B-tree Node>, page level <0000>
page offset 0000015d, page type <Undo Log Page>
page offset 0000015e, page type <Undo Log Page>
page offset 0000015f, page type <Undo Log Page>
page offset 00000165, page type <B-tree Node>, page level <0000>
page offset 00000166, page type <B-tree Node>, page level <0000>
page offset 00000167, page type <B-tree Node>, page level <0000>
page offset 00000168, page type <B-tree Node>, page level <0000>
page offset 00000169, page type <Undo Log Page>
page offset 0000016a, page type <Undo Log Page>
page offset 0000016b, page type <B-tree Node>, page level <0000>
page offset 0000016c, page type <Undo Log Page>
page offset 0000016d, page type <Undo Log Page>
page offset 0000016e, page type <Undo Log Page>
page offset 0000016f, page type <Undo Log Page>
page offset 00000170, page type <B-tree Node>, page level <0000>
page offset 00000171, page type <Undo Log Page>
page offset 00000172, page type <Undo Log Page>
page offset 00000173, page type <Undo Log Page>
page offset 00000174, page type <Undo Log Page>
page offset 00000175, page type <Undo Log Page>
page offset 00000176, page type <B-tree Node>, page level <0000>
page offset 00000177, page type <Undo Log Page>
page offset 00000178, page type <B-tree Node>, page level <0000>
page offset 00000179, page type <B-tree Node>, page level <0000>
page offset 0000017a, page type <B-tree Node>, page level <0000>
page offset 0000017d, page type <Undo Log Page>
page offset 0000017e, page type <B-tree Node>, page level <0000>
page offset 0000017f, page type <Undo Log Page>
page offset 00000180, page type <Undo Log Page>
page offset 00000181, page type <Undo Log Page>
page offset 00000182, page type <File Segment inode>
page offset 00000183, page type <Undo Log Page>
page offset 00000184, page type <B-tree Node>, page level <0000>
page offset 00000185, page type <Undo Log Page>
page offset 00000186, page type <B-tree Node>, page level <0000>
page offset 00000187, page type <Undo Log Page>
page offset 00000188, page type <Undo Log Page>
page offset 00000189, page type <Undo Log Page>
page offset 0000018a, page type <Undo Log Page>
page offset 0000018b, page type <Undo Log Page>
page offset 0000018c, page type <Undo Log Page>
page offset 0000018d, page type <Undo Log Page>
page offset 0000018e, page type <Undo Log Page>
page offset 0000018f, page type <Undo Log Page>
page offset 00000190, page type <Undo Log Page>
page offset 00000191, page type <B-tree Node>, page level <0000>
page offset 00000192, page type <B-tree Node>, page level <0000>
page offset 00000193, page type <Undo Log Page>
page offset 00000194, page type <Undo Log Page>
page offset 00000195, page type <B-tree Node>, page level <0000>
page offset 00000196, page type <Undo Log Page>
page offset 00000197, page type <B-tree Node>, page level <0000>
page offset 00000198, page type <Undo Log Page>
page offset 00000199, page type <Undo Log Page>
page offset 0000019a, page type <B-tree Node>, page level <0000>
page offset 0000019b, page type <B-tree Node>, page level <0000>
page offset 0000019c, page type <Undo Log Page>
page offset 0000019d, page type <Undo Log Page>
page offset 0000019e, page type <Undo Log Page>
page offset 0000019f, page type <Undo Log Page>
page offset 000001a0, page type <Undo Log Page>
page offset 000001a1, page type <B-tree Node>, page level <0000>
page offset 000001a2, page type <Undo Log Page>
page offset 000001a3, page type <B-tree Node>, page level <0000>
page offset 000001a4, page type <Undo Log Page>
page offset 000001a5, page type <Undo Log Page>
page offset 000001a6, page type <Undo Log Page>
page offset 000001a7, page type <Undo Log Page>
page offset 000001a8, page type <Undo Log Page>
page offset 000001a9, page type <B-tree Node>, page level <0000>
page offset 000001aa, page type <Undo Log Page>
page offset 000001ab, page type <Undo Log Page>
page offset 000001ac, page type <Undo Log Page>
page offset 000001ad, page type <Undo Log Page>
page offset 000001ae, page type <Undo Log Page>
page offset 000001af, page type <B-tree Node>, page level <0000>
page offset 000001b0, page type <Undo Log Page>
page offset 000001b1, page type <Undo Log Page>
page offset 000001b2, page type <Undo Log Page>
page offset 000001cc, page type <B-tree Node>, page level <0000>
page offset 000001cd, page type <Undo Log Page>
page offset 000001ce, page type <B-tree Node>, page level <0000>
page offset 000001cf, page type <Undo Log Page>
page offset 000001d0, page type <B-tree Node>, page level <0000>
page offset 000001d1, page type <B-tree Node>, page level <0000>
page offset 000001d2, page type <Undo Log Page>
page offset 000001d3, page type <Undo Log Page>
page offset 000001d4, page type <B-tree Node>, page level <0000>
page offset 000001d5, page type <B-tree Node>, page level <0000>
page offset 000001d6, page type <B-tree Node>, page level <0000>
page offset 000001d7, page type <Undo Log Page>
page offset 000001d8, page type <Undo Log Page>
page offset 000001d9, page type <Undo Log Page>
page offset 000001de, page type <B-tree Node>, page level <0000>
page offset 000001df, page type <Undo Log Page>
page offset 000001e0, page type <File Segment inode>
page offset 000001e1, page type <Undo Log Page>
page offset 000001e2, page type <Undo Log Page>
page offset 000001e3, page type <Undo Log Page>
page offset 000001ef, page type <B-tree Node>, page level <0000>
page offset 000001f0, page type <Undo Log Page>
page offset 000001f1, page type <Undo Log Page>
page offset 000001f2, page type <Undo Log Page>
page offset 000001f5, page type <B-tree Node>, page level <0000>
page offset 000001f6, page type <Undo Log Page>
page offset 000001f7, page type <Undo Log Page>
page offset 000001f8, page type <Undo Log Page>
page offset 000001f9, page type <Undo Log Page>
page offset 000001ff, page type <B-tree Node>, page level <0000>
page offset 00000200, page type <B-tree Node>, page level <0000>
page offset 00000201, page type <Undo Log Page>
page offset 00000202, page type <Undo Log Page>
page offset 00000203, page type <Undo Log Page>
page offset 00000204, page type <Undo Log Page>
page offset 00000205, page type <Undo Log Page>
page offset 00000206, page type <Undo Log Page> --undo页的分配
page offset 00000207, page type <Undo Log Page>
page offset 00000208, page type <Undo Log Page>
page offset 00000209, page type <Undo Log Page>
page offset 0000020a, page type <Undo Log Page>
page offset 0000020b, page type <Undo Log Page>
page offset 00000000, page type <Freshly Allocated Page>
page offset 00000000, page type <Freshly Allocated Page>
page offset 00000000, page type <Freshly Allocated Page>
page offset 00000000, page type <Freshly Allocated Page>
page offset 00000000, page type <Freshly Allocated Page> --64个连续页的分配
Total number of page: 4864:
Insert Buffer Bitmap: 9
System Page: 104
Transaction system Page: 1
Freshly Allocated Page: 4293
Undo Log Page: 281
File Segment inode: 16
B-tree Node: 148
File Space Header: 12

python py_innodb_page_info.py -v /usr/local/var/mysql/ibdata1的更多相关文章

  1. 报错:ERROR! The server quit without updating PID file (/usr/local/var/mysql/chenyuntekiMacBook-Air.local.pid).

    在Mac上通过brew install mysql 安装了完mysql 执行mysql.server start 报错:ERROR! The server quit without updating ...

  2. ERROR! The server quit without updating PID file (/usr/local/var/mysql/bogon.pid).

    本文转载自http://www.jb51.net/article/48625.htm 今天网站web页面提交内容到数据库,发现出错了,一直提交不了,数找了下原因,发现数据写不进去!第一反应,重启mys ...

  3. nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)

    nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory) ...

  4. nginx: [error] invalid PID number “” in “/usr/local/var/run/nginx/nginx.pid”

    在Mac上用brew安装Nginx,然后修改Nginx配置文件,再重启时报出如下错误: nginx: [error] invalid PID number "" in " ...

  5. 【防坑指南】nginx重启后出现[error] open() “/usr/local/var/run/nginx/nginx.pid” failed

    重新启动nginx后,出现报错,原因就是下没有nginx文件夹或没有nginx.pid文件,为什么会没有呢? 原因就是每次重新启动,系统都会自动删除文件,所以解决方式就是更改pid文件存储的位置, 打 ...

  6. nginx启动或者重启失败,报错nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)

    第一种方案: 1. 执行命令 :open /usr/local/etc/nginx 打开nginx安装目录 nginx安装目录默认位置有:(找到适合你的) /etc/nginx/nginx.conf, ...

  7. nginx报错 [error] open() “/usr/local/var/run/openresty.pid” failed (2: No such file or directory)

    解决: 服务没有启动 使用start启动服务,因为没有start而直接使用stop或者reload报错这个问题: 如果方法一没有解决,使用方法二:-C 指定配置文件nginx.conf或者weblua ...

  8. 【Python之路】第二十篇--MySQL(二)

    视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名], 用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用. 1.创建视图 --格式:CREATE ...

  9. mysql MHA报错 Can't exec "mysqlbinlog": No such file or directory at /usr/local/share/perl5/MHA/BinlogManager.pm line 99.

    如果发现如下错误: Can't exec "mysqlbinlog": No such file or directory at /usr/local/share/perl5/MH ...

随机推荐

  1. 介绍Angular的注入服务

    其实angular的注入服务是挺复杂的,目前看源码也只看懂了一半,为了不误导大家,我也不讲敢讲太复杂,怕自己都理解错了. 首先我们要知道angular的三种注入方式: 第一种:inference va ...

  2. DDMS工具使用(转)

    DDMS工具使用   一.查看进程的堆栈使用情况1.选中你要查看的进程:2.点击“ Update Heap”按钮开启该进程的该项功能,如果单独打开ddms工具,按钮名为“Show heap updat ...

  3. 怎么把一个int数组转化为char型数组??

    /* 234 Press any key to continue */ #include <stdio.h> int main() { ,n; ]; ; num; ++n) { s[n] ...

  4. 畅通工程续 (dijkstra)

    畅通工程续 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  5. @Resource @Autowired 区别

    spring2.5提供了基于注解(Annotation-based)的配置,我们可以通过注解的方式来完成注入依赖.在Java代码中可以使用 @Resource或者@Autowired注解方式来经行注入 ...

  6. mtp

    http://www.android.gs/mount-google-nexus-4-mtp-sd-card-on-ubuntu-and-other-linux-computers/ https:// ...

  7. Spring的5种事物配置方式

    Spring事务配置的五种方式 前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识.通过这次的学习发觉Spring的事务配置只 ...

  8. 编码器芯片MLX90363的使用

    文档资料 MLX90363 Datasheet MLX90363 Application Note 使用 对于编码器来说,Rotary Application模式 SPI驱动中,CS必须在8个字节都发 ...

  9. svn + jenkins + maven 实现java环境的自动化构建和部署

    1. 环境说明: 系统CentOS 7 x64 IP:  10.6.0.126 1.1 首先安装配置 svn Centos 7  通过yum 安装svn 既可, 版本为1.7.14 # yum -y ...

  10. Apache2 三种MPM对比分析

    就最新版本的Web服务器Apache(版本是Apache 2.4.10,发布于2014年7月21日)来说,一共有三种稳定的MPM(Multi-Processing Module,多进程处理模块)模式. ...