December 26, 2004
使用Solaris上的filestat工具
作者:eygle
出处:http://blog.eygle.com
Solaris Internals: Core Kernel Architecture的作者在书中提到一个用以产看文件inode及block分配情况的工具:filestat。
这是一个非常有用的工具,有助于我们理解Solaris中空间管理及分配。
通过这个工具也可以帮助我们察看文件碎片是否严重,是否需要进行整理或重组。
其输出非常简单和直观:
# filestat /home/rmc/bigfileInodes 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: 204928Start 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 16Number 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的层次及结构:

回过头来看我们前面的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: 204944Start 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 8016Number of extents: 12
Average extent size: 17078 Blocks
我们注意到,在这个文件中从第四个extent开始,空间分配开始不再连续,如果一个文件碎片过多,同样可能出现性能问题。
该工具可以在以下地址下载:下载地址
Posted by eygle at 10:10 PM | Comments (4)
了解一点硬件-硬盘生产全过程
作者:eygle
出处:http://blog.eygle.com
看到一篇关于硬盘生产过程的文章,转载在这里,了解一点硬件知识.
原文出处:
http://hk.netsh.com/bbs/700987/html/tree_1442982.html
1957年IBM公司研制成功的IBM 350(RAMAC)是第一台真正意义上的硬盘存储器。它由许多片直径为61厘米的盘片组成,盘片由一台电动机带动,只有一个磁头,磁头上下前后运动起来寻找要读写的磁道,和现在的硬磁盘机几乎没有什么根本性的差别,它的体积很大,但存储容量只有5MB。2000年8月,IBM公司发布了目前体积最小的硬盘Micordriver,盘片直径大约是2.54厘米,而存储容量却达到了2000MB。相比之下,磁盘技术的发展真的是突飞猛进。
真正意义上的硬盘发展的历程碑应该是1973年,IBM 3340硬盘开始应用的温彻斯特技术,这种技术在1976年的IBM 3350逐渐成熟,它的出现使硬磁盘进入一个黄金时代。温彻斯特技术的主要内容有:1.磁头、盘片、主轴等运动部分密封在一个壳体中,形成一个头盘组合件(HDA),与外界环境隔绝,避免了灰尘的污染。2.采用小型化轻浮力的磁头浮动块,盘片表面涂润滑剂,实行接触起停。即平常盘片不转时,磁头停靠在盘片上,当盘片转速达一定值时,磁头浮起并保持一定的浮动间隙。这样简化了机械结构,缩短了起动时间。采用温彻斯特技术,磁头与磁盘是一一对应的,磁头读出的就是它本身写入的,信噪比等等都比可换的要好,因此存储密度提高了,存储容量也增加了。
最早把温彻斯特技术放在小型驱动器上的依旧是IBM,其62-PC,首次采用直径为20.3厘米的盘片。此后CDC公司、NEC公司开始生产20.3厘米的硬盘驱动器。 1980年Shugart公司首先制成13.3厘米硬盘驱动器,体积的更小型化,但其容量只有6MB。1983年,Rodime公司也制成了13.3厘米的硬盘驱动器,容量也仅有6MB左右。
硬盘另外一个发展里程碑就是使用溅射工艺来生产连续介质,这样就让硬盘的密度进一步增大,为提高硬盘的存储空间奠定了良好的基础。1991年IBM首次实现了1Gbit/英寸的密度,1992年日立公司则达到2Gbit/英寸,1997年又是IBM公司领先一步,得到了11.6Gbit/英寸的实验结果。1998年Seagate公司实现了16.3Gbit/英寸的密度,1999年IBM又推出了更加大的27.6Gbit/英寸,而且这个趋势还有提高。
了解了一些硬盘的背景后,相信很多人依旧对整合硬盘的制造流程有了解。因此今天我们的主要任务就是一起来看一下硬盘的制造流程。来参观一下硬盘制造商Seagate的硬盘装配厂,主角就是Seagate目前最高端的主流桌面硬盘-酷鱼IV硬盘的生产过程。

相信所有人都知道,硬盘中磁头同盘片之间的距离很小,一半来说只有十万分之一厘米,这个距离比灰尘来得更小。因此生产硬盘必须在超尘的情况下进行。以上就是Seagate硬盘厂的质检车间,这里的厂房里显得非常干净,而且所有工作人员必须穿上防尘服才能进入。

以上则是硬盘的自动装配生产线,为了保持洁净,一般来说这里操作的工人都比较少。不过我们有幸仔细看了一下硬盘的实际制造过程。

这个就是已经制造好的硬盘底座,背后就是线路板,这个当然在刚才就已经做好了。

驱动器中需要安装的设备主要是:磁盘、磁头、液态轴承(FDB)马达等,不过这些部件的装配必须在无尘情况下进行。并且安装硬盘的时候气压有个绝对值,如果不在这个情况下安装,硬盘的可靠性就得不到保障。另外上面的图片就是已经安装好液态轴承马达的情况,由于处于商业机密,我们无法把安装马达的情况拍摄出来。

这个运送磁盘的装置,其中可以容纳25张磁盘,通过机械臂把需要的磁盘装配的硬盘中。

以上就是机械臂正在自动装填磁盘的情况,这一切都无需人为干预。

机械臂正在把磁盘装配到硬盘底座中的液态轴承马达上(先于磁盘安装)。当然磁盘是否水平我们不用担心,机械臂会自动进行水平位置的调节。

这道工序就是进行磁头的装配,由于磁头和磁盘的精密性,所有这道工序是整个硬盘安装中最复杂的,我们看到硬盘被放置在一个精确定位的装置中进行磁头装配。

一旦所有内部零件被安装好后,硬盘就基本成形了,之后就是把硬盘“盖”起来。同样这里的一切装配工作都是有流水线自动完成的。当硬盘被密封好后,就不必待在超尘的空间中了。之后就别送到最后收尾车间了。(这里无须超尘)

技术人员正在给硬盘上螺丝,同样这里的要求很严格,所有线路板都被有机玻璃隔离覆盖,这样就保证线路板不会收到静电的威胁,由于隔离的玻璃上面有定位空,这样装配起来更加不会出错了。

接着就是为线路板覆盖泡沫屏蔽层,主要是为了防止静电和控制噪音。

这才是真正最后的一步,给硬盘装上底盖,主要是进一步控制噪音,并且保护内部的原器件。当然完成这一步后,还需要为硬盘贴上标识,然后进行质检,最后当然就是出厂上市销售啦。
Posted by eygle at 3:03 PM | Comments (0)
配置AWStats,Apache日志分析工具
作者:eygle
出处:http://blog.eygle.com
今天参考了车东的文章,配置调整了AWStats工具,用于我的站点的日志分析。AWstats是一个基于Perl的WEB日志分析工具,极其强大,界面友好,而且支持中文。
目前稳定版本是6.2,2004-11-06 发布,测试版已经到了6.3,为了稳定可靠,我安装了6.2版。
该软件可以到:
http://awstats.sourceforge.net/ 或者
http://sourceforge.net/projects/awstats/
下载。
在处理日志时,需要安装cronolog工具,将日志设置成按天截断。
可以参考我的:
安装cronolog,格式化Apache的日志文件
很不错的工具。
为了提高安全性,可以设置访问认证:
在httpd.conf文件中配置需要认证的目录:
< Directory "/opt/apache/www.eygle.com/cgi-bin/awstats/" > AuthType Basic AuthName "Restricted Files" AuthUserFile /opt/apache/passwd/passwords Require user awsuser < /Directory >
其中在 /opt/apache/passwd/下产生passwords 的密码文件
运行如下代码产生用户名为awsuser用户及其密码
/opt/apache/bin/htpasswd -c /opt/apache/passwd/passwords awsuser
注意:先要在 /opt/apache/下建passwd目录
我的网站访问分析:
访问分析
Posted by eygle at 10:37 AM | Comments (12)
关于windows上的lsass.exe进程
作者:eygle
出处:http://blog.eygle.com
今天见到有人问lsass.exe进程,翻了点东西,记录些东西在这里。
lsass - lsass.exe - 进程信息
进程文件: lsass or lsass.exe
进程名称: 本地安全权限服务
描述: 本地安全权限服务,控制Windows安全机制。
常见错误: N/A
是否为系统进程: 是
该进程为系统进程,不能在任务管理器里终止,记得以前在命令行kill该进程,可能会导致系统蓝屏(不确认了)。
微软的说明如下:
Lsass.exe - You cannot end this process from Task Manager.
This is the local security authentication server, and it generates the process responsible for authenticating users for the Winlogon service. This process is performed by using authentication packages such as the default Msgina.dll. If authentication is successful, Lsass generates the user's access token, which is used to launch the initial shell. Other processes that the user initiates inherit this token.
意思是说:
这是一个本地的安全授权服务,并且它会为使用winlogon服务的授权用户生成一个进程。这个进程是通过使用授权的包,例如默认的msgina.dll来执行的。如果授权是成功的,lsass就会产生用户的进入令牌,令牌别使用启动初始的shell 。其他的由用户初始化的进程会继承这个令牌的。
但是适当的担心是有必要的,已知的部分病毒跟lsass有关。
首先,微软缺省的lsass.exe位于c:\windows\System32\lsass.exe
我们应该清楚正常运行lsass需要的动态链接库:
|
大家可以看到,Google的桌面搜索也需要在此注册,这个进程是权限控制所必需的。
有的软件验证和更新或验证注册信息,会使用500端口通信(Internet Key Exchange(IKE)-Internet密钥交换用端口),有时可能会被误报为病毒或木马。
通常我认为,只要对windows的进程有适当的认识,不依赖防病毒工具,我们仍然可以敏感的认识到异常进程或异常Dll,从而发现可疑进程,找出问题所在。
tlist这个简单的小工具就曾经帮助我发现过几个杀毒软件不能及时识别的病毒。
目前已知的和lsass相关的病毒有:
W32.HLLW.Lovgate.C@mm - Symantec Corporation
W32.Mydoom.L@mm - Symantec Corporation
W32.Nimos.Worm - Symantec Corporation
W32.Sasser.E.Worm (Lsasss.exe) - McAfee
所以大家还是应该适当的留意一下这个进程。
Posted by eygle at 9:44 AM | Comments (1)
安装cronolog,格式化Apache的日志文件
作者:eygle
出处:http://blog.eygle.com
使用cronolog可以格式化日志文件的格式,比如按时间分割,易于管理和分析。cronolog的安装配置非常简单,简要说明如下:
1.下载软件
http://cronolog.org/download/index.html
2.解压缩
gzip -d cronolog-1.6.2.tar.gz
tar xf cronolog-1.6.2.tar
2.进入相应的目录 ./configure
3.make
4.make install
5.修改apache配置文件
以下是我的安装日志,供大家参考:
[root@eygle opt]# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
--08:05:12-- http://cronolog.org/download/cronolog-1.6.2.tar.gz
=> `cronolog-1.6.2.tar.gz'
Resolving cronolog.org... done.
Connecting to cronolog.org[217.160.212.212]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 133,591 [application/x-gzip]
100%[==================================>] 133,591 26.23K/s ETA 00:00
08:05:19 (26.23 KB/s) - `cronolog-1.6.2.tar.gz' saved [133591/133591]
[root@eygle opt]# gzip -d cronolog-1.6.2.tar.gz
[root@eygle opt]# tar xf cronolog-1.6.2.tar
[root@eygle opt]# cd cronolog-1.6.2
[root@eygle cronolog-1.6.2]# ls
aclocal.m4 config.cache configure cronolog.spec install-sh Makefile.am mkinstalldirs src
AUTHORS config.log configure.in doc lib Makefile.in NEWS testsuite
ChangeLog config.status COPYING INSTALL Makefile missing README TODO
[root@eygle cronolog-1.6.2]# ./configure
loading cache ./config.cache
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... (cached) yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking for gcc... (cached) gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD compatible install... /usr/bin/install -c
checking whether ln -s works... (cached) yes
checking for ranlib... (cached) ranlib
checking for perl... (cached) /usr/bin/perl
checking how to run the C preprocessor... (cached) gcc -E
checking for ANSI C header files... (cached) yes
checking whether stat file-mode macros are broken... (cached) no
checking whether time.h and sys/time.h may both be included... (cached) yes
checking whether struct tm is in sys/time.h or time.h... (cached) time.h
checking for tm_zone in struct tm... (cached) yes
checking for fcntl.h... (cached) yes
checking for limits.h... (cached) yes
checking for unistd.h... (cached) yes
checking for working const... (cached) yes
checking for size_t... (cached) yes
checking whether struct tm is in sys/time.h or time.h... (cached) time.h
checking for strftime... (cached) yes
checking for vprintf... (cached) yes
checking for mkdir... (cached) yes
checking for mktime... (cached) yes
checking for putenv... (cached) yes
checking for strptime... (cached) yes
checking for localtime_r... (cached) yes
creating ./config.status
creating Makefile
creating lib/Makefile
creating src/Makefile
creating doc/Makefile
creating testsuite/Makefile
creating src/cronosplit
[root@eygle cronolog-1.6.2]# make
Making all in lib
make[1]: Entering directory `/opt/cronolog-1.6.2/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/cronolog-1.6.2/lib'
Making all in src
make[1]: Entering directory `/opt/cronolog-1.6.2/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/cronolog-1.6.2/src'
Making all in doc
make[1]: Entering directory `/opt/cronolog-1.6.2/doc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/cronolog-1.6.2/doc'
Making all in testsuite
make[1]: Entering directory `/opt/cronolog-1.6.2/testsuite'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/cronolog-1.6.2/testsuite'
make[1]: Entering directory `/opt/cronolog-1.6.2'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/opt/cronolog-1.6.2'
[root@eygle cronolog-1.6.2]# make install
Making install in lib
make[1]: Entering directory `/opt/cronolog-1.6.2/lib'
make[2]: Entering directory `/opt/cronolog-1.6.2/lib'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/cronolog-1.6.2/lib'
make[1]: Leaving directory `/opt/cronolog-1.6.2/lib'
Making install in src
make[1]: Entering directory `/opt/cronolog-1.6.2/src'
make[2]: Entering directory `/opt/cronolog-1.6.2/src'
/bin/sh ../mkinstalldirs /usr/local/sbin
/usr/bin/install -c cronolog /usr/local/sbin/cronolog
/bin/sh ../mkinstalldirs /usr/local/sbin
/usr/bin/install -c cronosplit /usr/local/sbin/cronosplit
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/cronolog-1.6.2/src'
make[1]: Leaving directory `/opt/cronolog-1.6.2/src'
Making install in doc
make[1]: Entering directory `/opt/cronolog-1.6.2/doc'
make[2]: Entering directory `/opt/cronolog-1.6.2/doc'
make[2]: Nothing to be done for `install-exec-am'.
/bin/sh ../mkinstalldirs /usr/local/info
/usr/bin/install -c -m 644 ./cronolog.info /usr/local/info/cronolog.info
install-info --info-dir=/usr/local/info /usr/local/info/cronolog.info
make install-man1
make[3]: Entering directory `/opt/cronolog-1.6.2/doc'
/bin/sh ../mkinstalldirs /usr/local/man/man1
/usr/bin/install -c -m 644 ./cronolog.1m /usr/local/man/man1/cronolog.1m
/usr/bin/install -c -m 644 ./cronosplit.1m /usr/local/man/man1/cronosplit.1m
make[3]: Leaving directory `/opt/cronolog-1.6.2/doc'
make[2]: Leaving directory `/opt/cronolog-1.6.2/doc'
make[1]: Leaving directory `/opt/cronolog-1.6.2/doc'
Making install in testsuite
make[1]: Entering directory `/opt/cronolog-1.6.2/testsuite'
make[2]: Entering directory `/opt/cronolog-1.6.2/testsuite'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/cronolog-1.6.2/testsuite'
make[1]: Leaving directory `/opt/cronolog-1.6.2/testsuite'
make[1]: Entering directory `/opt/cronolog-1.6.2'
make[2]: Entering directory `/opt/cronolog-1.6.2'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/cronolog-1.6.2'
make[1]: Leaving directory `/opt/cronolog-1.6.2'
[root@eygle cronolog-1.6.2]# which cronolog
/usr/local/sbin/cronolog
|
1.自定义日志格式
CustomLog "|/usr/local/sbin/cronolog /opt/apache/logs/access_log.%Y%m%d" combined
2.如果存在多个虚拟站点
可以考虑在VirtualHost进行相应设置
|
配置后生成日志文件的效果:
[root@eygle logs]# ls -l access_log.20041226 -rw-r--r-- 1 root root 110425 Dec 26 09:10 access_log.20041226 |
Posted by eygle at 9:20 AM | Comments (3)
