<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chensq&#039;s BLOG</title>
	<atom:link href="http://www.ads1st.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ads1st.com</link>
	<description>简洁，高效</description>
	<lastBuildDate>Wed, 28 Dec 2011 12:56:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>跟踪Oracle在Linux下启动关闭的系统调用</title>
		<link>http://www.ads1st.com/trace-oracle-startup-and-stop-system-call-on-linux.html</link>
		<comments>http://www.ads1st.com/trace-oracle-startup-and-stop-system-call-on-linux.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 07:28:38 +0000</pubDate>
		<dc:creator>chensq</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[Truble shooting]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[strace]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.ads1st.com/?p=1098</guid>
		<description><![CDATA[[oracle@as54 ~]$ strace -fFo sqlplus.log sqlplus

SQL*Plus: Release 10.2.0.1.0 - Product[......]<p class='read-more'><a href='http://www.ads1st.com/trace-oracle-startup-and-stop-system-call-on-linux.html'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<pre>
[oracle@as54 ~]$ strace -fFo sqlplus.log sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Sep 3 03:10:45 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning and Data Mining options

www.ads1st.com shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
www.ads1st.com startup
ORACLE instance started.

Total System Global Area  570425344 bytes
Fixed Size                  2022376 bytes
Variable Size             356516888 bytes
Database Buffers          205520896 bytes
Redo Buffers                6365184 bytes
Database mounted.
Database opened.
www.ads1st.com exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning and Data Mining options

[1]+  Stopped                 strace -fFo sqlplus.log sqlplus
</pre>
<pre>
[oracle@as54 ~]$ more sqlplus.log
2903  execve("/oracle/app/10201/bin/sqlplus", ["sqlplus"], [/* 26 vars */]) = 0
2903  brk(0)                            = 0xce3c000
2903  mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b3b82400000
2903  uname({sys="Linux", node="as54", ...}) = 0
2903  access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
2903  open("/oracle/app/10201/lib/tls/x86_64/libsqlplus.so", O_RDONLY) = -1 ENOENT (No such file or directory)
2903  stat("/oracle/app/10201/lib/tls/x86_64", 0x7fff4fd648a0) = -1 ENOENT (No such file or directory)
2903  open("/oracle/app/10201/lib/tls/libsqlplus.so", O_RDONLY) = -1 ENOENT (No such file or directory)
2903  stat("/oracle/app/10201/lib/tls", 0x7fff4fd648a0) = -1 ENOENT (No such file or directory)
2903  open("/oracle/app/10201/lib/x86_64/libsqlplus.so", O_RDONLY) = -1 ENOENT (No such file or directory)
2903  stat("/oracle/app/10201/lib/x86_64", 0x7fff4fd648a0) = -1 ENOENT (No such file or directory)
2903  open("/oracle/app/10201/lib/libsqlplus.so", O_RDONLY) = 3
2903  read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\242\2\0\0\0\0\0"..., 832) = 832
2903  fstat(3, {st_mode=S_IFREG|0640, st_size=985473, ...}) = 0
2903  mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b3b82401000
2903  mmap(NULL, 2031528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b3b82402000
2903  mprotect(0x2b3b824e6000, 1044480, PROT_NONE) = 0
2903  mmap(0x2b3b825e5000, 53248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe3000) = 0x2b3b825e5000
2903  close(3)                          = 0
2903  open("/oracle/app/10201/lib/libclntsh.so.10.1", O_RDONLY) = 3
2903  read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0x%\0\0\0\0\0"..., 832) = 832
2903  fstat(3, {st_mode=S_IFREG|0750, st_size=20706597, ...}) = 0
2903  mmap(NULL, 21471040, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b3b82601000
2903  mprotect(0x2b3b837c7000, 2097152, PROT_NONE) = 0
2903  mmap(0x2b3b839c7000, 659456, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11c6000) = 0x2b3b839c7000
2903  mmap(0x2b3b83a68000, 77632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b3b83a68000
2903  close(3)                          = 0
2903  open("/oracle/app/10201/lib/libnnz10.so", O_RDONLY) = 3
2903  read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\242\f\0\0\0\0\0"..., 832) = 832
2903  fstat(3, {st_mode=S_IFREG|0640, st_size=3803097, ...}) = 0
2903  mmap(NULL, 4854616, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b3b83a7b000
2903  mprotect(0x2b3b83d6b000, 1048576, PROT_NONE) = 0
2903  mmap(0x2b3b83e6b000, 720896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2f0000) = 0x2b3b83e6b000
2903  mmap(0x2b3b83f1b000, 4952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b3b83f1b000
2903  close(3)                          = 0
2903  open("/oracle/app/10201/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
2903  open("/etc/ld.so.cache", O_RDONLY) = 3
2903  fstat(3, {st_mode=S_IFREG|0644, st_size=101984, ...}) = 0
2903  mmap(NULL, 101984, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2b3b83f1d000
2903  close(3)                          = 0
2903  open("/lib64/libdl.so.2", O_RDONLY) = 3
2903  read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\16\0\0\0\0\0\0"..., 832) = 832
2903  fstat(3, {st_mode=S_IFREG|0755, st_size=20424, ...}) = 0
2903  mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b3b83f36000
2903  mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b3b83f37000
2903  mprotect(0x2b3b83f39000, 2097152, PROT_NONE) = 0
2903  mmap(0x2b3b84139000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x2b3b84139000
2903  close(3)                          = 0
2903  open("/oracle/app/10201/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
2903  open("/lib64/libm.so.6", O_RDONLY) = 3
......
</pre>
<pre>
[oracle@as54 ~]$ cat sqlplus.log|awk '{print $2}'|awk -F'(' '{print $1}'|sort -u
---
<...
access
arch_prctl
bind
brk
chdir
clone
close
connect
dup
execve
exit_group
fcntl
fstat
fstatfs
futex
getcwd
getegid
geteuid
getgid
getpeername
getppid
getrlimit
getrusage
getsockname
getsockopt
getuid
io_setup
ioctl
kill
lseek
lstat
mmap
mprotect
munmap
open
pipe
poll
pread
pwrite
read
readlink
readv
rt_sigaction
rt_sigprocmask
rt_sigreturn
sched_get_priority_max
sched_get_priority_min
semctl
semget
semop
semtimedop
sendto
set_robust_list
set_tid_address
setrlimit
setsid
setsockopt
shmat
shmctl
shmdt
shmget
sigaltstack
socket
stat
statfs
times
umask
uname
unlink
wait4
write
writev
</pre>
</h4>
<p>Related Posts</h4>
<ul class="related_post">
<li>2011 年 9 月 3 日 -- <a href="http://www.ads1st.com/linux-system-call-list.html" title="Linux系统调用列表">Linux系统调用列表</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ads1st.com/trace-oracle-startup-and-stop-system-call-on-linux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux系统调用列表</title>
		<link>http://www.ads1st.com/linux-system-call-list.html</link>
		<comments>http://www.ads1st.com/linux-system-call-list.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 06:59:34 +0000</pubDate>
		<dc:creator>chensq</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.ads1st.com/?p=1091</guid>
		<description><![CDATA[以下是Linux系统调用的一个列表，包含了大部分常用系统调用和由系统调用派生出的的函数。这可能是你在互联网上所能看到的唯一一篇中文注释的Linux系统调用列表，即使是简单的字母[......]<p class='read-more'><a href='http://www.ads1st.com/linux-system-call-list.html'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>以下是Linux系统调用的一个列表，包含了大部分常用系统调用和由系统调用派生出的的函数。这可能是你在互联网上所能看到的唯一一篇中文注释的Linux系统调用列表，即使是简单的字母序英文列表，能做到这么完全也是很罕见的。</p>
<p>按照惯例，这个列表以man pages第2节，即系统调用节为蓝本。按照笔者的理解，对其作了大致的分类，同时也作了一些小小的修改，删去了几个仅供内核使用，不允许用户调用的系统调用，对个别本人稍觉不妥的地方作了一些小的修改，并对所有列出的系统调用附上简要注释。</p>
<p>其中有一些函数的作用完全相同，只是参数不同。（可能很多熟悉C++朋友马上就能联想起函数重载，但是别忘了Linux核心是用C语言写的，所以只能取成 不同的函数名）。还有一些函数已经过时，被新的更好的函数所代替了（gcc在链接这些函数时会发出警告），但因为兼容的原因还保留着，这些函数我会在前面 标上“*”号以示区别。</p>
<p>一、进程控制：</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>fork</strong></td>
<td valign="top"><strong>创建一个新进程</strong></td>
</tr>
<tr>
<td valign="top"><strong>clone</strong></td>
<td valign="top">按指定条件创建子进程</td>
</tr>
<tr>
<td valign="top"><strong>execve</strong></td>
<td valign="top">运行可执行文件</td>
</tr>
<tr>
<td valign="top"><strong>exit</strong></td>
<td valign="top">中止进程</td>
</tr>
<tr>
<td valign="top"><strong>_exit</strong></td>
<td valign="top">立即中止当前进程</td>
</tr>
<tr>
<td valign="top"><strong>getdtablesize</strong></td>
<td valign="top">进程所能打开的最大文件数</td>
</tr>
<tr>
<td valign="top"><strong>getpgid</strong></td>
<td valign="top">获取指定进程组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setpgid</strong></td>
<td valign="top">设置指定进程组标志号</td>
</tr>
<tr>
<td valign="top"><strong>getpgrp</strong></td>
<td valign="top">获取当前进程组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setpgrp</strong></td>
<td valign="top">设置当前进程组标志号</td>
</tr>
<tr>
<td valign="top"><strong>getpid</strong></td>
<td valign="top">获取进程标识号</td>
</tr>
<tr>
<td valign="top"><strong>getppid</strong></td>
<td valign="top">获取父进程标识号</td>
</tr>
<tr>
<td valign="top"><strong>getpriority</strong></td>
<td valign="top">获取调度优先级</td>
</tr>
<tr>
<td valign="top"><strong>setpriority</strong></td>
<td valign="top">设置调度优先级</td>
</tr>
<tr>
<td valign="top"><strong>modify_ldt</strong></td>
<td valign="top">读写进程的本地描述表</td>
</tr>
<tr>
<td valign="top"><strong>nanosleep</strong></td>
<td valign="top">使进程睡眠指定的时间</td>
</tr>
<tr>
<td valign="top"><strong>nice</strong></td>
<td valign="top">改变分时进程的优先级</td>
</tr>
<tr>
<td valign="top"><strong>pause</strong></td>
<td valign="top">挂起进程，等待信号</td>
</tr>
<tr>
<td valign="top"><strong>personality</strong></td>
<td valign="top">设置进程运行域</td>
</tr>
<tr>
<td valign="top"><strong>prctl</strong></td>
<td valign="top">对进程进行特定操作</td>
</tr>
<tr>
<td valign="top"><strong>ptrace</strong></td>
<td valign="top">进程跟踪</td>
</tr>
<tr>
<td valign="top"><strong>sched_get_priority_max</strong></td>
<td valign="top">取得静态优先级的上限</td>
</tr>
<tr>
<td valign="top"><strong>sched_get_priority_min</strong></td>
<td valign="top">取得静态优先级的下限</td>
</tr>
<tr>
<td valign="top"><strong>sched_getparam</strong></td>
<td valign="top">取得进程的调度参数</td>
</tr>
<tr>
<td valign="top"><strong>sched_getscheduler</strong></td>
<td valign="top">取得指定进程的调度策略</td>
</tr>
<tr>
<td valign="top"><strong>sched_rr_get_interval</strong></td>
<td valign="top">取得按RR算法调度的实时进程的时间片长度</td>
</tr>
<tr>
<td valign="top"><strong>sched_setparam</strong></td>
<td valign="top">设置进程的调度参数</td>
</tr>
<tr>
<td valign="top"><strong>sched_setscheduler</strong></td>
<td valign="top">设置指定进程的调度策略和参数</td>
</tr>
<tr>
<td valign="top"><strong>sched_yield</strong></td>
<td valign="top">进程主动让出处理器,并将自己等候调度队列队尾</td>
</tr>
<tr>
<td valign="top"><strong>vfork</strong></td>
<td valign="top">创建一个子进程，以供执行新程序，常与execve等同时使用</td>
</tr>
<tr>
<td valign="top"><strong>wait</strong></td>
<td valign="top">等待子进程终止</td>
</tr>
<tr>
<td valign="top"><strong>wait3</strong></td>
<td valign="top">参见wait</td>
</tr>
<tr>
<td valign="top"><strong>waitpid</strong></td>
<td valign="top">等待指定子进程终止</td>
</tr>
<tr>
<td valign="top"><strong>wait4</strong></td>
<td valign="top">参见waitpid</td>
</tr>
<tr>
<td valign="top"><strong>capget</strong></td>
<td valign="top">获取进程权限</td>
</tr>
<tr>
<td valign="top"><strong>capset</strong></td>
<td valign="top">设置进程权限</td>
</tr>
<tr>
<td valign="top"><strong>getsid</strong></td>
<td valign="top">获取会晤标识号</td>
</tr>
<tr>
<td valign="top"><strong>setsid</strong></td>
<td valign="top">设置会晤标识号</td>
</tr>
</tbody>
</table>
<p>二、文件系统控制</p>
<p><strong>1</strong><strong>、文件读写操作</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>fcntl</strong></td>
<td valign="top"><strong>文件控制</strong></td>
</tr>
<tr>
<td valign="top"><strong>open</strong></td>
<td valign="top">打开文件</td>
</tr>
<tr>
<td valign="top"><strong>creat</strong></td>
<td valign="top">创建新文件</td>
</tr>
<tr>
<td valign="top"><strong>close</strong></td>
<td valign="top">关闭文件描述字</td>
</tr>
<tr>
<td valign="top"><strong>read</strong></td>
<td valign="top">读文件</td>
</tr>
<tr>
<td valign="top"><strong>write</strong></td>
<td valign="top">写文件</td>
</tr>
<tr>
<td valign="top"><strong>readv</strong></td>
<td valign="top">从文件读入数据到缓冲数组中</td>
</tr>
<tr>
<td valign="top"><strong>writev</strong></td>
<td valign="top">将缓冲数组里的数据写入文件</td>
</tr>
<tr>
<td valign="top"><strong>pread</strong></td>
<td valign="top">对文件随机读</td>
</tr>
<tr>
<td valign="top"><strong>pwrite</strong></td>
<td valign="top">对文件随机写</td>
</tr>
<tr>
<td valign="top"><strong>lseek</strong></td>
<td valign="top">移动文件指针</td>
</tr>
<tr>
<td valign="top"><strong>_llseek</strong></td>
<td valign="top">在64位地址空间里移动文件指针</td>
</tr>
<tr>
<td valign="top"><strong>dup</strong></td>
<td valign="top">复制已打开的文件描述字</td>
</tr>
<tr>
<td valign="top"><strong>dup2</strong></td>
<td valign="top">按指定条件复制文件描述字</td>
</tr>
<tr>
<td valign="top"><strong>flock</strong></td>
<td valign="top">文件加/解锁</td>
</tr>
<tr>
<td valign="top"><strong>poll</strong></td>
<td valign="top">I/O多路转换</td>
</tr>
<tr>
<td valign="top"><strong>truncate</strong></td>
<td valign="top">截断文件</td>
</tr>
<tr>
<td valign="top"><strong>ftruncate</strong></td>
<td valign="top">参见truncate</td>
</tr>
<tr>
<td valign="top"><strong>umask</strong></td>
<td valign="top">设置文件权限掩码</td>
</tr>
<tr>
<td valign="top"><strong>fsync</strong></td>
<td valign="top">把文件在内存中的部分写回磁盘</td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>2</strong><strong>、文件系统操作</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>access</strong></td>
<td valign="top"><strong>确定文件的可存取性</strong></td>
</tr>
<tr>
<td valign="top"><strong>chdir</strong></td>
<td valign="top">改变当前工作目录</td>
</tr>
<tr>
<td valign="top"><strong>fchdir</strong></td>
<td valign="top">参见chdir</td>
</tr>
<tr>
<td valign="top"><strong>chmod</strong></td>
<td valign="top">改变文件方式</td>
</tr>
<tr>
<td valign="top"><strong>fchmod</strong></td>
<td valign="top">参见chmod</td>
</tr>
<tr>
<td valign="top"><strong>chown</strong></td>
<td valign="top">改变文件的属主或用户组</td>
</tr>
<tr>
<td valign="top"><strong>fchown</strong></td>
<td valign="top">参见chown</td>
</tr>
<tr>
<td valign="top"><strong>lchown</strong></td>
<td valign="top">参见chown</td>
</tr>
<tr>
<td valign="top"><strong>chroot</strong></td>
<td valign="top">改变根目录</td>
</tr>
<tr>
<td valign="top"><strong>stat</strong></td>
<td valign="top">取文件状态信息</td>
</tr>
<tr>
<td valign="top"><strong>lstat</strong></td>
<td valign="top">参见stat</td>
</tr>
<tr>
<td valign="top"><strong>fstat</strong></td>
<td valign="top">参见stat</td>
</tr>
<tr>
<td valign="top"><strong>statfs</strong></td>
<td valign="top">取文件系统信息</td>
</tr>
<tr>
<td valign="top"><strong>fstatfs</strong></td>
<td valign="top">参见statfs</td>
</tr>
<tr>
<td valign="top"><strong>readdir</strong></td>
<td valign="top">读取目录项</td>
</tr>
<tr>
<td valign="top"><strong>getdents</strong></td>
<td valign="top">读取目录项</td>
</tr>
<tr>
<td valign="top"><strong>mkdir</strong></td>
<td valign="top">创建目录</td>
</tr>
<tr>
<td valign="top"><strong>mknod</strong></td>
<td valign="top">创建索引节点</td>
</tr>
<tr>
<td valign="top"><strong>rmdir</strong></td>
<td valign="top">删除目录</td>
</tr>
<tr>
<td valign="top"><strong>rename</strong></td>
<td valign="top">文件改名</td>
</tr>
<tr>
<td valign="top"><strong>link</strong></td>
<td valign="top">创建链接</td>
</tr>
<tr>
<td valign="top"><strong>symlink</strong></td>
<td valign="top">创建符号链接</td>
</tr>
<tr>
<td valign="top"><strong>unlink</strong></td>
<td valign="top">删除链接</td>
</tr>
<tr>
<td valign="top"><strong>readlink</strong></td>
<td valign="top">读符号链接的值</td>
</tr>
<tr>
<td valign="top"><strong>mount</strong></td>
<td valign="top">安装文件系统</td>
</tr>
<tr>
<td valign="top"><strong>umount</strong></td>
<td valign="top">卸下文件系统</td>
</tr>
<tr>
<td valign="top"><strong>ustat</strong></td>
<td valign="top">取文件系统信息</td>
</tr>
<tr>
<td valign="top"><strong>utime</strong></td>
<td valign="top">改变文件的访问修改时间</td>
</tr>
<tr>
<td valign="top"><strong>utimes</strong></td>
<td valign="top">参见utime</td>
</tr>
<tr>
<td valign="top"><strong>quotactl</strong></td>
<td valign="top">控制磁盘配额</td>
</tr>
</tbody>
</table>
<p>三、系统控制</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>ioctl</strong></td>
<td valign="top"><strong>I/O</strong><strong>总控制函数</strong></td>
</tr>
<tr>
<td valign="top"><strong>_sysctl</strong></td>
<td valign="top">读/写系统参数</td>
</tr>
<tr>
<td valign="top"><strong>acct</strong></td>
<td valign="top">启用或禁止进程记账</td>
</tr>
<tr>
<td valign="top"><strong>getrlimit</strong></td>
<td valign="top">获取系统资源上限</td>
</tr>
<tr>
<td valign="top"><strong>setrlimit</strong></td>
<td valign="top">设置系统资源上限</td>
</tr>
<tr>
<td valign="top"><strong>getrusage</strong></td>
<td valign="top">获取系统资源使用情况</td>
</tr>
<tr>
<td valign="top"><strong>uselib</strong></td>
<td valign="top">选择要使用的二进制函数库</td>
</tr>
<tr>
<td valign="top"><strong>ioperm</strong></td>
<td valign="top">设置端口I/O权限</td>
</tr>
<tr>
<td valign="top"><strong>iopl</strong></td>
<td valign="top">改变进程I/O权限级别</td>
</tr>
<tr>
<td valign="top"><strong>outb</strong></td>
<td valign="top">低级端口操作</td>
</tr>
<tr>
<td valign="top"><strong>reboot</strong></td>
<td valign="top">重新启动</td>
</tr>
<tr>
<td valign="top"><strong>swapon</strong></td>
<td valign="top">打开交换文件和设备</td>
</tr>
<tr>
<td valign="top"><strong>swapoff</strong></td>
<td valign="top">关闭交换文件和设备</td>
</tr>
<tr>
<td valign="top"><strong>bdflush</strong></td>
<td valign="top">控制bdflush守护进程</td>
</tr>
<tr>
<td valign="top"><strong>sysfs</strong></td>
<td valign="top">取核心支持的文件系统类型</td>
</tr>
<tr>
<td valign="top"><strong>sysinfo</strong></td>
<td valign="top">取得系统信息</td>
</tr>
<tr>
<td valign="top"><strong>adjtimex</strong></td>
<td valign="top">调整系统时钟</td>
</tr>
<tr>
<td valign="top"><strong>alarm</strong></td>
<td valign="top">设置进程的闹钟</td>
</tr>
<tr>
<td valign="top"><strong>getitimer</strong></td>
<td valign="top">获取计时器值</td>
</tr>
<tr>
<td valign="top"><strong>setitimer</strong></td>
<td valign="top">设置计时器值</td>
</tr>
<tr>
<td valign="top"><strong>gettimeofday</strong></td>
<td valign="top">取时间和时区</td>
</tr>
<tr>
<td valign="top"><strong>settimeofday</strong></td>
<td valign="top">设置时间和时区</td>
</tr>
<tr>
<td valign="top"><strong>stime</strong></td>
<td valign="top">设置系统日期和时间</td>
</tr>
<tr>
<td valign="top"><strong>time</strong></td>
<td valign="top">取得系统时间</td>
</tr>
<tr>
<td valign="top"><strong>times</strong></td>
<td valign="top">取进程运行时间</td>
</tr>
<tr>
<td valign="top"><strong>uname</strong></td>
<td valign="top">获取当前UNIX系统的名称、版本和主机等信息</td>
</tr>
<tr>
<td valign="top"><strong>vhangup</strong></td>
<td valign="top">挂起当前终端</td>
</tr>
<tr>
<td valign="top"><strong>nfsservctl</strong></td>
<td valign="top">对NFS守护进程进行控制</td>
</tr>
<tr>
<td valign="top"><strong>vm86</strong></td>
<td valign="top">进入模拟8086模式</td>
</tr>
<tr>
<td valign="top"><strong>create_module</strong></td>
<td valign="top">创建可装载的模块项</td>
</tr>
<tr>
<td valign="top"><strong>delete_module</strong></td>
<td valign="top">删除可装载的模块项</td>
</tr>
<tr>
<td valign="top"><strong>init_module</strong></td>
<td valign="top">初始化模块</td>
</tr>
<tr>
<td valign="top"><strong>query_module</strong></td>
<td valign="top">查询模块信息</td>
</tr>
<tr>
<td valign="top"><strong>*get_kernel_syms</strong></td>
<td valign="top">取得核心符号,已被query_module代替</td>
</tr>
</tbody>
</table>
<p>四、内存管理</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>brk</strong></td>
<td valign="top"><strong>改变数据段空间的分配</strong></td>
</tr>
<tr>
<td valign="top"><strong>sbrk</strong></td>
<td valign="top">参见brk</td>
</tr>
<tr>
<td valign="top"><strong>mlock</strong></td>
<td valign="top">内存页面加锁</td>
</tr>
<tr>
<td valign="top"><strong>munlock</strong></td>
<td valign="top">内存页面解锁</td>
</tr>
<tr>
<td valign="top"><strong>mlockall</strong></td>
<td valign="top">调用进程所有内存页面加锁</td>
</tr>
<tr>
<td valign="top"><strong>munlockall</strong></td>
<td valign="top">调用进程所有内存页面解锁</td>
</tr>
<tr>
<td valign="top"><strong>mmap</strong></td>
<td valign="top">映射虚拟内存页</td>
</tr>
<tr>
<td valign="top"><strong>munmap</strong></td>
<td valign="top">去除内存页映射</td>
</tr>
<tr>
<td valign="top"><strong>mremap</strong></td>
<td valign="top">重新映射虚拟内存地址</td>
</tr>
<tr>
<td valign="top"><strong>msync</strong></td>
<td valign="top">将映射内存中的数据写回磁盘</td>
</tr>
<tr>
<td valign="top"><strong>mprotect</strong></td>
<td valign="top">设置内存映像保护</td>
</tr>
<tr>
<td valign="top"><strong>getpagesize</strong></td>
<td valign="top">获取页面大小</td>
</tr>
<tr>
<td valign="top"><strong>sync</strong></td>
<td valign="top">将内存缓冲区数据写回硬盘</td>
</tr>
<tr>
<td valign="top"><strong>cacheflush</strong></td>
<td valign="top">将指定缓冲区中的内容写回磁盘</td>
</tr>
</tbody>
</table>
<p>五、网络管理</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>getdomainname</strong></td>
<td valign="top"><strong>取域名</strong></td>
</tr>
<tr>
<td valign="top"><strong>setdomainname</strong></td>
<td valign="top">设置域名</td>
</tr>
<tr>
<td valign="top"><strong>gethostid</strong></td>
<td valign="top">获取主机标识号</td>
</tr>
<tr>
<td valign="top"><strong>sethostid</strong></td>
<td valign="top">设置主机标识号</td>
</tr>
<tr>
<td valign="top"><strong>gethostname</strong></td>
<td valign="top">获取本主机名称</td>
</tr>
<tr>
<td valign="top"><strong>sethostname</strong></td>
<td valign="top">设置主机名称</td>
</tr>
</tbody>
</table>
<p>六、socket控制</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>socketcall</strong></td>
<td valign="top"><strong>socket</strong><strong>系统调用</strong></td>
</tr>
<tr>
<td valign="top"><strong>socket</strong></td>
<td valign="top">建立socket</td>
</tr>
<tr>
<td valign="top"><strong>bind</strong></td>
<td valign="top">绑定socket到端口</td>
</tr>
<tr>
<td valign="top"><strong>connect</strong></td>
<td valign="top">连接远程主机</td>
</tr>
<tr>
<td valign="top"><strong>accept</strong></td>
<td valign="top">响应socket连接请求</td>
</tr>
<tr>
<td valign="top"><strong>send</strong></td>
<td valign="top">通过socket发送信息</td>
</tr>
<tr>
<td valign="top"><strong>sendto</strong></td>
<td valign="top">发送UDP信息</td>
</tr>
<tr>
<td valign="top"><strong>sendmsg</strong></td>
<td valign="top">参见send</td>
</tr>
<tr>
<td valign="top"><strong>recv</strong></td>
<td valign="top">通过socket接收信息</td>
</tr>
<tr>
<td valign="top"><strong>recvfrom</strong></td>
<td valign="top">接收UDP信息</td>
</tr>
<tr>
<td valign="top"><strong>recvmsg</strong></td>
<td valign="top">参见recv</td>
</tr>
<tr>
<td valign="top"><strong>listen</strong></td>
<td valign="top">监听socket端口</td>
</tr>
<tr>
<td valign="top"><strong>select</strong></td>
<td valign="top">对多路同步I/O进行轮询</td>
</tr>
<tr>
<td valign="top"><strong>shutdown</strong></td>
<td valign="top">关闭socket上的连接</td>
</tr>
<tr>
<td valign="top"><strong>getsockname</strong></td>
<td valign="top">取得本地socket名字</td>
</tr>
<tr>
<td valign="top"><strong>getpeername</strong></td>
<td valign="top">获取通信对方的socket名字</td>
</tr>
<tr>
<td valign="top"><strong>getsockopt</strong></td>
<td valign="top">取端口设置</td>
</tr>
<tr>
<td valign="top"><strong>setsockopt</strong></td>
<td valign="top">设置端口参数</td>
</tr>
<tr>
<td valign="top"><strong>sendfile</strong></td>
<td valign="top">在文件或端口间传输数据</td>
</tr>
<tr>
<td valign="top"><strong>socketpair</strong></td>
<td valign="top">创建一对已联接的无名socket</td>
</tr>
</tbody>
</table>
<p>七、用户管理</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>getuid</strong></td>
<td valign="top"><strong>获取用户标识号</strong></td>
</tr>
<tr>
<td valign="top"><strong>setuid</strong></td>
<td valign="top">设置用户标志号</td>
</tr>
<tr>
<td valign="top"><strong>getgid</strong></td>
<td valign="top">获取组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setgid</strong></td>
<td valign="top">设置组标志号</td>
</tr>
<tr>
<td valign="top"><strong>getegid</strong></td>
<td valign="top">获取有效组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setegid</strong></td>
<td valign="top">设置有效组标识号</td>
</tr>
<tr>
<td valign="top"><strong>geteuid</strong></td>
<td valign="top">获取有效用户标识号</td>
</tr>
<tr>
<td valign="top"><strong>seteuid</strong></td>
<td valign="top">设置有效用户标识号</td>
</tr>
<tr>
<td valign="top"><strong>setregid</strong></td>
<td valign="top">分别设置真实和有效的的组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setreuid</strong></td>
<td valign="top">分别设置真实和有效的用户标识号</td>
</tr>
<tr>
<td valign="top"><strong>getresgid</strong></td>
<td valign="top">分别获取真实的,有效的和保存过的组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setresgid</strong></td>
<td valign="top">分别设置真实的,有效的和保存过的组标识号</td>
</tr>
<tr>
<td valign="top"><strong>getresuid</strong></td>
<td valign="top">分别获取真实的,有效的和保存过的用户标识号</td>
</tr>
<tr>
<td valign="top"><strong>setresuid</strong></td>
<td valign="top">分别设置真实的,有效的和保存过的用户标识号</td>
</tr>
<tr>
<td valign="top"><strong>setfsgid</strong></td>
<td valign="top">设置文件系统检查时使用的组标识号</td>
</tr>
<tr>
<td valign="top"><strong>setfsuid</strong></td>
<td valign="top">设置文件系统检查时使用的用户标识号</td>
</tr>
<tr>
<td valign="top"><strong>getgroups</strong></td>
<td valign="top">获取后补组标志清单</td>
</tr>
<tr>
<td valign="top"><strong>setgroups</strong></td>
<td valign="top">设置后补组标志清单</td>
</tr>
</tbody>
</table>
<p>八、进程间通信</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>ipc</strong></td>
<td valign="top"><strong>进程间通信总控制调用</strong></td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>1</strong><strong>、信号</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>sigaction</strong></td>
<td valign="top"><strong>设置对指定信号的处理方法</strong></td>
</tr>
<tr>
<td valign="top"><strong>sigprocmask</strong></td>
<td valign="top">根据参数对信号集中的信号执行阻塞/解除阻塞等操作</td>
</tr>
<tr>
<td valign="top"><strong>sigpending</strong></td>
<td valign="top">为指定的被阻塞信号设置队列</td>
</tr>
<tr>
<td valign="top"><strong>sigsuspend</strong></td>
<td valign="top">挂起进程等待特定信号</td>
</tr>
<tr>
<td valign="top"><strong>signal</strong></td>
<td valign="top">参见signal</td>
</tr>
<tr>
<td valign="top"><strong>kill</strong></td>
<td valign="top">向进程或进程组发信号</td>
</tr>
<tr>
<td valign="top"><strong>*sigblock</strong></td>
<td valign="top">向被阻塞信号掩码中添加信号,已被sigprocmask代替</td>
</tr>
<tr>
<td valign="top"><strong>*siggetmask</strong></td>
<td valign="top">取得现有阻塞信号掩码,已被sigprocmask代替</td>
</tr>
<tr>
<td valign="top"><strong>*sigsetmask</strong></td>
<td valign="top">用给定信号掩码替换现有阻塞信号掩码,已被sigprocmask代替</td>
</tr>
<tr>
<td valign="top"><strong>*sigmask</strong></td>
<td valign="top">将给定的信号转化为掩码,已被sigprocmask代替</td>
</tr>
<tr>
<td valign="top"><strong>*sigpause</strong></td>
<td valign="top">作用同sigsuspend,已被sigsuspend代替</td>
</tr>
<tr>
<td valign="top"><strong>sigvec</strong></td>
<td valign="top">为兼容BSD而设的信号处理函数,作用类似sigaction</td>
</tr>
<tr>
<td valign="top"><strong>ssetmask</strong></td>
<td valign="top">ANSI C的信号处理函数,作用类似sigaction</td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>2</strong><strong>、消息</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>msgctl</strong></td>
<td valign="top"><strong>消息控制操作</strong></td>
</tr>
<tr>
<td valign="top"><strong>msgget</strong></td>
<td valign="top">获取消息队列</td>
</tr>
<tr>
<td valign="top"><strong>msgsnd</strong></td>
<td valign="top">发消息</td>
</tr>
<tr>
<td valign="top"><strong>msgrcv</strong></td>
<td valign="top">取消息</td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>3</strong><strong>、管道</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>pipe</strong></td>
<td valign="top"><strong>创建管道</strong></td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>4</strong><strong>、信号量</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>semctl</strong></td>
<td valign="top"><strong>信号量控制</strong></td>
</tr>
<tr>
<td valign="top"><strong>semget</strong></td>
<td valign="top">获取一组信号量</td>
</tr>
<tr>
<td valign="top"><strong>semop</strong></td>
<td valign="top">信号量操作</td>
</tr>
</tbody>
</table>
<p><strong>5</strong><strong>、共享内存</strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="232" valign="top"><strong>shmctl</strong></td>
<td valign="top"><strong>控制共享内存</strong></td>
</tr>
<tr>
<td valign="top"><strong>shmget</strong></td>
<td valign="top">获取共享内存</td>
</tr>
<tr>
<td valign="top"><strong>shmat</strong></td>
<td valign="top">连接共享内存</td>
</tr>
<tr>
<td valign="top"><strong>shmdt</strong></td>
<td valign="top">拆卸共享内存</td>
</tr>
</tbody>
</table>
<p>参考资料</p>
<ul>
<li>Linux man      pages</li>
<li>Advanced      Programming in the UNIX Environment, W. Richard Stevens, 1993</li>
</ul>
<p>原文地址：http://www.ibm.com/developerworks/cn/linux/kernel/syscall/part1/appendix.html</h4>
<p>Related Posts</h4>
<ul class="related_post">
<li>2011 年 9 月 3 日 &#8212; <a href="http://www.ads1st.com/trace-oracle-startup-and-stop-system-call-on-linux.html" title="跟踪Oracle在Linux下启动关闭的系统调用">跟踪Oracle在Linux下启动关闭的系统调用</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ads1st.com/linux-system-call-list.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux 网络分析工具 tcpdump</title>
		<link>http://www.ads1st.com/linux-network-analyze-tool-tcpdump.html</link>
		<comments>http://www.ads1st.com/linux-network-analyze-tool-tcpdump.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 03:09:47 +0000</pubDate>
		<dc:creator>chensq</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[Truble shooting]]></category>
		<category><![CDATA[tcpdump]]></category>

		<guid isPermaLink="false">http://www.ads1st.com/?p=1085</guid>
		<description><![CDATA[网络数据采集分析工具TcpDump的简介
顾名思义，TcpDump可以将网络中传送的数据包的“头”完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤，并提供a[......]<p class='read-more'><a href='http://www.ads1st.com/linux-network-analyze-tool-tcpdump.html'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>网络数据采集分析工具TcpDump的简介</p>
<p>顾名思义，TcpDump可以将网络中传送的数据包的“头”完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤，并提供and、or、not等逻辑语句来帮助你去掉无用的信息。<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>就是一种免费的网络分析工具，尤其其提供了源代码，公开了接口，因此具备很强的可扩展性，对于网络维护和入侵者都是非常有用的工具。<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>存在于基本的FreeBSD系统中，由于它需要将网络界面设置为混杂模式，普通用户不能正常执行，但具备root权限的用户可以直接执行它来获取网络上的信息。因此系统中存在网络分析工具主要不是对本机安全的威胁，而是对网络上的其他计算机的安全存在威胁。</p>
<p>我们用尽量简单的话来定义<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>，就是：dump the traffice on a network.，根据使用者的定义对网络上的数据包进行截获的包分析工具。作为互联网上经典的的系统管理员必备工具，<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>以其强大的功能，灵活的截取策略，成为每个高级的系统管理员分析网络，排查问题等所必备的东西之一。<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>提供了源代码，公开了接口，因此具备很强的可扩展性，对于网络维护和入侵者都是非常有用的工具。<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>存在于基本的FreeBSD系统中，由于它需要将网络界面设置为混杂模式，普通用户不能正常执行，但具备root权限的用户可以直接执行它来获取网络上的信息。因此系统中存在网络分析工具主要不是对本机安全的威胁，而是对网络上的其他计算机的安全存在威胁。</p>
<p>网络数据采集分析工具TcpDump的安装</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>在<a href="http://linux.anheng.com/news/24/586.html">linux</a>下<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的安装十分简单，一般由两种安装方式。一种是以rpm包的形式来进行安装。另外一种是以源程序的形式安装。</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>rpm包的形式安装：这种形式的安装是最简单的安装方法，rpm包是将软件编译后打包成二进制的格式，通过rpm命令可以直接安装，不需要修改任何东西。以超级用户登录，使用命令如下：<br />
#rpm -ivh <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>-3_4a5.rpm</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>这样<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>就顺利地安装到你的<a href="http://linux.anheng.com/news/24/586.html">linux</a>系统中。怎么样，很简单吧。</p>
<p>源程序的安装：既然rpm包的安装很简单,为什么还要采用比较复杂的源程序安装呢?其实，<a href="http://linux.anheng.com/news/24/586.html">linux</a>一个最大的诱人之处就是在她上面有很多软件是提供源程序的，人们可以修改源程序来满足自己的特殊的需要。所以我特别建议朋友们都采取这种源程序的安装方法。</p>
<ul>
<li>第一步 取得源程序 在源程序的安装方式中，我们首先要取得<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的源程序分发包，这种分发包有两种形式，一种是tar压缩包(<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>-3_4a5.tar.Z),另一种是rpm的分发包(<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>-3_4a5.src.rpm)。这两种形式的内容都是一样的，不同的仅仅是压缩的方式.tar的压缩包可以使用如下命令解开：<br />
#tar xvfz <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>-3_4a5.tar.Z<br />
rpm的包可以使用如下命令安装:<br />
#rpm -ivh <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>-3_4a5.src.rpm<br />
这样就把<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的源代码解压到/usr/src/redhat/SOURCES目录下.</li>
<li>第二步 做好编译源程序前的准备活动<br />
在编译源程序之前，最好已经确定库文件libpcap已经安装完毕，这个库文件是<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>软件所需的库文件。同样，你同时还要有一个标准的c语言编译器。在<a href="http://linux.anheng.com/news/24/586.html">linux</a>下标准的c 语言编译器一般是gcc。 在<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的源程序目录中。有一个文件是Makefile.in，configure命令就是从Makefile.in文件中自动产生Makefile文件。在Makefile.in文件中，可以根据系统的配置来修改BINDEST 和 MANDEST 这两个宏定义，缺省值是<br />
BINDEST = @sbindir@<br />
MANDEST = @mandir@<br />
第一个宏值表明安装<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的二进制文件的路径名，第二个表明<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的man 帮助页的路径名,你可以修改它们来满足系统的需求。</li>
<li>第三步 编译源程序<br />
使用源程序目录中的configure脚本，它从系统中读出各种所需的属性。并且根据Makefile.in文件自动生成Makefile文件，以便编译使用.make 命令则根据Makefile文件中的规则编译<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的源程序。使用make install命令安装编译好的<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的二进制文件。<br />
总结一下就是:<br />
# tar xvfz <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>-3_4a5.tar.Z<br />
# vi Makefile.in<br />
# . /configure<br />
# make<br />
# make install</li>
</ul>
<p>3 网络数据采集分析工具TcpDump的使用</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>普通情况下，直接启动<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>将监视第一个网络界面上所有流过的数据包。<br />
<span style="font-family: courier new,courier,mono;"># <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a><br />
<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>: listening on fxp0<br />
11:58:47.873028 202.102.245.40.netbios-ns &gt; 202.102.245.127.netbios-ns: udp 50<br />
11:58:47.974331 0:10:7b:8:3a:56 &gt; 1:80:c2:0:0:0 802.1d ui/C len=43<br />
0000 0000 0080 0000 1007 cf08 0900 0000<br />
0e80 0000 902b 4695 0980 8701 0014 0002<br />
000f 0000 902b 4695 0008 00<br />
11:58:48.373134 0:0:e8:5b:6d:85 &gt; Broadcast sap e0 ui/C len=97<br />
ffff 0060 0004 ffff ffff ffff ffff ffff<br />
0452 ffff ffff 0000 e85b 6d85 4008 0002<br />
0640 4d41 5354 4552 5f57 4542 0000 0000<br />
0000 00<br />
^C</span></p>
<p><a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>支持相当多的不同参数，如使用-i参数指定<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>监听的网络界面，这在计算机具有多个网络界面时非常有用，使用-c参数指定要监听的数据包数量，使用-w参数指定将监听到的数据包写入文件中保存，等等。</p>
<p>然而更复杂的<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>参数是用于过滤目的，这是因为网络中流量很大，如果不加分辨将所有的数据包都截留下来，数据量太大，反而不容易发现需要的数据包。使用这些参数定义的过滤规则可以截留特定的数据包，以缩小目标，才能更好的分析网络中存在的问题。<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>使用参数指定要监视数据包的类型、地址、端口等，根据具体的网络问题，充分利用这些过滤规则就能达到迅速定位故障的目的。请使用man <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>查看这些过滤规则的具体用法。</p>
<p>显然为了安全起见，不用作网络管理用途的计算机上不应该运行这一类的网络分析软件，为了屏蔽它们，可以屏蔽内核中的bpfilter伪设备。一般情况下网 络硬件和TCP/IP堆栈不支持接收或发送与本计算机无关的数据包，为了接收这些数据包，就必须使用网卡的混杂模式，并绕过标准的TCP/IP堆栈才行。 在FreeBSD下，这就需要内核支持伪设备bpfilter。因此，在内核中取消bpfilter支持，就能屏蔽<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>之类的网络分析工具。</p>
<p>并且当网卡被设置为混杂模式时，系统会在控制台和日志文件中留下记录，提醒管理员留意这台系统是否被用作攻击同网络的其他计算机的跳板。</p>
<p>May 15 16:27:20 host1 /kernel: fxp0: promiscuous mode enabled</p>
<p>虽然网络分析工具能将网络中传送的数据记录下来，但是网络中的数据流量相当大，如何对这些数据进行分析、分类统计、发现并报告错误却是更关键的问题。网络 中的数据包属于不同的协议，而不同协议数据包的格式也不同。因此对捕获的数据进行解码，将包中的信息尽可能的展示出来，对于协议分析工具来讲更为重要。昂 贵的商业分析工具的优势就在于它们能支持很多种类的应用层协议，而不仅仅只支持tcp、udp等低层协议。</p>
<p>从上面<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的输出可以看出，<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>对截获的数据并没有进行彻底解码，数据包内的大部分内容是使用十六进制的形式直接打印输出的。显然这不利于分析网络故障，通常的解决办法是先使用带-w参数的<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> 截获数据并保存到文件中，然后再使用其他程序进行解码分析。当然也应该定义过滤规则，以避免捕获的数据包填满整个硬盘。FreeBSD提供的一个有效的解码程序为tcpshow，它可以通过Packages Collection来安装。</p>
<p><span style="font-family: courier new,courier,mono;"># pkg_add /cdrom/packages/security/tcpshow*<br />
# <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> -c 3 -w <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>.out<br />
<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>: listening on fxp0<br />
# tcpshow &lt; <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>.out<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Packet 1<br />
TIME:12:00:59.984829<br />
LINK:00:10:7B:08:3A:56 -&gt; 01:80:C2:00:00:00 type=0026<br />
&lt;*** No decode support for encapsulated protocol ***&gt;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Packet 2<br />
TIME:12:01:01.074513 (1.089684)<br />
LINK:00:A0:C9:AB:3C:DF -&gt; FF:FF:FF:FF:FF:FF type=ARP<br />
ARP:htype=Ethernet ptype=IP hlen=6 plen=4 op=request<br />
sender-MAC-addr=00:A0:C9:AB:3C:DF sender-IP-address=202.102.245.3<br />
target-MAC-addr=00:00:00:00:00:00 target-IP-address=202.102.245.3<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Packet 3<br />
TIME:12:01:01.985023 (0.910510)<br />
LINK:00:10:7B:08:3A:56 -&gt; 01:80:C2:00:00:00 type=0026<br />
&lt;*** No decode support for encapsulated protocol ***&gt;</span></p>
<p>tcpshow能以不同方式对数据包进行解码，并以不同的方式显示解码数据，使用者可以根据其手册来选择最合适的参数对截获的数据包进行分析。从上面的例子中可以看出，tcpshow支持的协议也并不丰富，对于它不支持的协议就无法进行解码。</p>
<p>除了<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>之 外，FreeBSD的Packages  Collecion中还提供了Ethereal和Sniffit两个网络分析工具，以及其他一些基于网络分析方式的安全工具。其中Ethereal运行在 X Window 下，具有不错的图形界面，Sniffit使用字符窗口形式，同样也易于操作。然而由于<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>对 过滤规则的支持能力更强大，因此系统管理员仍然更喜欢使用它。对于有经验的网络管理员，使用这些网络分析工具不但能用来了解网络到底是如何运行的，故障出 现在何处，还能进行有效的统计工作，如那种协议产生的通信量占主要地位，那个主机最繁忙，网络瓶颈位于何处等等问题。因此网络分析工具是用于网络管理的宝 贵系统工具。为了防止数据被滥用的网络分析工具截获，关键还是要在网络的物理结构上解决。常用的方法是使用交换机或网桥将信任网络和不信任网络分隔开，可 以防止外部网段窃听内部数据传输，但仍然不能解决内部网络与外部网络相互通信时的数据安全问题。如果没有足够的经费将网络上的共享集线器升级为以太网交换 机，可以使用FreeBSD系统执行网桥任务。这需要使用option BRIDGE编译选项重新定制内核，此后使用bridge命令启动网桥功能。</p>
<p><span style="font-family: courier new,courier,mono;"><a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>采用命令行方式，它的命令格式为：<br />
<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> [ -adeflnNOpqStvx ] [ -c 数量 ] [ -F 文件名 ]<br />
[ -i 网络接口 ] [ -r 文件名] [ -s snaplen ]<br />
[ -T 类型 ] [ -w 文件名 ] [表达式 ]</span></p>
<p><span style="font-family: courier new,courier,mono;"><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a> </span></p>
<p><span style="font-family: courier new,courier,mono;">(1). <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的选项介绍<a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></span></p>
<p>-a 　　　将网络地址和广播地址转变成名字；<br />
-d 　　　将匹配信息包的代码以人们能够理解的汇编格式给出；<br />
-dd 　　 将匹配信息包的代码以c语言程序段的格式给出；<br />
-ddd 　　将匹配信息包的代码以十进制的形式给出；<br />
-e 　　　在输出行打印出数据链路层的头部信息；<br />
-f 　　　将外部的Internet地址以数字的形式打印出来；<br />
-l 　　　使标准输出变为缓冲行形式；<br />
-n 　　　不把网络地址转换成名字；<br />
-t 　　　在输出的每一行不打印时间戳；<br />
-v 　　　输出一个稍微详细的信息，例如在ip包中可以包括ttl和服务类型的信息；<br />
-vv 　　 输出详细的报文信息；<br />
-c 　　　在收到指定的包的数目后，<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>就会停止；<br />
-F 　　　从指定的文件中读取表达式,忽略其它的表达式；<br />
-i 　　　指定监听的网络接口；<br />
-r 　　　从指定的文件中读取包(这些包一般通过-w选项产生)；<br />
-w 　　　直接将包写入文件中，并不分析和打印出来；<br />
-T 　　　将监听到的包直接解释为指定的类型的报文，常见的类型有rpc （远程过程调用）和snmp（简单网络管理协议；）</p>
<p>(2). <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的表达式介绍</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>表达式是一个正则表达式，<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>利用它作为过滤报文的条件，如果一个报文满足表达式的条件，则这个报文将会被捕获。如果没有给出任何条件，则网络上所有的信息包将会被截获。在表达式中一般如下几种类型的关键字。</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>第一种是关于类型的关键字，主要包括host，net，port, 例如 host 210.27.48.2，指明  210.27.48.2是一台主机，net 202.0.0.0 指明 202.0.0.0是一个网络地址，port 23  指明端口号是23。如果没有指定类型，缺省的类型是host.</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>第二种是确定传输方向的关键字，主要包括src , dst ,dst or src, dst and src  ,这些关键字指明了传输的方向。举例说明，src 210.27.48.2 ,指明ip包中源地址是210.27.48.2 , dst net  202.0.0.0 指明目的网络地址是202.0.0.0 。如果没有指明方向关键字，则缺省是src or dst关键字。</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>第三种是协议的关键字，主要包括fddi,ip,arp,rarp,tcp,udp等类型。Fddi指明是在FDDI(分布式光纤数据接口网络)上的特定 的网络协议，实际上它是”ether”的别名，fddi和ether具有类似的源地址和目的地址，所以可以将fddi协议包当作ether的包进行处理和 分析。其他的几个关键字就是指明了监听的包的协议内容。如果没有指定任何协议，则<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>将会监听所有协议的信息包。</p>
<p>除了这三种类型的关键字之外，其他重要的关键字如下：gateway,  broadcast,less,greater,还有三种逻辑运算，取非运算是 &#8216;not &#8216; &#8216;! &#8216;,  与运算是&#8217;and&#8217;,'&amp;&amp;&#8217;;或运算 是&#8217;or&#8217;  ,&#8217;││&#8217;；这些关键字可以组合起来构成强大的组合条件来满足人们的需要，下面举几个例子来说明。</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>A想要截获所有210.27.48.1 的主机收到的和发出的所有的数据包：<br />
#<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> host 210.27.48.1<br />
B想要截获主机210.27.48.1 和主机210.27.48.2 或210.27.48.3的通信，使用命令：（在命令行中适用　　　括号时，一定要<br />
#<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> host 210.27.48.1 and \ (210.27.48.2 or 210.27.48.3 \)<br />
C如果想要获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包，使用命令：<br />
#<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> ip host 210.27.48.1 and ! 210.27.48.2<br />
D如果想要获取主机210.27.48.1接收或发出的telnet包，使用如下命令：<br />
#<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> tcp port 23 host 210.27.48.1</p>
<p>(3). <a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>的输出结果介绍</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>下面我们介绍几种典型的<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a>命令的输出信息</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>A,数据链路层头信息</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>使用命令<br />
#<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> &#8211;e host ice<br />
ice 是一台装有<a href="http://linux.anheng.com/news/24/586.html">linux</a>的主机，她的MAC地址是0：90：27：58：AF：1A<br />
H219是一台装有SOLARIC的SUN工作站，它的MAC地址是8：0：20：79：5B：46；上一条命令的输出结果如下所示：<br />
21:50:12.847509 eth0 &lt; 8:0:20:79:5b:46 0:90:27:58:af:1a ip 60: h219.33357 &gt; ice.telne<br />
t 0:0(0) ack 22535 win 8760 (DF)</p>
<p>分析：21：50：12是显示的时间， 847509是ID号，eth0 &lt;表示从网络接口eth0 接受该数据包，eth0  &gt;表示从网络接口设备发送数据包, 8:0:20:79:5b:46是主机H219的MAC地址,它表明是从源地址H219发来的数据包.  0:90:27:58:af:1a是主机ICE的MAC地址,表示该数据包的目的地址是ICE . ip 是表明该数据包是IP数据包,60  是数据包的长度, h219.33357 &gt; ice.telnet  表明该数据包是从主机H219的33357端口发往主机ICE的TELNET(23)端口. ack 22535  表明对序列号是222535的包进行响应. win 8760表明发送窗口的大小是8760.</p>
<p>B,ARP包的TCPDUMP输出信息</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>使用命令<br />
#<a href="http://tcpdump.anheng.com/news/24/586.html">tcpdump</a> arp<br />
得到的输出结果是：<br />
22:32:42.802509 eth0 &gt; arp who-has route tell ice (0:90:27:58:af:1a)<br />
22:32:42.802902 eth0 &lt; arp reply route is-at 0:90:27:12:10:66 (0:90:27:58:af:1a)<br />
分 析: 22:32:42是时间戳, 802509是ID号, eth0 &gt;表明从主机发出该数据包, arp表明是ARP请求包, who-has  route tell ice表明是主机ICE请求主机ROUTE的MAC地址。 0:90:27:58:af:1a是主机ICE的MAC地址。</p>
<p>C,TCP包的输出信息</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>用TCPDUMP捕获的TCP包的一般输出信息是：<br />
src &gt; dst: flags data-seqno ack window urgent options<br />
src  &gt; dst:表明从源地址到目的地址, flags是TCP包中的标志信息,S 是SYN标志, F (FIN), P (PUSH) , R  (RST) “.” (没有标记); data-seqno是数据包中的数据的顺序号, ack是下次期望的顺序号,  window是接收缓存的窗口大小, urgent表明数据包中是否有紧急指针. Options是选项.</p>
<p>D,UDP包的输出信息</p>
<p><a href="http://anheng.com/news/24/586.html"><span style="color: #eeeeee;">http://anheng.com/news/24/586.html</span></a></p>
<p>用TCPDUMP捕获的UDP包的一般输出信息是：<br />
route.port1 &gt; ice.port2: udp lenth<br />
UDP十分简单，上面的输出行表明从主机ROUTE的port1端口发出的一个UDP数据包到主机ICE的port2端口，类型是UDP， 包的长度是lenth</p>
<p>&nbsp;</p>
<p>原文地址：http://tcpdump.anheng.com.cn/news/24/586.html</h4>
<p>Random Posts</h4>
<ul class="related_post">
<li>2010 年 6 月 13 日 &#8212; <a href="http://www.ads1st.com/ora-600kcbgcur_9-with-fet-table-insert.html" title="ORA-600[kcbgcur_9] With FET$ Table INSERT">ORA-600[kcbgcur_9] With FET$ Table INSERT</a></li>
<li>2010 年 3 月 16 日 &#8212; <a href="http://www.ads1st.com/%e6%9f%90%e5%85%ac%e5%ae%89%e8%ad%a6%e7%bb%bc%e7%b3%bb%e7%bb%9fora-006004097%e9%94%99%e8%af%af%e7%9a%84%e5%a4%84%e7%90%86.html" title="某公安警综系统ORA-00600[4097]错误的处理">某公安警综系统ORA-00600[4097]错误的处理</a></li>
<li>2010 年 6 月 13 日 &#8212; <a href="http://www.ads1st.com/ora-00600-kcbgcur_3-or-ora-600-ktspctb-1-during-update-of-a-partition-table-with-a-lob.html" title="Ora-00600: [Kcbgcur_3] OR Ora-600 [ktspctb-1] during update of a partition table with a LOB">Ora-00600: [Kcbgcur_3] OR Ora-600 [ktspctb-1] during update of a partition table with a LOB</a></li>
<li>2010 年 7 月 20 日 &#8212; <a href="http://www.ads1st.com/can-goldengate-replicate-an-oracle-table-that-contains-only-clob-columns.html" title="Can GoldenGate Replicate An Oracle Table That Contains Only CLOB Column(s)?">Can GoldenGate Replicate An Oracle Table That Contains Only CLOB Column(s)?</a></li>
<li>2010 年 8 月 23 日 &#8212; <a href="http://www.ads1st.com/votedisk-migrate-from-raw-to-asm.html" title="votedisk migrate from raw to asm">votedisk migrate from raw to asm</a></li>
<li>2010 年 6 月 13 日 &#8212; <a href="http://www.ads1st.com/utf8test.html" title="utf8test">utf8test</a></li>
<li>2010 年 8 月 23 日 &#8212; <a href="http://www.ads1st.com/crs-add-nodes.html" title="crs add Nodes">crs add Nodes</a></li>
<li>2010 年 7 月 20 日 &#8212; <a href="http://www.ads1st.com/to-start-manager-from-the-command-line.html" title="To start Manager from the command line">To start Manager from the command line</a></li>
<li>2010 年 7 月 20 日 &#8212; <a href="http://www.ads1st.com/using-unix-batch-and-shell-scripts.html" title="Using UNIX batch and shell scripts">Using UNIX batch and shell scripts</a></li>
<li>2011 年 7 月 21 日 &#8212; <a href="http://www.ads1st.com/shutdown-abort-cause-dictionary-corruption-and-fail-to-open-database.html" title="shutdown abort导致数据字典损坏，数据库无法打开">shutdown abort导致数据字典损坏，数据库无法打开</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ads1st.com/linux-network-analyze-tool-tcpdump.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aix 6L JFS2 Snapshot</title>
		<link>http://www.ads1st.com/aix-6l-jfs2-snapshot.html</link>
		<comments>http://www.ads1st.com/aix-6l-jfs2-snapshot.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 02:52:50 +0000</pubDate>
		<dc:creator>chensq</dc:creator>
				<category><![CDATA[Aix]]></category>
		<category><![CDATA[6l]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[jfs2]]></category>
		<category><![CDATA[snapshot]]></category>

		<guid isPermaLink="false">http://www.ads1st.com/?p=1083</guid>
		<description><![CDATA[<a name="1.1.JFS2 快照功能介绍 &#124;outline">1.JFS2 快照功能介绍 </a>
AIX 中 JFS2 文件系统分区（enhanced journaled file system），是自 AIX  V5.2L  引入的增强的日志[......]<p class='read-more'><a href='http://www.ads1st.com/aix-6l-jfs2-snapshot.html'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><a name="1.1.JFS2 快照功能介绍 |outline">1.JFS2 快照功能介绍 </a></p>
<p>AIX 中 JFS2 文件系统分区（enhanced journaled file system），是自 AIX  V5.2L  引入的增强的日志文件系统分区，相比上一代文件系统分区（JFS），其动态扩展性以及支持的最大文件大小和容量都有较大的提高，并且也增加了一些实用功 能，比如：外部快照。在 AIX 6 中 JFS2  功能得到进一步加强，主要改进有三个方面：内部快照功能，关闭文件系统分区日志，文件系统分区加密。本文将就文件系统分区快照功能做一个简单介绍。</p>
<p>JFS2  文件系统分区快照类似于存储的快照功能，就是将某个时刻的文件系统分区状态和数据保存成一个映像，就像是使用‘相机’将某个时刻的硬盘上的数据状态捕捉下 来。快照功能的主要作用是在于保持各系统文件时间点的一致性。假如我们需要备份一个系统，该系统中有多个文件间的数据具有相关性，并且这些文件经常被读 写。如果采用普通的备份方式的话，由于备份需要较长时间以及文件备份先后顺序的关系，会破坏这多个文件间的数据一致性，导致无效的备份。而使用快照备份方 式就可以避免这一问题。在存储中快照还会被用来做一些远程灾备的异步备份。</p>
<p>JFS2 文件系统分区的快照与存储不同地方在于，它是基于“文件系统块”级别的操作，也就是它只会监控文件系统级的 IO 操作。<br />
<a name="N1007E"><strong>Snapshot 功能示意图 </strong></a><br />
<img src="http://www.ibm.com/developerworks/cn/aix/library/0802_wangrong_snapshot/image002.gif" alt="" width="478" height="360" /></p>
<p><a name="N1008B">JFS2 外置快照（external snapshot）</a></p>
<p>在 AIX V6.1 以前 JFS2 的快照功能需要使用一个额外的 LV  来保存快照镜像，所以也被称之为外置快照。在 AIX V5.2L 以上版本的 JFS2 文件系统都默认支持该功能。保存快照的 LV  可以使用现有的未被使用的 LV，也可以在创建快照时自动创建新的 LV。每个 JFS2 文件系统分区的外置快照数最大支持 15  个；每个快照都需要占用一个 LV。在用户需要查看某一快照内容时，其访问方式类似于文件系统分区，也就是将指定快照 LV 挂载在某一目录下进行访问。</p>
<p><a name="N10094">AIX 6 新功能 JFS2 内置快照（internal snapshot）</a></p>
<p>在 AIX V6.1 上，JFS2  文件系统分区保持了外置快照功能的支持，同时新增加了的内置快照的方式。所谓内置快照，即将所有快照镜像保存在同一 LV 上，不需要使用额外的  LV。最大支持的快照数提高到 64 个。所有快照内容都可以通过 /mountpoint/.snapshot/  这一目录下直接访问，不要再手动挂载。内置快照功能不是默认属性，在创建 JFS2 文件系统分区时需要特别声明。原有的 JFS2  文件系统分区想升级支持内置快照，需要先删除然后重新创建。</p>
<p><a name="N1009D"> 内置快照的优势 </a></p>
<p>通过实现快照的“内置”，大大降低了快照功能的复杂性，相应的也提高了其可管理性。总得来说内置有下面几个主要的优势。</p>
<ul>
<li> 访问快照不再需要使用 root 账户。由于不需要使用 root 权限挂载快照 LV，所以普通用户也可以依照原有权限去访问快照内容。</li>
<li> 管理更简单，更易操作。使用内部空间保存快照，无需管理额外的快照 LV，也减少了访问快照的相关操作。</li>
<li> 通过 NFS 共享快照内容更方便，快照与文件系统分区在同一个挂载目录 （mount point）下可以一同 export 给用户。</li>
</ul>
<p><a href="http://www.ibm.com/developerworks/cn/aix/library/0802_wangrong_snapshot/#ibm-pcon">回页首</a></p>
<p><a name="2.2.JFS2 快照的基本操作命令 |outline">2.JFS2 快照的基本操作命令 </a></p>
<p>下面将介绍使用 snapshot 的基本命令参数。在 AIX 中，快照的相关操作都是同过 snapshot 这个命令来完成的。</p>
<p><a name="N100BB"> 外置快照（external snapshot）</a></p>
<p><strong> 创建一个外置的快照 </strong></p>
<p>在 AIX V5.2L 以后我们可以为任意现有的 JFS2 文件系统分区创建一个外置的快照</p>
<p>例如：为根目录（/）创建一个快照。通过 -o snapfrom 参数指定被快照的系统分区对象， -o size 指定创建的快照 LV 的大小。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -o snapfrom=/ -o size=128M
Snapshot for file system / created on /dev/fslv04</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>我们先通过 snapfrom 指定快照的对象，然后通过 size 参数指定自动生成的快照 lv 的大小。自动生成的 lv 名称是 fslv04。</p>
<p>我们还可以通过利用现有 lv 来创建快照。例如已有一个闲置的 lv fslv04。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -o snapfrom=/ /dev/fslv04
Snapshot for file system / created on /dev/fslv04</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong> 查询快照状态 </strong><br />
我们可以通过 -q 参数查询当前快照状态及剩余空间大小，当 Free 的块太少时，我们可以用–o size 参数改变快照的空间大小。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -q /
Snapshots for /
Current Location 512-blocks Free Time
* /dev/fslv04 65536 58112 Fri Jan 4 22:49:59 2008</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong> 挂载快照 </strong></p>
<p>我们将快照 fslv00 mount 在 /mnt 目录下，并查看其内容。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># mount -o snapshot /dev/fslv00 /mnt/* 挂载快照 */
# ls /mnt/* 列出快照内容 */
.SPOT dev smit.log
.image.data.removetag etc smit.script
.profile export smit.transaction
.rhosts home test
.rhosts.nim lib tftpboot
.rhosts.prev lost+found tmp
.sh_history lpp u
.snapshot mnt unix
.vi_history opt usr
admin pconsole var
audit proc
bin sbin</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong> 删除快照 </strong></p>
<p>我们为根目录创建了 2 个快照，我们已经不需要 fslv00  这个快照，我们可以通过以下命令删除，删除前请检查是否已经 umount  该快照。注意：在删除操作时，如果要删除某一时间点的快照，那么该时间点之前的快照都将自动移除，比如我们删除 fslv04 这个快照，那么  fslv00 也将自动移除。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -d /dev/fslv00
rmlv: Logical volume fslv00 is removed.</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><a name="N10106"> 内置快照（internal snapshot）</a></p>
<p><strong> 创建一个内置快照 </strong></p>
<p>内置快照与外置不同，不需要使用 lv  设备保存快照信息，所以命令的参数也略有不同。内置快照使用快照名来定义每一个快照。内置快照功能需要在创建文件系统分区的时候申明，否则默认不支持，并 且也无法通过 chfs 直接打开该功能，需要删除并重新创建文件系统分区。创建内置快照的命令参数需要通过 -n 来制定一个快照名，无需创建快照  LV。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># mkdir /tmp/test/* 创建文件分区挂载点 */
# crfs -v jfs2 -m /tmp/test -a isnapshot=yes -a size=256M -g rootvg
File system created successfully./* 创建新的分区 . 并打开 snapshot 功能 */
261932 kilobytes total disk space.
New File System size is 524288
# mount /tmp/test/* 挂载新创建的分区 */
# echo "this's snapshot one" &gt; /tmp/test/data /* 创建一个数据文件 , 用来校验快照功能 */
# snapshot -o snapfrom=/tmp/test -n snapshot00/* 创建一个快照 , 快照名为 snapshot00 */
Snapshot for file system /tmp/test created on snapshot00</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong> 查看内置快照状态 </strong></p>
<p>内置快照状态查询方式与外置快照相同，不同的是，内置快照不会显示可用的快照空间，这是因为内置快照使用的是文件系统分区内的资源空间。查看快照可用空间 与查看分区相同使用 df 命令。当文件系统分区空间不足时，该分区的快照信息将自动全部删除，并在错误日志里添加一条记录。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -q /tmp/test
Snapshots for /tmp/test
Current Name Time
* snapshot00 Fri Jan 4 20:29:18 2008</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong> 访问快照文件内容 </strong></p>
<p>内置快照可以实时的在挂载点的 ./.snapshot 目录下查看，该目录处于隐藏状态。通过 ls，find 等命令都无法列出该快照下的内容信息。在 .snapshot 目录下各个快照保存在不同的目录下，目录名同快照名。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># ls -al
total 16
drwxr-xr-x 3 root system 256 Jan 4 20:27 .
drwxrwxrwt 10 bin bin 4096 Jan 4 20:25 ..
-rw-r--r-- 1 root system 20 Jan 4 20:27 data
drwxr-xr-x 2 root system 256 Jan 4 20:22 lost+found
# rm data/* 删除数据文件 */
# cd /tmp/test/.snapshot/* 进入快照目录 */
# ls/* 列出快照 */
snapshot00
# cat snapshot00/data/* 显示’已删除的数据内容’ */
this's snapshot one
#</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>删除内置快照</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -d -n snapshot00 /tmp/test
# snapshot -q /tmp/test
/tmp/test has no snapshots.</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><a href="http://www.ibm.com/developerworks/cn/aix/library/0802_wangrong_snapshot/#ibm-pcon">回页首</a></p>
<p><a name="3.3.JFS2 快照应用 |outline">3.JFS2 快照应用 </a></p>
<p>下面我们将介绍两个快照在实际应用中的例子。Snapshot 功能最普遍的应用还是在于数据的备份，另外也可以根据其快照（point in time） 的特性用来监控文件内容的变化，我们在第二个例子中就采用快照来追踪系统中重要的配置文件的变更。</p>
<p><a name="N10147"> 使用快照备份系统 </a></p>
<p>使用快照备份系统最常见的步骤就是，先创建一个快照，然后使用备份工具或备份命令来备份数据。AIX 提供了一个快捷的备份命令 Backsnap 将这两个步骤合二为一。Backsnap 可以看成是 snapshot 和 backup 两个命令的结合。</p>
<p><strong> 内置快照的备份 </strong></p>
<p>先创建一个快照名 snapshotback，备份完，仍保留该快照。下面我们通过一个例子来介绍 backsnap  的使用，我们将备份挂载在 /tmp/lv 的一个文件分区。我们通过 -n 参数指定将要创建的快照的名称，通过 -f 参数指定备份的位置，通过  -f 可以指定一个文件名，也就是备份到文件，还可以指定一个设备名，将系统备份到设备（如磁带机–f /dev/rmt0）</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># backsnap -n snapshotback -f/tmp/test.bak /tmp/test
Snapshot for file system /tmp/test created on snapshotback
backup: Date of this level 9 backup: Fri Jan 4 21:19:43 2008
backup: Date of last level 0 backup: the epoch
backup: Backing up /tmp/test/.snapshot/snapshotback (/tmp/test) to /tmp/test.bak
backup: File system still mounted, inconsistent data possible
backup: Mapping (Pass I) [regular files]
backup: Mapping (Pass II) [directories]
backup: estimated 49 1k blocks.
backup: Backing up (Pass III) [directories]
backup: Backing up (Pass IV) [regular files]
backup: 52 1k blocks on 1 volume(s)
backup: Backup is complete
#</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong> 外置快照的备份 </strong></p>
<p>我们先创建一个快照，将根分区备份到 /tmp/root.bak, 加上 -R 参数备份后删除快照。使用外置快照备份，我们需要指定外置快照 LV 的大小和挂载位置，分别用 -m 和 -s 来制定。-f 参数定义同内置快照。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># backsnap -R -m /mnt -s size=32M -f /tmp/root.bak /
Snapshot for file system / created on /dev/fslv05
backup: Date of this level 9 backup: Fri Jan 4 21:23:01 2008
backup: Date of last level 0 backup: the epoch
backup: Backing up /dev/rfslv05 to /tmp/root.bak
backup: Mapping (Pass I) [regular files]
backup: Mapping (Pass II) [directories]
backup: estimated 128315 1k blocks.
backup: Backing up (Pass III) [directories]
backup: Backing up (Pass IV) [regular files]
backup: 127982 1k blocks on 1 volume(s)
backup: Backup is complete
rmlv: Logical volume fslv04 is removed.
rmlv: Logical volume fslv05 is removed.
#</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><a name="N1016C"> 使用快照监控系统安全 </a></p>
<p>快照功能就是将某一文件分区的某一时刻的文件信息状态保存下来。我们可以利用这一功能来监控系统配置文件的状态与内容。系统中的配置文件一般都是放在  /etc 目录下，我们在安装配置好服务器后，可以通过创建一个 /etc  目录的快照来保存的系统配置信息。在系统发生异常或系统配置文件被误改时，可以用来快速的修复系统，以及监控系统状态的改变。</p>
<p><strong> 创建文件系统快照 </strong></p>
<p>因为 /etc 目录并没有保存在独立的 lv 下，而是放在根目录的空间里，所以我们要首先创建根目录的快照镜像，并将快照挂载到 /mnt 目录下面。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># snapshot -o snapfrom=/ -o size=128m
Snapshot for file system / created on /dev/fslv04
# mount -o snapshot /dev/fslv04 /mnt</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>接下来我们可以手动的比较 /etc 和 /mnt/etc 目录下的相对应的文件有何异同，也可以使用 diff  命令来对比整个目录文件。比如 diff –r /etc /mnt/etc 2&gt;/dev/null。使用 diff 命令简单快捷，但是因为  /etc 目录下还保存有一些二进制文件并经常改变，使用 diff 命令将会在屏幕输出很多乱码，不方便识别。我在下面写了一个简单 perl  脚本用来识别文本配置文件，然后再进行比对。脚本如下：</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># cat diff.sh
#!/usr/bin/perl
# 执行方法 ./ diff.sh DIR1 DIR2 该脚本将比较 DIR1 与 DIR2 目录中的同名文件异同。
# 检查输入的目录名 DIR1 与 DIR2 是否存在，如不存在立即退出。
-e $ARGV[0] || die "Warning,Directory $ARGV[0] doesn't exist\n";
-e $ARGV[1] || die "Warning,Directory $ARGV[1] doesn't exist\n";
# 将 DIR1 目录中的所有文件通过 find 命令列出到文件，并作为文件方式打开。
open CONFIG,"find $ARGV[0] |";
# 依次从 CONFIG 文件读取出各文件名（包括路径）
foreach (&lt;CONFIG&gt;) {
 chomp;
# 通过 file 命令检查该文件的属性，是否是文本文件。
 $type=`file $_`;
 if ((!( $type =~ /data/i) &amp;&amp; $type =~ /text/i)|| $type =~ /shell/i )
{
 $base=length($ARGV[0]);
 $extend=substr($_,$base);
 $extend=$ARGV[1] . $extend;
# 通过 diff 命令分析文件内容差异并输出到屏幕。
 $diffs=`diff -c $_ $extend`;
 		 if ( $? != 0 &amp;&amp; $diffs ne '' )
 {
 print "$diffs \n";
 }
 }
}</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>我们使用该脚本来做一些测试，因为我们刚创建的快照，所有快照内容与原目录内容是一致的，diff.sh 将不会有任何输出。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># ./diff.sh /etc /mnt/etc
#</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>下面我们改变 /etc/hosts 文件中的信息，再重新对比一次。文件的对比实际上还是调用 diff 命令，所以输出格式也是依照 diff 命令的输出风格。</p>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<td>
<pre># echo "192.168.21.100 vios" &gt;&gt; /etc/hosts /* 在 /etc/hosts 文件中插入一条信息 */
# ./diff.sh /mnt/etc /etc
*** /mnt/etc/hosts Sat Dec 29 17:53:58 2007
--- /etc/hosts Fri Jan 4 22:29:55 2008
***************
*** 54,56 ****
--- 54,57 ----
 192.168.21.130 AIX01
 192.168.21.136 aixjs21
 192.168.21.134 aix6lpar aix6
+ 192.168.21.100 vios/* 对比发现在当前 hosts 文件中增加了一条记录 */
#</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>在 AIX 系统中有些服务进程的 PID 文件也是放在 /etc 目录下，而且也是保存成文本文件，所以如果某一服务进程中断或者被重启，我们也将能够监控得到。我们下面再做一些测试。</p>
<p># cp /mnt/etc/hosts /etc/hosts /* 恢复 hosts 文件 */</p>
<p># vi /etc/hosts 							/* 编辑 hosts 文件，删掉最后一条记录 */</p>
<p># rm /etc/motd							/* 删除一个配置文件 */</p>
<p># stopsrc -s syslogd						/* 关闭然后重启 syslogd 服务 */</p>
<p>0513-044 The syslogd Subsystem was requested to stop.</p>
<p># startsrc -s syslogd</p>
<p>0513-059 The syslogd Subsystem has been started. Subsystem PID is 200810.</p>
<p># ./diff.sh /mnt/etc /etc/* 执行 diff.sh */</p>
<p>*** /mnt/etc/hosts Fri Jan 4 22:29:55 2008</p>
<p>&#8212; /etc/hosts Fri Jan 4 23:13:18 2008</p>
<p>***************</p>
<p>*** 53,56 ****</p>
<p>192.168.7.63 js20a1</p>
<p>192.168.21.130 AIX01</p>
<p>192.168.21.136 aixjs21</p>
<p>- 192.168.21.134 aix6lpar aix6				/* 发现 hosts 被修改 */</p>
<p>&#8212; 53,55 &#8212;-</p>
<p>diff: /etc/motd: No such file or directory				/* 发现有被删除文件 */</p>
<p>*** /mnt/etc/syslog.pid Sat Dec 29 17:42:42 2007		/* 发现服务进程 ID 号改变 */</p>
<p>&#8212; /etc/syslog.pid Fri Jan 4 23:17:22 2008</p>
<p>***************</p>
<p>*** 1 ****</p>
<p>! 200808</p>
<p>&#8212; 1 &#8212;-</p>
<p>! 200810</p>
<p>我们可以看到，通过快照功能加上一些文件内容比较工具—（文中提供的脚本提供的功能并不十分完善 , 可按需自行修改），我们能够很好的监控到系统配置文件是否变更和删除，一方面能快速定位问题，另一方面也能够为快速修复系统提供帮助。</p>
<p><a href="http://www.ibm.com/developerworks/cn/aix/library/0802_wangrong_snapshot/#ibm-pcon">回页首</a></p>
<p><a name="4.4. 使用快照的一些注意事项 |outline">4. 使用快照的一些注意事项 </a></p>
<ul>
<li> 支持了内置快照的文件系统分区仍然可以使用外置快照，但是这两种功能是互斥的，同时只能使用某一种快照方式。</li>
<li> 在创建文件系统分区时可以设定是否支持内置快照，一经设定无法更改。</li>
<li> 如果 fsck 命令检测到错误，必须修改文件系统，那么快照将被 fsck 删除。</li>
<li> 创建了快照的文件系统不能动态缩小。</li>
<li> 在支持内置快照的文件系统分区无法执行 Defragfs，也不建议在创建了外置快照的分区执行 defragfs。</li>
<li> 一般快照会占用原文件分区 2-6% 的空间大小，一些较活跃的分区可能会达到 15%。</li>
<li> 快照映像只允许读，不可以写。</li>
<li> 在创建了快照的文件系统分区中，写操作将受到一定性能影响，但是对读操作没有影响。</li>
<li> 快照空间不够时，所有快照将会被自动删除。</li>
</ul>
<p><a href="http://www.ibm.com/developerworks/cn/aix/library/0802_wangrong_snapshot/#ibm-pcon">回页首</a></p>
<p><a name="5. 总结 |outline"> 总结 </a></p>
<p>总的来说，在 AIX  中提供的文件系统快照功能非常简单易用。无需加装额外的软件，所有功能都能通过一个命令完成。提供了两种不同的快照方式，适用不同的客户环境与需求。同 时，AIX  快照功能也能降低用户的成本。此功能已足够满足客户的一般备份需求，无需为了使用快照功能而使用存储设备，或可以减免存储快照功能的许可费用。另外，在快 照的使用上，AIX 文件系统级的快照也要比存储的快照方便的多。</p>
<p>&nbsp;</p>
<p>原文地址：http://www.ibm.com/developerworks/cn/aix/library/0802_wangrong_snapshot/</h4>
<p>Related Posts</h4>
<ul class="related_post">
<li>2010 年 8 月 24 日 &#8212; <a href="http://www.ads1st.com/snapshot-acfs-filesystem.html" title="snapshot acfs filesystem">snapshot acfs filesystem</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ads1st.com/aix-6l-jfs2-snapshot.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aix下的LTG</title>
		<link>http://www.ads1st.com/ltg-on-aix.html</link>
		<comments>http://www.ads1st.com/ltg-on-aix.html#comments</comments>
		<pubDate>Tue, 30 Aug 2011 08:03:28 +0000</pubDate>
		<dc:creator>chensq</dc:creator>
				<category><![CDATA[Aix]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[Truble shooting]]></category>
		<category><![CDATA[lquerypv]]></category>
		<category><![CDATA[lsvg]]></category>
		<category><![CDATA[LTG]]></category>

		<guid isPermaLink="false">http://www.ads1st.com/?p=1079</guid>
		<description><![CDATA[LTG是Logical Track  Group的缩写，它表示硬盘所允许的最大I/O传输值。不同的硬盘具有不同的LTG值，代表不同的I/O吞吐能力。在AIX 5L  之前，操作[......]<p class='read-more'><a href='http://www.ads1st.com/ltg-on-aix.html'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>LTG是Logical Track  Group的缩写，它表示硬盘所允许的最大I/O传输值。不同的硬盘具有不同的LTG值，代表不同的I/O吞吐能力。在AIX 5L  之前，操作系统只支持128KB的LTG值(这也是AIX 5L默认的LTG值)。AIX 5L  现在可以支持128KB，256KB，512KB和1024KB  的LTG值。因此，为了最大限度的发挥硬盘的I/O吞吐能力，我们有必要选择合适的LTG值。</p>
<p>在选择合适的LTG值之前，首先需要确定硬盘所支持的最大LTG值。<br />
用命令 “lquerypv -M hdiskn”（其中， n表示hdisk的号）可以获得硬盘所支持的最大LTG值。</p>
<blockquote><p>OASRV2_p550:/#lspv<br />
hdisk0          00c4a63f8370cf62                    rootvg          active<br />
hdisk1          00c8e65b6c3c027e                    rootvg          active<br />
hdisk2          00c3efab20989aa8                    oravg           concurrent<br />
hdisk3          00c3efab20989d06                    oravg           concurrent<br />
hdisk4          00c3efab20989f6d                    oravg           concurrent<br />
hdisk5          00c3efab2098a197                    oravg           concurrent<br />
hdisk6          00c3efab2098a331                    oravg           concurrent<br />
hdisk7          00c3efab2098a438                    oravg           concurrent<br />
hdisk8          00c3efab2098a53f                    oravg           concurrent<br />
hdisk9          00c3ef1b0e6f9fb2                    appnewvg<br />
hdisk10         00c3ef1b0e6fe002                    appnewvg<br />
hdisk11         00c3ef1b0e71cbec                    appnewvg<br />
hdisk12         00c3ef1b0e71ce1a                    appnewvg<br />
hdisk13         00c3ef1b0e71cfdb                    appnewvg<br />
hdisk14         00c3ef1b0e71d17c                    appnewvg<br />
hdisk15         00c3ef1b0e71d32d                    appnewvg<br />
hdisk16         00c3ef1b0e71d589                    appnewvg<br />
hdisk17         00c3ef1b0e71d778                    appnewvg<br />
hdisk18         00c3ef1b0e71d963                    appnewvg<br />
hdisk19         00c3ef1b0e71db16                    appnewvg<br />
hdisk20         00c3ef1b0e71dcc4                    appnewvg<br />
hdisk21         00c3ef1b0e720530                    appnewvg<br />
OASRV2_p550:/#lquerypv -M hdisk0<br />
<span style="color: #ff0000;">256</span><br />
OASRV2_p550:/#lsvg rootvg<br />
VOLUME GROUP:       rootvg                   VG IDENTIFIER:  00c3eedb00004c000000010a1bd0a904<br />
VG STATE:           active                   PP SIZE:        256 megabyte(s)<br />
VG PERMISSION:      read/write               TOTAL PPs:      1092 (279552 megabytes)<br />
MAX LVs:            256                      FREE PPs:       518 (132608 megabytes)<br />
LVs:                12                       USED PPs:       574 (146944 megabytes)<br />
OPEN LVs:           11                       QUORUM:         1<br />
TOTAL PVs:          2                        VG DESCRIPTORS: 3<br />
STALE PVs:          0                        STALE PPs:      0<br />
ACTIVE PVs:         2                        AUTO ON:        yes<br />
MAX PPs per VG:     32512<br />
MAX PPs per PV:     1016                     MAX PVs:        32<br />
<span style="color: #ff0000;">LTG size (Dynamic): 256 kilobyte(s) </span> AUTO SYNC:      no<br />
HOT SPARE:          no                       BB POLICY:      relocatable</p>
<p>OASRV2_p550:/#lsvg<br />
rootvg<br />
oravg<br />
appnewvg<br />
OASRV2_p550:/#lsvg oravg<br />
VOLUME GROUP:       oravg                    VG IDENTIFIER:  00c3efab00004c000000010a2098be93<br />
VG STATE:           active                   PP SIZE:        128 megabyte(s)<br />
VG PERMISSION:      read/write               TOTAL PPs:      2793 (357504 megabytes)<br />
MAX LVs:            512                      FREE PPs:       0 (0 megabytes)<br />
LVs:                43                       USED PPs:       2793 (357504 megabytes)<br />
OPEN LVs:           33                       QUORUM:         4<br />
TOTAL PVs:          7                        VG DESCRIPTORS: 7<br />
STALE PVs:          0                        STALE PPs:      0<br />
ACTIVE PVs:         7                        AUTO ON:        no<br />
Concurrent:         Enhanced-Capable         Auto-Concurrent: Disabled<br />
VG Mode:            Concurrent<br />
Node ID:        2                        Active Nodes:   1<br />
MAX PPs per VG:     130048<br />
MAX PPs per PV:     1016                     MAX PVs:        128<br />
<span style="color: #ff0000;">LTG size (Dynamic): 1024 kilobyte(s)</span> AUTO SYNC:      no<br />
HOT SPARE:          no                       BB POLICY:      relocatable<br />
OASRV2_p550:/#lsvg -p oravg<br />
oravg:<br />
PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION<br />
hdisk2            active            399         0           00..00..00..00..00<br />
hdisk3            active            399         0           00..00..00..00..00<br />
hdisk4            active            399         0           00..00..00..00..00<br />
hdisk5            active            399         0           00..00..00..00..00<br />
hdisk6            active            399         0           00..00..00..00..00<br />
hdisk7            active            399         0           00..00..00..00..00<br />
hdisk8            active            399         0           00..00..00..00..00<br />
OASRV2_p550:/#lquerypv -M hdisk2<br />
<span style="color: #ff0000;">1024</span><br />
OASRV2_p550:/#lquerypv -M hdisk3<br />
<span style="color: #ff0000;">1024</span><br />
OASRV2_p550:/#lquerypv -M hdisk4<br />
<span style="color: #ff0000;">1024</span><br />
OASRV2_p550:/#lquerypv -M hdisk5<br />
<span style="color: #ff0000;">1024</span><br />
OASRV2_p550:/#lquerypv -M hdisk6<br />
<span style="color: #ff0000;">1024</span><br />
OASRV2_p550:/#lquerypv -M hdisk7<br />
<span style="color: #ff0000;">1024</span><br />
OASRV2_p550:/#lquerypv -M hdisk8<br />
<span style="color: #ff0000;">1024</span></p></blockquote>
<p>对于已经创建的卷组，可以通过命令 “chvg -Ln datavg”来修改LTG值(命令中的“n”用新的LTG的值替换）。然后用“lsvg datavg”就可以看到修改的结果了。<br />
注意：<br />
1.如果卷组中有多块硬盘，在创建卷组时以最小的硬盘LTG值为准。<br />
2.在用 chvg 改变LTG值时，卷组中所有的文件系统必须 UNMOUNT 掉，所有的逻辑卷都要关闭，否则不能改变LTG值</h4>
<p>Random Posts</h4>
<ul class="related_post">
<li>2007 年 9 月 29 日 &#8212; <a href="http://www.ads1st.com/%e6%9f%90%e8%81%94%e9%80%9a%e8%ae%a1%e8%b4%b9%e7%b3%bb%e7%bb%9f%e5%88%a0%e9%99%a4%e7%ba%bf%e6%97%a5%e5%bf%97%e7%9a%84%e6%81%a2%e5%a4%8d.html" title="某联通计费系统删除在线日志的恢复">某联通计费系统删除在线日志的恢复</a></li>
<li>2010 年 8 月 24 日 &#8212; <a href="http://www.ads1st.com/snapshot-acfs-filesystem.html" title="snapshot acfs filesystem">snapshot acfs filesystem</a></li>
<li>2011 年 2 月 11 日 &#8212; <a href="http://www.ads1st.com/11-2-dictionary.html" title="11.2 Dictionary">11.2 Dictionary</a></li>
<li>2010 年 7 月 8 日 &#8212; <a href="http://www.ads1st.com/goldengate-%e4%b8%8eoracle%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%9e%e6%8e%a5.html" title="Goldengate 与Oracle数据库连接">Goldengate 与Oracle数据库连接</a></li>
<li>2011 年 4 月 6 日 &#8212; <a href="http://www.ads1st.com/international-cheat.html" title="international cheat">international cheat</a></li>
<li>2009 年 11 月 20 日 &#8212; <a href="http://www.ads1st.com/shrinking-database-segments-online.html" title="Shrinking Database Segments Online">Shrinking Database Segments Online</a></li>
<li>2010 年 6 月 7 日 &#8212; <a href="http://www.ads1st.com/tuexedo-simpapp%e9%83%a8%e7%bd%b2.html" title="Tuexedo simpapp部署">Tuexedo simpapp部署</a></li>
<li>2011 年 7 月 27 日 &#8212; <a href="http://www.ads1st.com/ora-15024-occur-on-linux-server-using-raw-device-as-asm-disks-when-clustered.html" title="Linux双机使用裸设置做ASM磁盘时报ORA-15024错误">Linux双机使用裸设置做ASM磁盘时报ORA-15024错误</a></li>
<li>2009 年 10 月 17 日 &#8212; <a href="http://www.ads1st.com/oracle11g-%e4%b8%8b%e7%bc%96%e8%af%91bbed.html" title="Oracle11g 下编译BBED">Oracle11g 下编译BBED</a></li>
<li>2011 年 4 月 12 日 &#8212; <a href="http://www.ads1st.com/trace-dumping-frequently-in-bdump.html" title="Trace dumping frequently in bdump">Trace dumping frequently in bdump</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ads1st.com/ltg-on-aix.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

