概述
github:https://github.com/jeremycole/innodb_ruby
今天主要介紹一個比較有趣的解析器,也是對 InooDB 格式文件的解析器,用於 Ruby 語言,下面一起來看看吧~
1、Installing using RubyGems
sudo gem install innodb_ruby
2、測試運行
innodb_space ...
3、基礎用法
Basics of using innodb_space from the command line. There are two ways to start innodb_space.
Against a single space file (ibdata or .ibd):
Against a system tablespace which will auto-load file-per-table tablespace files:
4、Space File Structure
4.1、system-spaces
List all tablespaces available from the system, including some basic stats. This is basically a list of tables:
innodb_space -s ibdata1 system-spaces
4.2、space-indexes
List all indexes available from the space (system space or file-per-table space):
innodb_space -s /var/lib/mysql/ibdata1 -T jumpserver/assets_asset space-indexes
4.3、space-page-type-regions
Iterate through all pages in a space and print a summary of page types coalesced into 「regions」 of same-type pages:
innodb_space -s /var/lib/mysql/ibdata1 -T jumpserver/assets_asset space-page-type-regions
4.4、space-page-type-summary
Iterate through all pages and print a summary of total counts of pages by type:
innodb_space -s ibdata1 -T jumpserver/assets_asset space-page-type-summary
4.5、space-extents-illustrate
Illustrate all pages in all extents in the space, showing a colorized block (colored by index/purpose) for each page, sized based on the amount of data in the page:
innodb_space -s ibdata1 -T jumpserver/assets_asset space-extents-illustrate
4.6、space-lsn-age-illustrate
Illustrate all pages in all extents in the space, showing a colorized block (colored by the age of the modification LSN for the page):
innodb_space -s ibdata1 -T jumpserver/assets_asset space-lsn-age-illustrate
5、Page Structure
5.1、page-account
Given any page number, explain what the page is used for (for most structures):
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 3 page-account
5.2、page-dump
Intelligently dump the contents of a page including a representation of most structures that innodb_ruby understands:
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 3 page-dump
5.3、page-records
Summarize all records within the page:
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 3 page-records
5.4、page-directory-summary
Dump the contents of the page directory for a page
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 7 page-directory-summary
5.5、page-illustrate
Illustrate the content of a page:
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 7 page-illustrate
6、Index Structure
6.1、index-recurse
Recurse an index (perform a full index scan) by following the entire B+Tree (scanning all pages by recursion, not just the leaf pages by list):
innodb_space -s ibdata1 -T jumpserver/assets_asset -I PRIMARY index-recurse
6.2、index-record-offsets
Recurse an index as index-recurse does, but print the offset of each record within the index pages:
innodb_space -s ibdata1 -T jumpserver/assets_asset -I PRIMARY index-record-offsets
6.3、index-level-summary
Print a summary of all index pages at a given level:
innodb_space -s ibdata1 -T jumpserver/assets_asset -I PRIMARY -l 0 index-level-summary
7、Record Structure
7.1、record-dump
Given a record offset, dump a detailed description of a record and the data it contains:
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 7 -R 128 record-dump
8、Record History
8.1、record-history
Summarize the history (undo logs) of a record:
innodb_space -s ibdata1 -T jumpserver/assets_asset -p 7 -R 128 record-history
9、Additional exploration
9.1、space-lists
Show a summary of the lists (free, free_frag, full_frag, free_inodes, and full_inodes) for the space, including the list length and the list node information of the first and last pages in the list:
innodb_space -s ibdata1 space-lists
9.2、space-list-iterate
Iterate through all extents in a list and show the extents or inodes in the list:
innodb_space -s ibdata1 space-list-iterate -L free_frag
9.3、space-inodes-summary
Print summary information for each inode in the space:
innodb_space -s ibdata1 space-inodes-summary
9.4、undo-history-summary
Print a summary of all records in the history list (undo logs):
innodb_space -s ibdata1 undo-history-summary
9.5、undo-record-dump
Print a detailed description of an undo record and the data it contains:
innodb_space -s ibdata1 -p page -R offset undo-record-dump
覺得有用的朋友多幫忙轉發哦!後面會分享更多devops和DBA方面的內容,感興趣的朋友可以關注下~