innodb_space

這是一個ruby寫的分析innodb表空間的軟件,軟件位置https://github.com/jeremycole/innodb_ruby安裝方法我之前寫過了。下面是一些使用方法。

可以用innodb_space --help

Usage: innodb_space -f <file> [-p <page>] [-l <level>] <mode> [<mode>, ...]


 --help, -?

   Print this usage text.


 --file, -f <file>

   Load the tablespace file <file>.


 --page-size, -P <size>

   Provide the page size, overriding auto-detection (in KiB): 16, 8, 4, 2, 1.

   Page sizes other than 16 may not work well, or at all.


 --page, -p <page>

   Operate on the page <page>; may be specified more than once.


 --level, -l <level>

   Operate on the level <level>; may be specified more than once.


 --list, -L <list>

   Operate  on the list <list>; may be specified more than once.


 --require, -r <file>

   Use Ruby's "require" to load the file <file>. This is useful for loading

   classes with record describers.


 --describer, -d <describer>

   Use the named record describer to parse records in index pages.


The following modes are supported:


 space-summary

   Summarize all pages within a tablespace. A starting page number can be

   provided with the --page/-p argument.


 space-index-pages-summary

   Summarize all "INDEX" pages within a tablespace. This is useful to analyze

   page fill rates and record counts per page. In addition to "INDEX" pages,

   "ALLOCATED" pages are also printed and assumed to be completely empty.

   A starting page number can be provided with the --page/-p argument.


 space-index-pages-free-plot

   Use Ruby's gnuplot module to produce a scatterplot of page free space for

   all "INDEX" and "ALLOCATED" pages in a tablespace. More aesthetically

   pleasing plots can be produced with space-index-pages-summary output,

   but this is a quick and easy way to produce a passable plot. A starting

   page number can be provided with the --page/-p argument.


 space-page-type-regions

   Summarize all contiguous regions of the same page type. This is useful to

   provide an overall view of the space and allocations within it. A starting

   page number can be provided with the --page/-p argument.


 space-indexes

   Summarize all indexes (actually each segment of the indexes) to show

   the number of pages used and allocated, and the segment fill factor.


 space-lists

   Print a summary of all lists in a space.


 space-list-iterate

   Iterate through the contents of a space list.


 space-extents

   Iterate through all extents, printing the extent descriptor bitmap.


 page-dump

   Dump the contents of a page, using the Ruby pp ("pretty-print") module.


 page-directory-summary

   Summarize the record contents of the page directory in a page. If a record

   describer is available, the key of each record will be printed.


 index-recurse

   Recurse an index, starting at the root (which must be provided in the first

   --page/-p argument), printing the node pages, node pointers (links), leaf

   pages. A record describer must be provided with the --describer/-d argument

   to recurse indexes (in order to parse node pages).


 index-digraph

   Recurse an index as index-recurse does, but print a dot-compatible digraph

   instead of a human-readable summary.


 index-level-summary

   Print a summary of all pages at a given level (provided with the --level/-l

   argument) in an index.


 index-fseg-internal-lists

 index-fseg-leaf-lists

   Print a summary of all lists in an index file segment. Index root page must

   be provided with --page/-p.


 index-fseg-internal-list-iterate

 index-fseg-leaf-list-iterate

   Iterate the file segment list (whose name is provided in the first --list/-L

   argument) for internal or leaf pages for a given index (whose root page

   is provided in the first --page/-p argument). The lists used for each

   index are "full", "not_full", and "free".


 index-fseg-internal-frag-pages

 index-fseg-leaf-frag-pages

   Print a summary of all fragment pages in an index file segment. Index root

   page must be provided with --page/-p.



下面是一些使用方法:

[root@mysql_node1 test]# innodb_space -f org_profile.ibd space-summary | head -n 10

page        type                prev        next        lsn                

0           FSP_HDR             0           0           236890261          

1           IBUF_BITMAP         0           0           237680486          

2           INODE               0           0           236890261          

3           INDEX               0           0           236890261          

4           INDEX               0           0           236196117          

5           INDEX               0           0           236530143          

6           INDEX               0           0           236502478          

7           INDEX               0           0           236396601          

8           INDEX               0           0           236819994

space-summary 是查看錶空間的頁的信息,上面是給出的前1條,下面是最後十條:

[root@mysql_node1 test]# innodb_space -f org_profile.ibd space-summary | tail -n

10

12278       ALLOCATED           0           0           0                  

12279       ALLOCATED           0           0           0                  

12280       ALLOCATED           0           0           0                  

12281       ALLOCATED           0           0           0                  

12282       ALLOCATED           0           0           0                  

12283       ALLOCATED           0           0           0                  

12284       ALLOCATED           0           0           0                  

12285       ALLOCATED           0           0           0                  

12286       ALLOCATED           0           0           0                  

12287       ALLOCATED           0           0           0  

紅色的頁號說明表空間有多少頁,這裏有12287,可以計算表大小16K×12287/1024=191.98

可以看看錶空間的大小

-rw-rw---- 1 mysql mysql 192M Jul  3 10:18 org_profile.ibd

和我計算出來的一樣,這在5.6之前不能調整page大小時默認16K,5.6可以調整page大小,

原文:Each tablespace consists of database pages. Every tablespace in a MySQL instance has the same page size. By default, all tablespaces have a page size of 16KB; you can reduce the page size to 8KB or 4KB by specifying theinnodb_page_size option when you create the MySQL instance.

[root@mysql_node1 test]# innodb_space -f org_profile.ibd  space-index-pages-summ

ary| head -n 10

page        index   level   data    free    records

3           19      2       253     15997   11      

4           20      1       6324    9746    372    

5           21      1       10311   5727    491    

6           22      1       13332   2652    606    

7           23      1       5634    10464   313    

8           24      2       361     15891   6      

9           19      0       5961    10291   3      

10          19      0       13343   2909    5      

11          19      0       12507   3745    3

[root@mysql_node1 test]# innodb_space -f org_profile.ibd  space-index-pages-summ

ary| tail -n 10

12278       0       0       0       16384   0      

12279       0       0       0       16384   0      

12280       0       0       0       16384   0      

12281       0       0       0       16384   0      

12282       0       0       0       16384   0      

12283       0       0       0       16384   0      

12284       0       0       0       16384   0      

12285       0       0       0       16384   0      

12286       0       0       0       16384   0      

12287       0       0       0       16384   0  

[root@mysql_node1 test]# innodb_space -f org_profile.ibd  space-indexes

id          root        fseg        used        allocated   fill_factor

19          3           internal    12          12          100.00%    

19          3           leaf        7077        8096        87.41%      

20          4           internal    1           1           100.00%    

20          4           leaf        372         480         77.50%      

21          5           internal    1           1           100.00%    

21          5           leaf        491         608         80.76%      

22          6           internal    1           1           100.00%    

22          6           leaf        606         736         82.34%      

23          7           internal    1           1           100.00%    

23          7           leaf        313         352         88.92%      

24          8           internal    7           7           100.00%    

24          8           leaf        1248        1440        86.67%    


[root@mysql_node1 test]# innodb_space -f org_profile.ibd  space-lists

name                length      f_page      f_offset    l_page      l_offset    

free                2           0           7518        0           7558        

free_frag           1           0           1238        0           1238        

full_frag           3           0           158         0           838        

full_inodes         0           0           0           0           0          

free_inodes         1           2           38          2           38  

[root@mysql_node1 test]# innodb_space -f org_profile.ibd  space-extents

start_page  page_used_bitmap                                                

0           ################################################################

64          #######################################################.........

128         ###########################################################.....

192         ################################################################

256         ##############################################..................

320         ########################################################........

384         ################################################################

448         ################################################################

512         ##############################################..................

576         ###################################################.............

640         ################################################################

704         #########################################################.......

768         ################################################################

832         #############################################################...

896         ################################################################

960         ################################################################

1024        ################################################################

1088        ################################################################

1152        ###############################################.................

1216        ################################################################

1280        ################################################################

1344        ################################################################

1408        ################################################################

1472        ################################################################

1536        ################################################################

1600        ################################################################

1664        ################################################################

1728        ##########################......................................

1792        ################################################################

1856        ################################################################

1920        ################################################################

1984        ################################################################

2048        #####################################################...........

2112        ################################################################

2176        ################################################################

2240        ################################################################

2304        ####............................................................

2368        #################...............................................

2432        ################################################################

2496        ################################################################

2560        ################################################################

2624        #############################################################...

2688        ################################################################

2752        ################################################################

2816        ################################################################

2880        ################################################################

2944        ############################################....................

3008        ################################################################

3072        ###################################################.............

3136        ################################################################

3200        ################################################################

3264        #######################.........................................

3328        ################################################################

3392        ################################################################

3456        ################################################################

3520        ################################################################

3584        ################################################################

3648        #####################...........................................

3712        ################################################################

3776        ################################################################

3840        ################################################################

3904        ################################################################

3968        ################################################################

4032        ################################################################

4096        ################################################################

4160        ################################################################

4224        ################################################################

4288        ################################################################

4352        ################################################################

4416        ################################################################

4480        ################################################################

4544        ################################################################

4608        ################################################################

4672        ###########################################################.....

4736        ################################################################

4800        ####################################............................

4864        ################################################################

4928        ################################################################

4992        #######.........................................................

5056        ################################################################

5120        ################################################################

5184        ################################################################

5248        ################################################################

5312        ################################################################

5376        ################################################################

5440        ################################################################

5504        ################################################################

5568        ################################################################

5632        ################################################################

5696        ################################################################

5760        ################################################################

5824        ################################################################

5888        ################################################################

5952        ################################################################

6016        ################################################################

6080        ################################################################

6144        #####################...........................................

6208        ##############################..................................

6272        ###############################.................................

6336        ################################################################

6400        ################################################################

6464        ################################################################

6528        ################################################################

6592        ################################################################

6656        ###########################.....................................

6720        ################################################################

6784        ################################################################

6848        ################################################################

6912        ################################################################

6976        ################################################################

7040        ###############.................................................

7104        ################################################################

7168        ################################################################

7232        ################################################################

7296        ################################################################

7360        ################################################################

7424        ###########################################################.....

7488        ################################################################

7552        ################################################################

7616        ################################################################

7680        ################################################################

7744        ################################################################

7808        ################################################################

7872        ################################################################

7936        ################################################################

8000        #############################################################...

8064        #####...........................................................

8128        ################################################################

8192        ################################################################

8256        ################################################################

8320        ################################################################

8384        #########################.......................................

8448        ##########################################......................

8512        ################################################################

8576        ################################################################

8640        ########################################################........

8704        ################################################################

8768        ################################################################

8832        ################################################################

8896        ########################################################........

8960        ################################################################

9024        ################################################################

9088        ################################################################

9152        ######################..........................................

9216        ################################################################

9280        ####################...........................................#

9344        ################################################################

9408        ################################################################

9472        ################################################################

9536        ################################################################

9600        #######################################################.........

9664        ##########################################......................

9728        ################################################################

9792        ############################################################....

9856        #############################################################...

9920        ################################################################

9984        #######################################.........................

10048       ###########################################################.....

10112       ################################################################

10176       ##################################################..............

10240       ############################################################....

10304       ################################################################

10368       #...............................................................

10432       ################################################################

10496       ############################################################....

10560       ##############################################..................

10624       #...............................................................

10688       ################################################################

10752       ##########......................................................

10816       ################################################################

10880       #...............................................................

10944       #########################.......................................

11008       ################################################################

11072       ########........................................................

11136       ################################################################

11200       ################################################################

11264       #...............................................................

11328       ##############################################################..

11392       ...............................................................#

11456       #...............................................................

11520       ################################################################

11584       ###.............................................................

11648       #######################################################.........

11712       #################...............................................

11776       ................................................................

11840       ................................................................




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章