eygle.com   eygle.com
eygle.com eygle
eygle.com  
 

« 了解一点硬件-硬盘生产全过程 | Blog首页 | 并购狂潮-EMC的动作 »

使用Solaris上的filestat工具
modb.pro

Solaris Internals: Core Kernel Architecture的作者在书中提到一个用以产看文件inode及block分配情况的工具:filestat

这是一个非常有用的工具,有助于我们理解Solaris中空间管理及分配。
通过这个工具也可以帮助我们察看文件碎片是否严重,是否需要进行整理或重组。

其输出非常简单和直观:

# filestat /home/rmc/bigfile

Inodes per cyl group: 64
Inodes per block: 64
Cylinder Group no: 0
Cylinder Group blk: 64
File System Block Size: 8192
Device block size: 512
Number of device blocks: 204928

Start Block End Block Length (Device Blocks)
----------- ----------- ----------------------
66272 -> 66463 192
66480 -> 99247 32768
1155904 -> 1188671 32768
1277392 -> 1310159 32768
1387552 -> 1420319 32768
1497712 -> 1530479 32768
1607872 -> 1640639 32768
1718016 -> 1725999 7984
1155872 -> 1155887 16

Number of extents: 9
Average extent size: 22769 Blocks

以下讨论基于UFS文件系统:
我们知道inode包括2类指针:直接指针(Direct Pointers)和间接指针(Indirect Pointers)

1.直接指针
共有12个对数据块直接访问的直接指针,按照8k的块大小分配。
这12个直接指针可以为一直到96K(12x8k=96k)字节的容量的文件直接引用数据块。

2.间接指针

有3种类型的间接指针:
一级间接指针:一个一级间接指针使用一个文件系统块记录到数据块的指针。这个文件系统块包含2048个8K字节数据块的附加地址(即2048个指针),可以用以标示和定位16M字节的数据。

二级间接指针:一个二级间接指针使用一个文件系统块进行空间扩展。一个文件系统块记录2048个指针,每个指针指向下一级间接指针,每个二级间接指针可以继续定位2048个数据块。由此,二级间接指针可以指向的32G字节的数据。

三级间接指针:类似的一个三级间接指针可以查找超过70T字节的数据。可是,在一个ufs文件系统中的最大的文件容量是1T。

通过下图我们可以直观的看到inode的层次及结构:
inode.jpg

回过头来看我们前面的filestat输出:

.......
66272 -> 66463 192
66480 -> 99247 32768
1155904 -> 1188671 32768
1277392 -> 1310159 32768
1387552 -> 1420319 32768
1497712 -> 1530479 32768
1607872 -> 1640639 32768
1718016 -> 1725999 7984
1155872 -> 1155887 16
......

我们可以看到,第一个extent分配了192个操作系统块(512bytes/os block),192x512/1024=96k,正好是inode的一级块。
而此后的6个extent都是32768个os block,正好是16M。

如果大家注意一下的话,以上结构非常类似Oracle9i开始提出的ASSM位图管理,Oracle使用三级位图块来分配管理空间。

再来看一下我的系统中文件分配空间的情况:

bash-2.03# filestat 11.dbf
Inodes per cyl group: 5632
Inodes per block: 64
Cylinder Group no: 0
Cylinder Group blk: 64
File System Block Size: 8192
Device block size: 512
Number of device blocks: 204944

Start Block End Block Length (Device Blocks)
----------- ----------- ----------------------
5884448 -> 5884639 192
15943328 -> 15976095 32768
16027760 -> 16060527 32768
16120192 -> 16134495 14304
16144560 -> 16163023 18464
16397536 -> 16404735 7200
16419440 -> 16445007 25568
16767328 -> 16774479 7152
16791696 -> 16817311 25616
16948016 -> 16974751 26736
16978960 -> 16984991 6032
17040480 -> 17048495 8016

Number of extents: 12
Average extent size: 17078 Blocks


我们注意到,在这个文件中从第四个extent开始,空间分配开始不再连续,如果一个文件碎片过多,同样可能出现性能问题。

该工具可以在以下地址下载:下载地址


历史上的今天...
    >> 2018-12-26文章:
    >> 2012-12-26文章:
    >> 2008-12-26文章:
    >> 2006-12-26文章:
    >> 2005-12-26文章:
           A Gift:Oracle DW/BI 2006 Calendar

By eygle on 2004-12-26 22:10 | Comments (4) | System | 132 |

4 Comments

你好:
这个filestat我下载怎么不好用?请帮忙!谢谢高手

什么叫不好用?

请解释!

就是我下载后 copy 到solais 中,不能执行,使用ls -l 看了一下, 不是可执行文件,我试着chmod +x filestat ,不能执行 ...

不好理解,我的没问题:
# wget http://www.solarisinternals.com/si/downloads/filestat
--09:19:23-- http://www.solarisinternals.com/si/downloads/filestat
=> `filestat'
Resolving www.solarisinternals.com... 71.146.198.169
Connecting to www.solarisinternals.com[71.146.198.169]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,057,448 [text/plain]

100%[========================================================================================>] 1,057,448 23.02K/s ETA 00:00

09:20:16 (20.70 KB/s) - `filestat' saved [1057448/1057448]

# chmod +x filestat
# ./filestat format.dat
Inodes per cyl group: 7488
Inodes per block: 64
Cylinder Group no: 0
Cylinder Group blk: 64
File System Block Size: 8192
Device block size: 512
Number of device blocks: 2

Start Block End Block Length (Device Blocks)
----------- ----------- ----------------------
37390 -> 37391 2

Number of extents: 1
Average extent size: 2 Blocks


CopyRight © 2004~2020 云和恩墨,成就未来!, All rights reserved.
数据恢复·紧急救援·性能优化 云和恩墨 24x7 热线电话:400-600-8755 业务咨询:010-59007017-7040 or 7037 业务合作: marketing@enmotech.com