<?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>TQ 试用 WP</title>
	<atom:link href="http://tq.freehostia.com.freehostia.com/feed" rel="self" type="application/rss+xml" />
	<link>http://tq.freehostia.com.freehostia.com</link>
	<description>TQ 试用中... ...</description>
	<lastBuildDate>Fri, 19 Mar 2010 06:07:08 +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>Orange Crush 20LDX</title>
		<link>http://tq.freehostia.com.freehostia.com/2010/03/orange-crush-20ldx.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2010/03/orange-crush-20ldx.html#comments</comments>
		<pubDate>Fri, 19 Mar 2010 06:07:08 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[MY 默认分类]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/?p=244</guid>
		<description><![CDATA[YOUKU视频
Orange Crush 20LDX
http://player.youku.com/player.php/sid/XMTU4NjQ4OTgw/v.swf
——

YOUKU视频... ]]></description>
			<content:encoded><![CDATA[<p>YOUKU视频<br />
Orange Crush 20LDX<br />
http://player.youku.com/player.php/sid/XMTU4NjQ4OTgw/v.swf<br />
——<br />
<embed src="http://player.youku.com/player.php/sid/XMTU4NjQ4OTgw/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed></p>
<p>YOUKU视频</p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2010/03/orange-crush-20ldx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>test 视频</title>
		<link>http://tq.freehostia.com.freehostia.com/2010/03/test-%e8%a7%86%e9%a2%91.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2010/03/test-%e8%a7%86%e9%a2%91.html#comments</comments>
		<pubDate>Fri, 19 Mar 2010 05:55:55 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[MY 默认分类]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/?p=238</guid>
		<description><![CDATA[test 视频

test 视频... ]]></description>
			<content:encoded><![CDATA[<p>test 视频<br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/ftXfLkDsxAI&#038;hl=zh_CN&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ftXfLkDsxAI&#038;hl=zh_CN&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object><br />
test 视频</p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2010/03/test-%e8%a7%86%e9%a2%91.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>高可用集群&#8212;&#8212;HA</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/%e9%ab%98%e5%8f%af%e7%94%a8%e9%9b%86%e7%be%a4ha.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/%e9%ab%98%e5%8f%af%e7%94%a8%e9%9b%86%e7%be%a4ha.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 08:19:00 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Performance_Tuning]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/10/%e9%ab%98%e5%8f%af%e7%94%a8%e9%9b%86%e7%be%a4ha.html</guid>
		<description><![CDATA[高可用集群——HA
2008年3月10日
当日小结：
 掌握使用heartbeat对Director做高可用集群HA（High Availability）。

“数据源”和“单一故障点（SOPE）”需要做HA集群。 
HA方式：（三种）
主从方式HA：
... ]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>高可用集群——HA</strong></p>
<p>2008年3月10日</p>
<p><strong>当日小结：</strong></p>
<p><strong> </strong><strong>掌握使用heartbeat对Director做高可用集群HA（High Availability）。</strong></p>
<p><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image0012.gif"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="clip_image001" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image001_thumb2.gif" border="0" alt="clip_image001" width="520" height="234" /></a></p>
<p><strong>“数据源”和“单一故障点（</strong><strong>SOPE</strong><strong>）”需要做</strong><strong>HA</strong><strong>集群。</strong><strong> </strong></p>
<p><strong>HA</strong><strong>方式：（三种）</strong></p>
<p><strong><span style="text-decoration: underline;">主从方式HA：</span></strong></p>
<p><strong><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image0021.gif"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="clip_image002" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image002_thumb1.gif" border="0" alt="clip_image002" width="516" height="232" /></a></strong><strong> </strong></p>
<p><strong>主从方式</strong><strong>HA</strong><strong>：从服务平时不运行。只有当主服务</strong><strong>DOWN</strong><strong>掉时，从服务才马上启用。</strong><strong> </strong></p>
<p><strong> </strong></p>
<p><strong><span style="text-decoration: underline;">对称方式HA：</span></strong></p>
<p><strong><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image003.gif"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="clip_image003" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image003_thumb.gif" border="0" alt="clip_image003" width="454" height="136" /></a></strong><strong> </strong></p>
<p><strong>现在，一般的陈列柜都有双控制器，可以有来个服务同时进行读写。</strong><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong><span style="text-decoration: underline;">集群方式HA：</span></strong></p>
<p><strong><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image004.gif"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="clip_image004" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image004_thumb.gif" border="0" alt="clip_image004" width="472" height="201" /></a></strong><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> <span id="more-235"></span></strong></p>
<p><strong>安装heartbeat：</strong></p>
<p><strong>＃</strong><strong>rpm -ivh *.rpm &#8211;force &#8211;nodeps</strong></p>
<p><strong> </strong></p>
<p><strong>＃</strong><strong>cp /usr/share/doc/heart-2.1.2/ha.cf /etc/ha.d/ </strong><strong>＃</strong><strong>主配置文件。</strong><strong> </strong></p>
<p><strong>＃</strong><strong>cp /usr/share/doc/heart-2.1.2/haresources /etc/ha.d/ </strong><strong>＃</strong><strong>切换配置文件。</strong><strong> </strong></p>
<p><strong>＃</strong><strong>cp /usr/share/doc/heart-2.1.2/authkeys /etc/ha.d/ </strong><strong>＃</strong><strong>认证文件。</strong><strong> </strong></p>
<p><strong>＃</strong><strong>cp /usr/share/doc/heartbeat-ldirectord2.1.2/ldirectord.cf /etc/ha.d/ </strong></p>
<p><strong>＃</strong><strong>查看</strong><strong>real server</strong><strong>是否正常工作的文件。</strong><strong></strong></p>
<p><strong></strong> </p>
<p><strong>Director</strong><strong>的</strong><strong>HA</strong><strong>集群：</strong><strong></strong></p>
<p><strong><span style="text-decoration: underline;">主Director：</span></strong></p>
<p><strong>/etc/ha.d/ha.cf </strong><strong>＃</strong><strong>主配置文件</strong><strong></strong></p>
<p><strong>写：</strong><strong>debugfile /var/log/ha-debug</strong></p>
<p><strong>logfile /var/log/ha-log</strong></p>
<p><strong>logfacility local0</strong></p>
<p><strong>keepalive 2 </strong><strong>＃</strong><strong>一分钟内进行</strong><strong>2</strong><strong>秒心跳。</strong><strong></strong></p>
<p><strong>deadtime 10 </strong><strong>＃</strong><strong>10</strong><strong>秒没心跳为“死心跳”。</strong><strong></strong></p>
<p><strong>warntime 6 </strong><strong>＃</strong><strong>6</strong><strong>秒没心跳，就警告。</strong><strong></strong></p>
<p><strong>initdead 120 </strong><strong>＃</strong><strong>开机</strong><strong>120</strong><strong>秒“死心跳”。</strong><strong></strong></p>
<p><strong>udpport 694 </strong><strong>＃</strong><strong>网卡心跳。用</strong><strong>UDP</strong><strong>：</strong><strong>694</strong><strong>端口。</strong><strong></strong></p>
<p><strong>#band 19200 </strong><strong>＃</strong><strong>波特率，串口心跳。</strong><strong></strong></p>
<p><strong>#serial /dev/ttyS0 </strong><strong>＃</strong><strong>linux</strong><strong>的串口设备。</strong><strong></strong></p>
<p><strong>#bcast eth0 </strong><strong>＃</strong><strong>广播心跳。</strong><strong></strong></p>
<p><strong>#mcast eth0 225.0.0.1 694 1 0 </strong><strong>＃</strong><strong>组播心跳。</strong><strong></strong></p>
<p><strong>#ucast eth0 <span style="text-decoration: underline;">192.168.0.68</span> </strong><strong>＃</strong><strong>UDP </strong><strong>点到点通信。<span style="text-decoration: underline;">设对方</span></strong><strong><span style="text-decoration: underline;">IP</span></strong><strong>。</strong><strong></strong></p>
<p><strong>auto_failback on </strong><strong>＃</strong><strong>on</strong><strong>：从<span style="text-decoration: underline;">从服务器</span>再切换回<span style="text-decoration: underline;">主服务器</span>。</strong><strong></strong></p>
<p><strong></strong><strong>＃</strong><strong>off</strong><strong>：主服务器</strong><strong>DOWN</strong><strong>掉→从服务器启动，主服务器</strong><strong>UP</strong><strong>了，不自动切换回主服务器，还是由从服务器运行。</strong><strong></strong></p>
<p><strong>#stonith baytech /etc/ha.d/conf/stonith.baytech</strong></p>
<p><strong>#stonith_host * baytech 10.0.0.3 mylogin mysecretpassword</strong></p>
<p><strong></strong><strong>＃</strong><strong>设置可编程电源控制器</strong><strong></strong></p>
<p><strong>watchdog /dev/watchdog </strong><strong>＃</strong><strong>软看门狗，要＃</strong><strong>modprobe softdog</strong><strong></strong></p>
<p><strong>node tq.com </strong><strong>＃</strong><strong>必须用主机名。写在前为主</strong><strong>Server</strong><strong>，写在后为从</strong><strong>Server</strong><strong>。</strong><strong></strong></p>
<p><strong>node cz.com </strong><strong>＃</strong><strong>要在</strong><strong>/etc/hosts</strong><strong>文件中对应</strong><strong>IP</strong><strong>。写：</strong><strong>192.168.0.66 tq.com</strong></p>
<p><strong>192.168.0.168 cz.com</strong></p>
<p><strong>ping 192.168.0.68 </strong><strong>＃</strong><strong>仲裁</strong><strong></strong></p>
<p><strong>respawn hacluster</strong><strong>（或</strong><strong>root</strong><strong>）</strong><strong> /usr/lib/heartbeat/ipfail</strong></p>
<p><strong>apiauth ipfail gid=haclient</strong><strong>（或</strong><strong>root</strong><strong>）</strong><strong> uid=hacluster</strong><strong>（或</strong><strong>root</strong><strong>）</strong><strong></strong></p>
<p><strong></strong> </p>
<p><strong>/etc/ha.d/authkeys </strong><strong>认证文件。</strong><strong></strong></p>
<p><strong>写：</strong><strong>auth 1</strong></p>
<p><strong>1 crc</strong></p>
<p><strong><span style="text-decoration: underline;">＃</span></strong><strong><span style="text-decoration: underline;">chmod 600 /etc/ha.d/authkeys</span></strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong>/etc/ha.d/haresources </strong><strong>切换配置文件。</strong><strong></strong></p>
<p><strong><span style="text-decoration: underline;">切换三要素</span></strong>：① VIP；</p>
<p>② server scripts 脚本</p>
<p>③ fs 文件系统。（当Director(无存储时)时，不用切换fs）</p>
<p>无存储时，写：tq.com IPaddr::VIP/24<span style="text-decoration: underline;">/</span><span style="text-decoration: underline;">eth0:1</span> ipvsadm ldirectord</p>
<p>当有存储时，写：node1 10.0.0.170 Filesystem::/dev/sda1::/data1::ext2</p>
<p><strong>＃</strong><strong>ipvsadm</strong><strong>配置并</strong><strong>save</strong><strong>。</strong><strong></strong></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="227"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
<p><strong>＃</strong><strong>scp</strong> /etc/ha.d/ha.cf 到<span style="text-decoration: underline;">从服务</span></p>
<p>/etc/ha.d/haresoures</p>
<p>/etc/ha.d/suthkeys</p>
<p>/etc/hosts</p>
<p>/etc/sysconfig/ipvsadm</p>
<p><strong>＃</strong><strong>service heartbeat start</strong></p>
<p><strong>＃</strong><strong>chkconfig ipvsadm off</strong></p>
<p><strong>＃</strong><strong>service ipvsadm stop</strong></p>
<p><strong>/etc/ha.d/ldirectord.cf </strong><strong>查看</strong><strong>real server</strong><strong>是否正常工作。</strong><strong></strong></p>
<p>checktimeout=10 <strong>＃</strong>10秒看不到，把real server的ipvsadm中-w权值清“0”。</p>
<p>checkinterval=5 <strong>＃</strong>每隔5秒访问一下real server</p>
<p>fallback=127.0.0.1:80</p>
<p>autoreload=yes <strong>＃</strong>再把/etc/sysconfig/ipvsadm中的-w权值设为“1”。</p>
<p>logfile=”/var/log/ldirectord.log”</p>
<p>#logfile=”local0”</p>
<p>＃＃虚拟服务</p>
<p>virtual=VIP:80</p>
<p>real=RIP1:80 gate <strong>＃</strong>DR（LVS）方式是gate。NAT（LVS）方式是masq。</p>
<p>隧道方式是ipip。</p>
<p>real=RIP2:80 gate</p>
<p>fallback=127.0.0.1:80 gate</p>
<p>service=http</p>
<p>request=”index.html” <strong>＃</strong>apache的htdocs/目录下index.html文件中，要有“Test Page”这8个字符。</p>
<p>receive=”Test Page”</p>
<p>#virtualhost=some.domain.com.au</p>
<p>scheduler=rr</p>
<p>protocol=tcp</p>
<p>checktype=negotiate</p>
<p>checkport=80</p>
<p>#virtualhost=www.x.y.z</p>
<p><strong><span style="text-decoration: underline;">从Director：</span></strong></p>
<p>① <strong>＃</strong><strong>vim /etc/ha.d/ha.cf</strong></p>
<p>写对方IP：ucase eth0 192.168.0.66</p>
<p>② 看一下，hostname</p>
<p>③ ＃chkconfig ipvsadm off</p>
<p>＃service ipvsadm stop</p>
<p>＃chmod 600 /etc/ha.d/authkeys</p>
<p><strong>查看：</strong><strong></strong></p>
<p>＃ipvsadm -L</p>
<p>＃ifconfig <span style="text-decoration: underline;">eth0:1</span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/%e9%ab%98%e5%8f%af%e7%94%a8%e9%9b%86%e7%be%a4ha.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>调优小结（一）&amp;&amp; linux_Performance_Tuning_1</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/%e8%b0%83%e4%bc%98%e5%b0%8f%e7%bb%93%ef%bc%88%e4%b8%80%ef%bc%89-linux_performance_tuning_1.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/%e8%b0%83%e4%bc%98%e5%b0%8f%e7%bb%93%ef%bc%88%e4%b8%80%ef%bc%89-linux_performance_tuning_1.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 08:04:00 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Performance_Tuning]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/10/%e8%b0%83%e4%bc%98%e5%b0%8f%e7%bb%93%ef%bc%88%e4%b8%80%ef%bc%89-linux_performance_tuning_1.html</guid>
		<description><![CDATA[调优小结（一）
2008年3月3日
Linux调优：从底层编程的角度考虑。
① 先调优应用程序Application
② 再调优操作系统OS
③ 再调优硬件
调优：
① 计算机体系结构：冯·诺伊曼模型。
② Linux系统及硬... ]]></description>
			<content:encoded><![CDATA[<blockquote><p><b>调优小结（一）</b>
<p>2008年3月3日
<p><b><u>Linux</u></b><b><u>调优</u></b><b>：从底层编程的角度考虑。</b>
<p><b>① </b><b>先调优应用程序Application</b>
<p><b>② </b><b>再调优操作系统OS</b>
<p><b>③ </b><b>再调优硬件</b>
<p><b>调优：</b>
<p><b>① </b><b>计算机体系结构：冯·诺伊曼模型。</b>
<p><b>② </b><b>Linux</b><b>系统及硬件常见性能问题及分析工具。</b>
<p><b>命令：ps、top、vmstat、iostat、mpstat、lsof、strace、ltrace、pmap、ipcs</b>
<p><b></b><b>③ /proc文件系统及内核参数调整。</b>
<p><b>一、计算机体系结构</b>
<p><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image0011.gif"><img title="system_configuration" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="266" alt="system_configuration" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image001_thumb1.gif" width="480" border="0"></a>
<p>CPU的<u>X86指令集</u>兼容386指令集以后的指令集。
<p>Windows中：.com 文件，编译成机器代码。
<p>.exe 文件，编译成操作系统（windows）的API，一少部分编译成机器代码。
<p><u>.com </u><u>文件执行最快，直接执行机器代码。</u>
<p>windows微内核（最核心）
<p><b>注：</b>grub就是机器代码。
<p><b>IA-32</b><b>体系结构：</b>
<p><b>一、CPU：</b>
<p>RISC：精简指令集。
<p>CISC：复杂指令集。
<p>64位：① X86-64：支持大内存2<sup>64</sup>＝16G
<p>② 科学计算（整数计算）2<sup>64</sup>位。
<p><b></b>
<p><b>二、内存：</b>
<p><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image002.gif"><img title="memory" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="201" alt="memory" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image002_thumb.gif" width="460" border="0"></a>
<p><u>服务器端需要大缓存。</u>
<p>内存：EDO：50MH<sub>Z</sub>
<p>SDRAM：66MH<sub>Z</sub>～133MH<sub>Z</sub>
<p>DDR1：266MH<sub>Z</sub>～400MH<sub>Z</sub> 上升沿、下降沿都执行一次，翻倍了。
<p>DDR2：533MH<sub>Z</sub>～800MH<sub>Z</sub>
<p><u></u>
<p><b>三、总线：</b>
<p><u>PCI</u><u>总线</u>：
<p>4B（32bit）×33 MH<sub>Z</sub>/s＝133MB/s
<p>8B（64bit）×33 MH<sub>Z</sub>/s＝266MB/s
<p>8B（64bit）×66 MH<sub>Z</sub>/s＝512MB/s
<p><b></b>
<p><u>PCI-X</u><u>总线</u>＝1GB/s
<p><u>USB</u><u>总线</u>：都是480Mb/s，是点对点（Point-to-Point）的Share Switch架构。
<p><u>PCI-E</u><u>总线</u>：是点对点（Point-to-Point）的Share Switch架构，每条回路都为250MB/s。
<p>1X：250MB/s
<p>16X：4GB/s
<p><u>IDE</u><u>总线</u>：133Mbps＝16MB/s ，寻道时间：8ms（毫秒） 一秒，125H<sub>Z</sub>
<p><b>二、Linux系统及硬件常见性能问题及分析工具</b>
<p><b>命令：ps、top、vmstat、iostat、mpstat、lsof、strace、ltrace、pmap、ipcs</b>
<p><u>检查系统时的步骤</u>：
<p>① ＃free
<p>② ＃ps aux
<p>③ 先备份<u></u>
<p>④ 再进行调整。
<p><u></u>
<p><b>[root@vm51: ~]#<u>top</u></b>
<p><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image004.jpg"><img title="clip_image004" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="233" alt="clip_image004" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image004_thumb.jpg" width="557" border="0"></a>
<p><b>[root@vm51: ~]#<u>uptime</u></b>
<p>15:02:22 up 9:55, 2 users, load average: 0.00, 0.00, 0.00
<p><b>注：top和uptime都是调用/proc/loadavg</b>
<p><u>load average</u>：1秒、5秒、15秒 等待执行任务的平均时间。
<p><b>说明：</b><b>load average</b><b>值高时，可能是：① I/O 慢设备读写；② 内存不足。</b>
<p><b></b><b>内存不足会引起I/O wait高，CPU占用高。内存不足，三个都高。</b>
<p><b></b>
<p><u>CPU</u><u>（s）</u>:<br />
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="246">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p>用top命令时，
<p>按”1”：可看每个CPU占用％。
<p>按”m”：以内存占用率排序。
<p>按”r”：renice 一个进程。
<p>按”k”：kill一个进程。</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>%us：用户占用CPU％
<p>%sy：系统空间占用CPU％
<p>%ni：高优先级占用CPU％
<p>%id：空闲CPU％
<p>%wa：等待硬盘占CPU％
<p>%hi：硬中断占CPU％
<p>%si：软中断占CPU％
<p><b>说明</b>：内存还没用空，就有用SWAP了，是内存慌恐机制引起的。
<p><b>说明：</b>
<p>buffer：在硬件中的缓存。只关心硬件，其内容不被关心。
<p>cache：写文件时用的缓存。关心文件、路径。
<p><b>[root@vm51: ~]#<u>ps -aux</u></b>
<p>Warning: bad syntax, perhaps a bogus &#8216;-&#8217;? See /usr/share/doc/procps-3.2.7/FAQ
<p>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
<p>root 1 0.0 0.2 2036 644 ? Ss 05:06 0:03 init [3]
<p>root 2 0.0 0.0 0 0 ? S 05:06 0:00 [migration/0]
<p>root 3 0.0 0.0 0 0 ? SN 05:06 0:00 [ksoftirqd/0]
<p>root 4 0.0 0.0 0 0 ? S 05:06 0:00 [watchdog/0]
<p>root 5 0.0 0.0 0 0 ? S 05:06 0:00 [migration/1]
<p>root 6 0.0 0.0 0 0 ? SN 05:06 0:00 [ksoftirqd/1]
<p>root 7 0.0 0.0 0 0 ? S 05:06 0:00 [watchdog/1]
<p>TIME:从开机到现在占用CPU累计时间。
<p>COMMAND：进程名字。有[]的只占内核空间（内核线程），是kill不掉的。
<p><u>Linux</u><u>中一页内存4K。</u>
<p>SATA：状态字。
<p>R：正在运行running。
<p>S：可中断休眠。
<p>s：会话session。一堆具有相同父进程的进程，表示下面有“子进程”，此为“父进程”。
<p>l：有线程。共享相同（工作单元）资源的进程。（省内存）
<p>＋：前置进程。当前tty的第一个进程。
<p>＜：高优先级进程。 nice值：-20最高～19最低
<p>N：低优先级进程。
<p>L：有内存锁。所占的内存不会被交换到SWAP中。
<p>D：不可中断休眠。deep sleep深度休眠，多了说明慢速设备I/O多。
<p>T：暂停进程。
<p>Z：僵尸进程。（儿子死了，父不回收。不占资源，占PID，占内存1.7K，不能被kill）
<p><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image005.gif"><img title="clip_image005" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="295" alt="clip_image005" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image005_thumb.gif" width="512" border="0"></a>
<p>说明：
<p>① 进程之间有封闭的内存。如果超出封闭内存范围，叫“内存溢出”。
<p>② 多线程可充分利用CPU。线程之间通讯方便、容易。
<p>③ 线程之间切换付出代价较小。
<p><b>命令：#<u>pmap PID</u> 查看调用到什么库</b>
<p><b>[root@vm51: ~]#<u>pmap 1</u></b>
<p>1: init [3]
<p>00546000 100K r-x&#8211; /lib/ld-2.5.so
<p>0055f000 4K r-x&#8211; /lib/ld-2.5.so
<p>00560000 4K rwx&#8211; /lib/ld-2.5.so
<p>00563000 1244K r-x&#8211; /lib/libc-2.5.so
<p>0069a000 8K r-x&#8211; /lib/libc-2.5.so
<p>0069c000 4K rwx&#8211; /lib/libc-2.5.so
<p>0069d000 12K rwx&#8211; [ anon ]
<p>006cb000 8K r-x&#8211; /lib/libdl-2.5.so
<p>006cd000 4K r-x&#8211; /lib/libdl-2.5.so
<p>006ce000 4K rwx&#8211; /lib/libdl-2.5.so
<p>008df000 236K r-x&#8211; /lib/libsepol.so.1
<p>0091a000 4K rwx&#8211; /lib/libsepol.so.1
<p>0091b000 40K rwx&#8211; [ anon ]
<p>00927000 84K r-x&#8211; /lib/libselinux.so.1
<p>0093c000 8K rwx&#8211; /lib/libselinux.so.1
<p>00dec000 4K r-x&#8211; [ anon ]
<p>08048000 32K r-x&#8211; /sbin/init
<p>08050000 4K rw&#8212; /sbin/init
<p>088ec000 132K rw&#8212; [ anon ]
<p>b7fb3000 8K rw&#8212; [ anon ]
<p>b7fc2000 4K rw&#8212; [ anon ]
<p>bff27000 88K rw&#8212; [ stack ]
<p>total 2036K
<p><b>命令：<u>#vmstat</u></b>
<p><b>[root@vm51: ~]#<u>vmstat 2 3</u></b>
<p>procs &#8212;&#8212;&#8212;&#8211;memory&#8212;&#8212;&#8212;- &#8212;swap&#8211; &#8212;&#8211;io&#8212;- &#8211;system&#8211; &#8212;&#8211;cpu&#8212;&#8212;
<p>r b swpd free buff cache si so bi bo in cs us sy id wa st
<p>0 0 8 10412 73608 116576 0 0 7 4 506 28 0 1 98 0 0
<p>0 0 8 10412 73608 116576 0 0 0 0 1015 35 0 0 100 0 0
<p>0 0 8 10412 73608 116576 0 0 0 0 1012 37 0 0 100 0 0
<p>r：在CPU等待要执行任务的个数。
<p>b：在CPU等待要进行块设备操作的个数。
<p>si/so：swapin：从磁盘读。
<p>swapout：写入到磁盘。
<p>bi/bo：blockin/blockout
<p>in：中断。
<p>cs：内容切换。
<p>us：用户占用CPU％
<p>sy：系统空间占用CPU％
<p>id：空闲CPU％
<p>wa：等待硬盘占CPU％ bi/bo高会导致wa高
<p><b>说明：没有si、so、bi、bo但r很高，说明CPU不行了，要换高性能的CPU了。</b>
<p><b>安装sysstat包会有<u>iostat、sar、mpstat</u>这三个命令。</b>
<p><b>[root@vm51: /mnt/Server]#rpm -ivh sysstat-7.0.0-3.el5.i386.rpm</b>
<p><b>[root@vm51: ~]#vmstat -d 1 1 </b><b>每隔1秒刷新 </b><b>就刷1次</b><b></b>
<p>disk- &#8212;&#8212;&#8212;&#8212;reads&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;writes&#8212;&#8212;&#8212;&#8211; &#8212;&#8211;IO&#8212;&#8212;
<p>total merged sectors ms total merged sectors ms cur sec
<p>ram0 0 0 0 0 0 0 0 0 0 0
<p>ram1 0 0 0 0 0 0 0 0 0 0
<p>ram2 0 0 0 0 0 0 0 0 0 0
<p>ram3 0 0 0 0 0 0 0 0 0 0
<p>ram4 0 0 0 0 0 0 0 0 0 0
<p>ram5 0 0 0 0 0 0 0 0 0 0
<p>ram6 0 0 0 0 0 0 0 0 0 0
<p>ram7 0 0 0 0 0 0 0 0 0 0
<p>ram8 0 0 0 0 0 0 0 0 0 0
<p>ram9 0 0 0 0 0 0 0 0 0 0
<p>ram10 0 0 0 0 0 0 0 0 0 0
<p>ram11 0 0 0 0 0 0 0 0 0 0
<p>ram12 0 0 0 0 0 0 0 0 0 0
<p>ram13 0 0 0 0 0 0 0 0 0 0
<p>ram14 0 0 0 0 0 0 0 0 0 0
<p>ram15 0 0 0 0 0 0 0 0 0 0
<p>sda 4636 2835 126957 19796 1679 2472 33208 24702 0 16
<p>hdc 195 116 1444 345 0 0 0 0 0 0
<p>fd0 0 0 0 0 0 0 0 0 0 0
<p>md0 0 0 0 0 0 0 0 0 0 0
<p><b>[root@vm51: ~]#sar -d 1 2 </b><b>可看现在到之后2秒的数据</b>
<p>Linux 2.6.18-8.el5 (vm51.com) 01/23/2008
<p>04:20:14 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
<p>04:20:15 PM dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
<p>04:20:15 PM dev22-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
<p>04:20:15 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
<p>04:20:16 PM dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
<p>04:20:16 PM dev22-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
<p>Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
<p>Average: dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
<p>Average: dev22-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
<p>tps：每秒读取次数
<p><b>sar </b><b>命令行的常用格式：</b><b><br />sar [options] [-A] [-o file] t [n] <br /></b>在命令行中，n 和t 两个参数组合起来定义采样间隔和次数，t为采样间隔，是必须有<br />的参数，n为采样次数，是可选的，默认值是1，-o file表示将命令结果以二进制格式<br />存放在文件中，file 在此处不是关键字，是文件名。options 为命令行选项，sar命令<br />的选项很多，下面只列出常用选项：<br />-A：所有报告的总和。<br />-u：CPU利用率<br />-v：进程、I节点、文件和锁表状态。<br />-d：硬盘使用报告。 （看过去数据）<br />-r：没有使用的内存页面和硬盘块。<br />-q：看CPU负载。<br />-g：串口I/O的情况。<br />-b：缓冲区使用情况。<br />-a：文件读写情况。<br />-c：系统调用情况。<br />-R：进程的活动情况。<br />-y：终端设备活动情况。<br />-w：系统交换活动。
<p><b>[root@vm51: ~]#<u>mpstat</u> </b><b>用于看多CPU</b><b></b>
<p>Linux 2.6.18-8.el5 (vm51.com) 01/23/2008
<p>04:28:57 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
<p>04:28:57 PM all 0.73 0.00 2.24 0.80 0.05 0.14 0.00 96.03 1013.95
<p><b>ipcs </b><b>进程间通讯。</b>
<p><b>[root@vm51: ~]#ipcs </b>
<p>&#8212;&#8212; Shared Memory Segments &#8212;&#8212;&#8211;共享内存
<p>key shmid owner perms bytes nattch status
<p>&#8212;&#8212; Semaphore Arrays &#8212;&#8212;&#8211;信号灯：两进程之间协调用
<p>key semid owner perms nsems
<p>&#8212;&#8212; Message Queues &#8212;&#8212;&#8211;消息队列
<p>key msqid owner perms used-bytes messages
<p><b>[root@vm51: ~]#ipcrm -m shmid</b><b>（共享ID） 删SHM共享内存（Orecal时用）</b>
<p><b>lsof</b><b>、strace、ltrace命令：</b>
<p>lsof 刷/proc文件系统
<p><b>[root@vm51: ~]#lsof -p 1 -p</b><b>：PID</b><b></b>
<p>COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
<p>init 1 root cwd DIR 8,1 4096 2 /
<p>init 1 root rtd DIR 8,1 4096 2 /
<p>init 1 root txt REG 8,1 38620 654239 /sbin/init
<p>init 1 root mem REG 8,1 121684 427404 /lib/ld-2.5.so
<p>init 1 root mem REG 8,1 1576952 427405 /lib/libc-2.5.so
<p>init 1 root mem REG 8,1 16528 427406 /lib/libdl-2.5.so
<p>init 1 root mem REG 8,1 242880 427422 /lib/libsepol.so.1
<p>init 1 root mem REG 8,1 93512 427423 /lib/libselinux.so.1
<p>init 1 root 10u FIFO 0,16 927 /dev/initctl
<p><b>[root@vm51: ~]#watch lsof -p PID </b>
<p><b>[root@vm51: ~]#strace -p PID </b><b>显示系统调用，追踪程序在干什么</b>
<p><b>[root@vm51: ~]#strace apachectl start</b>
<p><b>[root@vm51: ~]#ltrace /bin/ls</b>
<p><b>[root@vm51: ~]#time /bin/ls </b><b>看执行命令用了多少时间</b>
<p>anaconda-ks.cfg Desktop install.log install.log.syslog password tq tqwjj u
<p>real 0m0.013s
<p>user 0m0.001s
<p>sys 0m0.011s
<p><b>三、/proc文件系统及内核参数调整</b>
<p>/proc/interrupts 中断
<p>/proc/ioports I/O资源
<p>/proc/meminfo 内存信息
<p>/proc/cpuinfo CPU信息
<p>/proc/devices 设备文件
<p><b>例：</b>
<p><b>[root@vm51: ~]#vim /etc/modprobe.conf</b>
<p>alias scsi_hostadapter mptbase
<p>alias scsi_hostadapter1 mptspi
<p>alias snd-card-0 snd-ens1371
<p>options snd-card-0 index=0
<p>options snd-ens1371 index=0
<p>remove snd-ens1371 { /usr/sbin/alsactl store 0 &gt;/dev/null 2&gt;&amp;1 || : ; }; /sbin/modprobe -r &#8211;ignore-remove snd-ens
<p>1371
<p>alias eth0 pcnet32
<p>写:options eth0 irq=10 ioports=
<p>中断冲突时改
<p><b>/proc/sys/</b><b>目录下的文件是要我们改的，即调优。</b>
<p><b>例：</b>
<p>[root@vm51: ~]#cat /proc/sys/net/ipv4/ip_forward
<p>0
<p><b>[root@vm51: ~]#echo &gt; 1 /proc/sys/net/ipv4/ip_forward </b><b>临时修改</b><b></b>
<p><b>[root@vm51: ~]#sysctl -w net.ipv4.ip_forward=1 </b><b>临时修改</b><b></b>
<p>net.ipv4.ip_forward = 1
<p><b>永久生效：</b>
<p><b>[root@vm51: ~]#vim /etc/sysctl.conf</b>
<p><b>写：net.ipv4.ip_forward = 1</b>
<p><b>[root@vm51: ~]#<u>sysctl -p</u> </b><b><u>读取/etc/sysctl.conf配置文件内容，并重新设置一遍。（永久生效）</u></b></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/%e8%b0%83%e4%bc%98%e5%b0%8f%e7%bb%93%ef%bc%88%e4%b8%80%ef%bc%89-linux_performance_tuning_1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>日志项目集成</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90-2.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90-2.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 04:09:51 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[MY 默认分类]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90-2.html</guid>
		<description><![CDATA[日志项目集成：
项目说明：多台Web服务用用LVS进行负载均衡，并且多台Web服务器的apache日志由独立一台日志服务器来记录到syslog日志中。（这里主要介绍如何使用syslog日志服务远程管理apache日... ]]></description>
			<content:encoded><![CDATA[<blockquote><p><b>日志项目集成：</b>
<p>项目说明：多台Web服务用用LVS进行负载均衡，并且多台Web服务器的apache日志由独立一台日志服务器来记录到syslog日志中。（这里主要介绍如何使用syslog日志服务远程管理apache日志）
<p><a href="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image001.gif"><img title="clip_image001" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="112" alt="clip_image001" src="http://tq.freehostia.com.freehostia.com/wp-content/uploads/2009/10/clip_image001_thumb.gif" width="240" border="0"></a>
<p>∵apache本身有一套日志系统，记录在/var/log/httpd/中。现在想用独立的一台syslog日志服务器记录apache日志信息。
<p>∴用“管道”：| logger
<p><b>在各台Web服务器设置：</b>
<p><b>⑴</b><b> </b><b>上加</b><b>-r</b><b>参数，开启远程日志管理。</b><b></b>
<p>[root@vm5: ~]#vim /etc/sysconfig/syslog
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;前略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
<p>SYSLOGD_OPTIONS=&#8221;<b>-m 0 -r -x</b>&#8221; <b>注：</b><b>-m</b><b>：</b><b>MAC -r</b><b>：开启远程日志</b><b> -x</b><b>：不</b><b>DNS</b>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;后略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
<p><b>⑵</b><b> </b><b>在</b><b>apache</b><b>的配置文件</b><b>/etc/httpd/conf/httpd.conf</b><b>中，增加</b><b>| logger </b><b>。</b><b></b>
<p>[root@vm5: ~]#vim /etc/httpd/conf/httpd.conf
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;前略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
<p># For a single logfile with access, agent, and referer information
<p># (Combined Logfile Format), use the following directive:
<p>#
<p>CustomLog logs/access_log combined
<p>CustomLog &#8220;| logger -p info&#8221; combined
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;后略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
<p>此时，就可以在独立的syslog日志服务器上，查看到各台Web服务器的日志了！！！</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>日志项目集成</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 04:06:21 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[MY 默认分类]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/?p=213</guid>
		<description><![CDATA[日志项目集成：
项目说明：多台Web服务用用LVS进行负载均衡，并且多台Web服务器的apache日志由独立一台日志服务器来记录到syslog日志中。（这里主要介绍如何使用syslog日志服务远程管理apache日... ]]></description>
			<content:encoded><![CDATA[<p><strong>日志项目集成：</strong></p>
<p>项目说明：多台Web服务用用LVS进行负载均衡，并且多台Web服务器的apache日志由独立一台日志服务器来记录到syslog日志中。（这里主要介绍如何使用syslog日志服务远程管理apache日志）</p>
<p> </p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>LVS：Linux Virtual Server Linux虚拟服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>Web服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>Web服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>Web服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>Web服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>syslog日志服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>用户访问网页</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>Web服务器 负载均衡</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>日志都存到syslog日志服务器</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td><strong>| logger</strong></td>
</tr>
</tbody>
</table>
<p>∵apache本身有一套日志系统，记录在/var/log/httpd/中。现在想用独立的一台syslog日志服务器记录apache日志信息。</p>
<p>∴用“管道”：| logger</p>
<p> </p>
<p> </p>
<p><strong>在各台Web服务器设置：</strong></p>
<p><strong>⑴</strong><strong> </strong><strong>上加</strong><strong>-r</strong><strong>参数，开启远程日志管理。</strong><strong></strong></p>
<p>[root@vm5: ~]#vim /etc/sysconfig/syslog</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;前略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>SYSLOGD_OPTIONS=&#8221;<strong>-m 0 -r -x</strong>&#8220;    <strong>注：</strong><strong>-m</strong><strong>：</strong><strong>MAC -r</strong><strong>：开启远程日志</strong><strong>      -x</strong><strong>：不</strong><strong>DNS</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;后略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p> </p>
<p><strong>⑵</strong><strong> </strong><strong>在</strong><strong>apache</strong><strong>的配置文件</strong><strong>/etc/httpd/conf/httpd.conf</strong><strong>中，增加</strong><strong>| logger </strong><strong>。</strong><strong></strong></p>
<p>[root@vm5: ~]#vim /etc/httpd/conf/httpd.conf</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;前略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p># For a single logfile with access, agent, and referer information</p>
<p># (Combined Logfile Format), use the following directive:</p>
<p>#</p>
<p>CustomLog logs/access_log combined</p>
<p>CustomLog &#8220;| logger -p info&#8221; combined</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;后略&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>此时，就可以在独立的syslog日志服务器上，查看到各台Web服务器的日志了！！！</p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/%e6%97%a5%e5%bf%97%e9%a1%b9%e7%9b%ae%e9%9b%86%e6%88%90.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>日志管理</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/log-manage.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/log-manage.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 03:50:00 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[log manager]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/10/log-manage.html</guid>
		<description><![CDATA[日志服务：syslog
分为：kernel logger 内核日志；
system logger 系统日志。
[root@vm5: ~]#service syslog restart
Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger:... ]]></description>
			<content:encoded><![CDATA[<p><b>日志服务：syslog</b>
<p>分为：kernel logger 内核日志；
<p>system logger 系统日志。
<p>[root@vm5: ~]#service syslog restart
<p>Shutting down kernel logger: [ OK ]
<p>Shutting down system logger: [ OK ]
<p>Starting system logger: [ OK ]
<p>Starting kernel logger: [ OK ]
<p>查看内核日志用dmesg命令。
<p>[root@vm5: ~]#dmesg
<p>Linux version 2.6.18-8.el5 (brewbuilder@ls20-bc2-14.build.redhat.com) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Fri Jan 26 14:15:21 EST 2007
<p>BIOS-provided physical RAM map:
<p>BIOS-e820: 0000000000000000 &#8211; 000000000009f800 (usable)
<p>BIOS-e820: 000000000009f800 &#8211; 00000000000a0000 (reserved)
<p>BIOS-e820: 00000000000ca000 &#8211; 00000000000cc000 (reserved)
<p>BIOS-e820: 00000000000dc000 &#8211; 0000000000100000 (reserved)
<p>BIOS-e820: 0000000000100000 &#8211; 000000000fef0000 (usable)
<p>BIOS-e820: 000000000fef0000 &#8211; 000000000feff000 (ACPI data)
<p>BIOS-e820: 000000000feff000 &#8211; 000000000ff00000 (ACPI NVS)
<p>BIOS-e820: 000000000ff00000 &#8211; 0000000010000000 (usable)
<p>BIOS-e820: 00000000fec00000 &#8211; 00000000fec10000 (reserved)
<p>BIOS-e820: 00000000fee00000 &#8211; 00000000fee01000 (reserved)
<p>BIOS-e820: 00000000fffe0000 &#8211; 0000000100000000 (reserved)
<p>0MB HIGHMEM available.
<p>256MB LOWMEM available.
<p>found SMP MP-table at 000f6cd0
<p>Using x86 segment limits to approximate NX protection
<p>On node 0 totalpages: 65536
<p>DMA zone: 4096 pages, LIFO batch:0
<p>Normal zone: 61440 pages, LIFO batch:15
<p>DMI present.
<p>Using APIC driver default
<p>ACPI: RSDP (v000 PTLTD ) @ 0&#215;000f6c60
<p>ACPI: RSDT (v001 PTLTD RSDT 0&#215;06040000 LTP 0&#215;00000000) @ 0&#215;0fefab5a
<p>&#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;&#8212;
<p>/var/log/：登录文件放置的目录。
<p>/var/log/messages：是总管所有登录文件的文件（即：日志文件）。
<p>syslog日志服务的配置文件：/etc/syslog.conf 。
<p>[root@vm5: ~]#vim /etc/syslog.conf
<p># Log all kernel messages to the console.
<p># Logging much else clutters up the screen.
<p>#kern.* /dev/console
<p># Log anything (except mail) of level info or higher.
<p># Don&#8217;t log private authentication messages!
<p>*.info;mail.none;news.none;authpriv.none;cron.none /var/log/messages
<p># The authpriv file has restricted access.
<p>authpriv.* /var/log/secure
<p># Log all the mail messages in one place.
<p>mail.* <b>-/var/log/maillog</b>
<p><b></b><b>注：</b><b>-</b><b>表示异步磁盘数据，有用缓存。</b><b></b>
<p># Log cron stuff
<p>cron.* /var/log/cron
<p># Everybody gets emergency messages
<p>*.emerg *
<p># Save news errors of level crit and higher in a special file.
<p>uucp,news.crit /var/log/spooler
<p># Save boot messages also to boot.log
<p>local7.* /var/log/boot.log
<p>#
<p># INN
<p>#
<p>news.=crit /var/log/news/news.crit
<p>news.=err /var/log/news/news.err
<p>news.notice /var/log/news/news.notice
<p><b>说明：</b><b></b>
<p>日志有：对象.等级
<p><b>对象</b><b>.</b>
<p>邮件mail.
<p>内核kern.
<p>打印lpr.
<p>新闻组mark.
<p>news.
<p>安全security. 同于auth.
<p>日志本身syslog.
<p>用户user.
<p>uucp.
<p>用户自定义local0.
<p>…
<p>local7.
<p><b>.</b><b>等级</b><b></b>
<p>.debug 问题信息 （低级）
<p>.info 正常信息
<p>.notice 通知（友好提示）
<p>.warning
<p>.warn 警告信息
<p>.err
<p>.error 错误信息
<p>.crit 应急信息
<p>.alert 比warning更警告
<p>.emerg
<p>.panic 很紧急，不解决不行了
<p>（高级）
<p>news.=crit 就这一级的信息；不加“＝”就从本级到最高级。
<p>news.!crit “！”：取反，除了crit级的信息。
<p>news.*；news.crit；news.err “；”：排除等一个“分号；”后的信息。
<p>*.info;mail.none .none表示不记。
<p>-/var/log/maillog 注：-表示异步磁盘数据，有用缓存。
<p>日志可写到设备上：如：/dev/tty12
<p>日志可写给用户：（三种）
<p>⑴ “用户名”，如：root
<p>⑵ ＠IP地址，如：＠192.168.0.66 表示接收来自192.168.0.66发来的日志，要开启远程管理（加-r） （在客户端）
<p>⑶ ＊，表示给所有用户。
<p>开启日志服务的远程管理功能，在/etc/sysconfig/syslog文件中设置。
<p>[root@vm5: ~]#vim /etc/sysconfig/syslog
<p># Options to syslogd
<p># -m 0 disables &#8216;MARK&#8217; messages.
<p># -r enables logging from remote machines
<p># -x disables DNS lookups on messages recieved with -r
<p># See syslogd(8) for more details
<p>SYSLOGD_OPTIONS=&#8221;<b>-m 0 -r -x</b>&#8221; <b>注：</b><b>-m</b><b>：</b><b>MAC -r</b><b>：开启远程日志</b><b> -x</b><b>：不</b><b>DNS</b>
<p># Options to klogd
<p># -2 prints all kernel oops messages twice; once for klogd to decode, and
<p># once for processing with &#8216;ksymoops&#8217;
<p># -x disables all klogd processing of oops messages entirely
<p># See klogd(8) for more details
<p>KLOGD_OPTIONS=&#8221;-x&#8221;
<p>#
<p>SYSLOG_UMASK=077
<p># set this to a umask value to use for all log files as in umask(1).
<p># By default, all permissions are removed for &#8220;group&#8221; and &#8220;other&#8221;.
<p><b>可以用</b><b>ps aux | grep syslog </b><b>来查看是否开启“日志远程管理”功能。</b><b></b>
<p>[root@vm5: ~]#ps aux | grep syslog
<p>root 4338 0.0 0.2 1688 576 ? Ss 05:00 0:00 syslogd -m 0 -r -x
<p>root 4354 0.0 0.2 3884 680 pts/4 S+ 05:01 0:00 grep syslog
<p><b>例：找本局域网内日志最多的机器。</b><b></b>
<p>[root@vm5: ~]#awk &#8216;{print $4}&#8217; /var/log/messages | sort | uniq -c
<p>297 10.0.4.4 <b>sort</b><b>：排序</b><b> –n:</b><b>按数字排</b>
<p>413 localhost
<p>1375 vm5
<p>[root@vm5: ~]#awk &#8216;{print $4}&#8217; /var/log/messages | uniq -c | sort -n
<p>52 vm5 <b>uniq</b><b>：去除重复行</b><b> -c</b><b>：计数</b>
<p>297 10.0.4.4
<p>413 localhost
<p>544 vm5
<p>779 vm5
<p>[root@vm5: ~]#awk &#8216;{print $4}&#8217; /var/log/messages | sort | uniq -c | sort -n
<p>297 10.0.4.4
<p>413 localhost
<p>1375 vm5
<p>[root@vm5: ~]#awk &#8216;{print $4}&#8217; /var/log/messages | sort | uniq -c | sort -nr
<p>1375 vm5
<p>413 localhost
<p>297 10.0.4.4
<p><b>[root@vm5: ~]#awk &#8216;{print $4}&#8217; /var/log/messages | sort | uniq -c | sort -nr | head -1</b>
<p>1375 vm5
<p><b>在</b><b>/etc/logrotate.d/</b><b>下，是日志记录的信息。</b><b></b>
<p>[root@vm5: /etc/logrotate.d]#ls
<p>acpid cups mgetty ppp rpm sa-update squid tux vsftpd.log
<p>conman httpd named psacct samba setroubleshoot syslog up2date yum
<p>[root@vm5: /etc/logrotate.d]#cat httpd
<p>/var/log/httpd/*log {
<p>missingok
<p>notifempty
<p>sharedscripts
<p>postrotate
<p>/bin/kill -HUP `cat /var/run/httpd.pid 2&gt;/dev/null` 2&gt; /dev/null || true
<p>endscript
<p>}
<p><b>配置文件在</b><b>/etc/logrotate.conf</b><b>中，用来设置日志来如何记录。</b><b></b>
<p>[root@vm5: ~]#vim /etc/logrotate.conf
<p># see &#8220;man logrotate&#8221; for details
<p># rotate log files weekly
<p>weekly
<p># keep 4 weeks worth of backlogs
<p>rotate 4
<p># create new (empty) log files after rotating old ones
<p>create
<p># uncomment this if you want your log files compressed
<p>#compress
<p># RPM packages drop log rotation information into this directory
<p>include /etc/logrotate.d
<p># no packages own wtmp &#8212; we&#8217;ll rotate them here
<p>/var/log/wtmp {
<p>monthly
<p>create 0664 root utmp
<p>rotate 1
<p>}
<p># system-specific logs may be also be configured here.
<p><b>在计划任务中有：</b><b>/etc/cron.daily/logrotate</b><b>文件。</b><b></b>
<p>[root@vm5: ~]#vim /etc/cron.daily/logrotate
<p>#!/bin/sh
<p>/usr/sbin/logrotate /etc/logrotate.conf
<p>EXITVALUE=$?
<p>if [ $EXITVALUE != 0 ]; then
<p>/usr/bin/logger -t logrotate &#8220;ALERT exited abnormally with [$EXITVALUE]&#8221;
<p>fi
<p>exit 0
<p><b>logger</b><b>命令，常在脚本中用，使用脚本进入日志。</b><b></b>
<p>[root@vm5: ~]#logger -p local0.info &#8220;aaaaaa&#8221; 注：-p：加对象.级别
<p>[root@vm5: ~]#tail -1 /var/log/messages
<p>Feb 6 05:49:07 vm5 root: aaaaaa
<p>用户名
<p>[root@vm5: ~]#logger -p local.info -t abc &#8220;bbbbbb&#8221; 注：-t：加标签。
<p>[root@vm5: ~]#tail -1 /var/log/messages
<p>Feb 6 05:51:25 vm5 abc: bbbbbb
<p>标签
<p><b>日志相关：用</b><b>iptables</b><b>记日志。</b><b></b>
<p>-j后加LOG &#8211;log-level info
<p>日志级别
<p><b>例：</b><b></b>
<p>[root@vm5: ~]#iptables -A INPUT -s 192.168.0.0/24 -p tcp &#8211;dport 80 -j LOG &#8211;log-level info
<p>[root@vm5: ~]#tail -1 /var/log/messages
<p>Feb 6 05:54:02 vm5 kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
<p>对象名
<p>∵iptables是由内核直接的，只是kernel对象。
<p>∴iptables只能指定其级别。</p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/log-manage.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB引导盘制作</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/create_usbloading_media.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/create_usbloading_media.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 03:34:00 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[usbloading]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/10/create_usbloading_media.html</guid>
		<description><![CDATA[USB引导盘制作
2008年2月20日
一、系统启动过程：
开机→初始化BIOS→→启动引导器bootloader→→装载内核kernel→→启动init
（GRUB）

l 第一步，初始化BIOS：设置启动顺序等基本输入输出系统。
MBR... ]]></description>
			<content:encoded><![CDATA[<p><b>USB</b><b>引导盘制作</b>
<p>2008年2月20日
<p><b>一、系统启动过程：</b>
<p>开机→初始化BIOS→→启动引导器bootloader→→装载内核kernel→→启动init
<p>（GRUB）
<p><b></b>
<p>l <b>第一步，初始化</b><b>BIOS</b><b>：</b>设置启动顺序等基本输入输出系统。
<p>MBR：Master Boot Recorder主引导分区 （512字节，0柱面、0磁头、第1个扇区）
<p>446字节MBC：主引导代码（找可引导分区）
<p>64字节DPT：4个16字节的主分区信息
<p>2字节：55AA（十六进制数）表示结束。
<p>l <b>第二步，启动引导器</b><b>bootloader</b><b>：</b><b></b>
<p>⑴ grub：/boot/grub/grub.conf配置文件
<p># grub.conf generated by anaconda
<p>#
<p># Note that you do not have to rerun grub after making changes to this file
<p># NOTICE: You do not have a /boot partition. This means that
<p># all kernel and initrd paths are relative to /, eg.
<p># root (hd0,0)
<p># kernel /boot/vmlinuz-version ro root=/dev/sda1
<p># initrd /boot/initrd-version.img
<p>#boot=/dev/sda
<p>default=0
<p>timeout=5
<p>splashimage=(hd0,0)/boot/grub/splash.xpm.gz
<p>hiddenmenu
<p>title Red Hat Enterprise Linux Server (2.6.18-8.el5)
<p>root (hd0,0)
<p><b>注：</b>hd0：第一个硬盘 ， 0：第一个分区
<p>hd0是由/boot/grub/device.map硬盘映射的。
<p>kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet 安静：不显示selinux提示的错误信息等其它信息。
<p><b>注：</b>根分区为卷标为／的。
<p>initrd /boot/initrd-2.6.18-8.el5.img
<p><b>注：</b>[root@vm5: /boot]#ls
<p>config-2.6.18-8.el5 initrd-2.6.18-8.el5.img System.map-2.6.18-8.el5
<p>grub symvers-2.6.18-8.el5.gz vmlinuz-2.6.18-8.el5
<p>[root@vm5: /boot]#mkdir initrd
<p>[root@vm5: /boot]#ls
<p>config-2.6.18-8.el5 initrd symvers-2.6.18-8.el5.gz vmlinuz-2.6.18-8.el5
<p>grub initrd-2.6.18-8.el5.img System.map-2.6.18-8.el5
<p>[root@vm5: /boot]#gunzip &lt; initrd-2.6.18-8.el5.img &gt; initrd/initrd.img
<p>[root@vm5: /boot]#cd initrd
<p>[root@vm5: /boot/initrd]#ls
<p>initrd.img
<p>[root@vm5: /boot/initrd]#file initrd.img
<p>initrd.img: ASCII cpio archive (SVR4 with no CRC)
<p>[root@vm5: /boot/initrd]#cpio -iv &lt; initrd.img
<p>sys
<p>lib
<p>lib/mptspi.ko
<p>lib/ext3.ko 载入：ext3驱动模块
<p>lib/mptbase.ko
<p>lib/sd_mod.ko 载入：sd驱动模块
<p>lib/ohci-hcd.ko 载入：other芯片驱动模块
<p>lib/jbd.ko
<p>lib/mptscsih.ko
<p>lib/ehci-hcd.ko 载入：USB2.0驱动模块
<p>lib/uhci-hcd.ko 载入：USB1.1驱动模块
<p>lib/scsi_mod.ko 载入：SCSI驱动模块
<p>lib/scsi_transport_spi.ko
<p>etc
<p>proc
<p>init
<p>bin
<p>bin/nash
<p>bin/modprobe
<p>bin/insmod
<p>sysroot
<p>dev
<p>dev/mapper
<p>dev/tty7
<p>dev/tty3
<p>dev/tty2
<p>dev/tty0
<p>dev/ttyS0
<p>dev/tty6
<p>dev/ram
<p>dev/ram1
<p>dev/rtc
<p>dev/zero
<p>dev/tty11
<p>dev/ptmx
<p>dev/tty
<p>dev/tty5
<p>dev/console
<p>dev/tty10
<p>dev/ttyS1
<p>dev/tty1
<p>dev/tty8
<p>dev/tty4
<p>dev/null
<p>dev/tty9
<p>dev/ram0
<p>dev/tty12
<p>dev/ttyS2
<p>dev/systty
<p>dev/ttyS3
<p>sbin
<p>6761 blocks
<p>[root@vm5: /boot/initrd]#ls
<p>bin dev etc init initrd.img lib proc sbin sys sysroot
<p>[root@vm5: /boot/initrd]#vim init
<p>#!/bin/nash
<p>mount -t proc /proc /proc
<p>setquiet
<p>echo Mounting proc filesystem
<p>echo Mounting sysfs filesystem
<p>mount -t sysfs /sys /sys
<p>echo Creating /dev
<p>mount -o mode=0755 -t tmpfs /dev /dev
<p>mkdir /dev/pts
<p>mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
<p>mkdir /dev/shm
<p>mkdir /dev/mapper
<p>echo Creating initial device nodes
<p>mknod /dev/null c 1 3
<p>mknod /dev/zero c 1 5
<p>mknod /dev/systty c 4 0
<p>mknod /dev/tty c 5 0
<p>mknod /dev/console c 5 1
<p>mknod /dev/ptmx c 5 2
<p>mknod /dev/rtc c 10 135
<p>mknod /dev/tty0 c 4 0
<p>mknod /dev/tty1 c 4 1
<p>mknod /dev/tty2 c 4 2
<p>mknod /dev/tty3 c 4 3
<p>mknod /dev/tty4 c 4 4
<p>mknod /dev/tty5 c 4 5
<p>mknod /dev/tty6 c 4 6
<p>mknod /dev/tty7 c 4 7
<p>mknod /dev/tty8 c 4 8
<p>mknod /dev/tty9 c 4 9
<p>mknod /dev/tty10 c 4 10
<p>mknod /dev/tty11 c 4 11
<p>mknod /dev/tty12 c 4 12
<p>mknod /dev/ttyS0 c 4 64
<p>⑵ initrd：解决驱动问题（rd：run disk）
<p>initrd /boot/initrd-2.6.18-8.el5.img
<p>l <b>第三步，装载内核</b><b>kernel</b><b>：</b><b></b>
<p>kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet
<p>l <b>第四步，初始化</b><b>init</b><b>：</b><b></b>
<p>/etc/inittab配置文件 →→初始化 /etc/rc.d/
<p>#
<p># inittab This file describes how the INIT process should set up
<p># the system in a certain run-level.
<p>#
<p># Author: Miquel van Smoorenburg, &lt;miquels@drinkel.nl.mugnet.org&gt;
<p># Modified for RHS Linux by Marc Ewing and Donnie Barnes
<p>#
<p># Default runlevel. The runlevels used by RHS are:
<p># 0 &#8211; halt (Do NOT set initdefault to this)
<p># 1 &#8211; Single user mode
<p># 2 &#8211; Multiuser, without NFS (The same as 3, if you do not have networking)
<p># 3 &#8211; Full multiuser mode
<p># 4 &#8211; unused
<p># 5 &#8211; X11
<p># 6 &#8211; reboot (Do NOT set initdefault to this)
<p>#
<p>id:3:initdefault: 设置默认的运行级别为：3
<p># System initialization.
<p>si::sysinit:/etc/rc.d/rc.sysinit sysinit:一定要运行完后面的脚本，再继续运行后面，有错也不停（继续运行后面程序）
<p>l0:0:wait:/etc/rc.d/rc 0 wait:等运行完后面脚本，再继续运行会面，有错就停。
<p>l1:1:wait:/etc/rc.d/rc 1
<p>l2:2:wait:/etc/rc.d/rc 2
<p>l3:3:wait:/etc/rc.d/rc 3
<p>l4:4:wait:/etc/rc.d/rc 4
<p>l5:5:wait:/etc/rc.d/rc 5
<p>l6:6:wait:/etc/rc.d/rc 6
<p># Trap CTRL-ALT-DELETE
<p>ca::ctrlaltdel:/sbin/shutdown -t3 -r now
<p># When our UPS tells us power has failed, assume we have a few minutes
<p># of power left. Schedule a shutdown for 2 minutes from now.
<p># This does, of course, assume you have powerd installed and your
<p># UPS connected and working correctly.
<p>pf::powerfail:/sbin/shutdown -f -h +2 &#8220;Power Failure; System Shutting Down&#8221;
<p># If power was restored before the shutdown kicked in, cancel it.
<p>pr:12345:powerokwait:/sbin/shutdown -c &#8220;Power Restored; Shutdown Cancelled&#8221;
<p># Run gettys in standard runlevels
<p>1:2345:respawn:/sbin/mingetty tty1 respawn:可重生
<p>2:2345:respawn:/sbin/mingetty tty2
<p>3:2345:respawn:/sbin/mingetty tty3
<p>4:2345:respawn:/sbin/mingetty tty4
<p>5:2345:respawn:/sbin/mingetty tty5
<p>6:2345:respawn:/sbin/mingetty tty6
<p># Run xdm in runlevel 5
<p>x:5:respawn:/etc/X11/prefdm –nodaemon
<p>/etc/inittab配置文件 →→初始化： /etc/rc.d/rc.sysinit 键盘、鼠标驱动
<p>（5步） /etc/rc.d/rc 运行级别
<p>/etc/rc.d/rc.local
<p>系统环境配置
<p>l <b>说明：</b>
<p>⑴ initrd先于kernel，如果kernel中有硬盘等驱动就不用initrd了。
<p>RHEL5的kernel中没有硬盘驱动，所以得先initrd再装载kernel。
<p>⑵ 当前模块配置文件在：/boot/config-2.6.18-8.el5中，同/usr/local/src/`uname -r`/.config文件
<p>⑶ /boot/grub中，menu.lst -&gt; ./grub.conf
<p>⑷ 在第四步中，
<p>/etc/inittab配置文件 →→初始化 /etc/rc.d/rc.sysinit 键盘、鼠标驱动
<p>/etc/rc.d/rc 运行级别
<p>/etc/rc.d/rc.local 系统环境配置
<p><b>二、U盘引导制作方法、步骤：</b>
<p>⑴ 对U盘分区、格式化为EXT3文件系统并且加可引导。
<p>[root@vm5: ~]#fdisk /dev/sdb
<p>按a，加可引导。
<p>[root@vm5: ~]#partprobe
<p>[root@vm5: ~]#mke2fs -j /dev/sdb1
<p>⑵ 安装目录树。
<p>[root@vm5: /mnt/Server]#rpm -ivh &#8211;nodeps &#8211;force &#8211;root=/mnt/ filesystem-2.4.0-1.i386.rpm
<p>⑶ 安装grub。
<p>[root@vm5: /mnt/Server]#rpm -ivh &#8211;nodeps &#8211;force &#8211;root=/mnt/ grub-0.97-13.i386.rpm
<p>⑶ 拷贝应用程序到U盘。注：不要覆盖刚刚生成的文件或目录。
<p>[root@vm5: ~]#cp -rf /bin/* /mnt/bin/
<p>[root@vm5: ~]#cp -rf /sbin/* /mnt/sbin/
<p>[root@vm5: ~]#cp -rf /usr/bin/* /mnt/usr/bin/
<p>[root@vm5: ~]#cp -rf /usr/sbin/* /mnt/usr/sbin/
<p>⑷ 拷贝库文件到U盘。注：不要覆盖刚刚生成的文件或目录。
<p>[root@vm5: ~]#cp -rf /lib/* /mnt/lib/
<p>[root@vm5: ~]#cp -rf /usr/lib/* /mnt/usr/lib/ ←如果文件太大，可不拷
<p>⑸ 拷贝/boot/*到U盘之后，在U盘中修改/mnt/boot/grub/grub.conf配置文件、修改/mnt/boot/grub/device.map硬盘映射文件等。
<p>[root@vm5: ~]#cp -rf /boot/* /mnt/boot/
<p>[root@vm5: /mnt]#vim boot/grub/grub.conf
<p>改：default=0
<p>timeout=5
<p>hiddenmenu
<p>title Red Hat Enterprise Linux Server USB LINUX (2.6.18-8.el5)
<p>root (hd0,0)
<p>kernel /boot/vmlinuz-2.6.18-8.el5 ro root=/dev/sdb1 init=/bin/bash
<p>注：不能有多于的“空格”，否则，无法引导成功！
<p>initrd /boot/initrd_usb.img
<p>[root@vm5: /mnt]#vim boot/grub/device.map
<p>写：(hd0) /dev/sdb
<p>⑹ 创建设备文件。 块 主 从
<p>[root@vm5: ~]#mknod /mnt/dev/sdb b 8 16
<p>[root@vm5: ~]#mknod /mnt/dev/sdb1 b 8 17
<p>说明：主设备号：用同一个驱动。
<p>从设备号：记录分区号。
<p>[root@vm5: /mnt/Server]#rpm -ivh kernel-doc-2.6.18-8.el5.noarch.rpm安装内核文档，查看/usr/share/doc/kernel-doc-2.6.18/Documentation/devices.txt文档来学习主设备号、从设备号等说明。
<p>⑺ 加载驱动到initrd。 注：加载顺序不能错！
<p>[root@vm5: ~]#mkinitrd &#8211;with=sd_mod &#8211;with=scsi_mod &#8211;with=uhci-mod &#8211;with=ehci-hcd &#8211;with=usb-storage /mnt/boot/ initrd_usb.img `uname -r`
<p>说明：initrd_usb.img为U盘中/mnt/boot/grub/grub.conf配置文件中initrd /boot/initrd_usb.img 。
<p>⑻ 拷贝/etc/fstab和/etc/mtab，并加以修改。
<p>[root@vm5: ~]#cp /etc/fstab /mnt/etc/fstab
<p>只写：/dev/sdb1 / ext3 defaults 1 1
<p>[root@vm5: ~]#cp /etc/mtab /mnt/etc/mtab
<p>只写：/dev/sdb1 / ext3 rw 0 0
<p>⑼ 切换U盘/mnt/为／根分区。
<p>[root@vm5: ~]#chroot /mnt
<p>⑽ 重装sdb，修复MBR。
<p>sh-3.1#grub-install /dev/sdb
<p>sh-3.1#grub-install &#8211;recheck /dev/sdb
<p>注：检测（也可不用）
<p>至此，U盘引导盘制作完毕！用sync命令同步一下磁盘，重启系统。
<p>改BIOS为USB-HDD为第一启动，即可用U盘引导Linux系统了！！！</p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/create_usbloading_media.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB引导盘制作</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/10/create_usb_loading_media.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/10/create_usb_loading_media.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 03:26:54 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/?p=205</guid>
		<description><![CDATA[USB引导盘制作
2008年2月20日
 
一、系统启动过程：
开机→初始化BIOS→→启动引导器bootloader→→装载内核kernel→→启动init
                                              ... ]]></description>
			<content:encoded><![CDATA[<p align="center"><strong>USB</strong><strong>引导盘制作</strong></p>
<p align="right">2008年2月20日</p>
<p align="right"> </p>
<p><strong>一、系统启动过程：</strong></p>
<p>开机→初始化BIOS→→启动引导器bootloader→→装载内核kernel→→启动init</p>
<p>                                                     （GRUB）</p>
<p><strong>                             </strong></p>
<p>l        <strong>第一步，初始化</strong><strong>BIOS</strong><strong>：</strong>设置启动顺序等基本输入输出系统。</p>
<p>MBR：Master Boot Recorder主引导分区 （512字节，0柱面、0磁头、第1个扇区）</p>
<p>446字节MBC：主引导代码（找可引导分区）</p>
<p>64字节DPT：4个16字节的主分区信息</p>
<p>2字节：55AA（十六进制数）表示结束。</p>
<p> </p>
<p> </p>
<p>l        <strong>第二步，启动引导器</strong><strong>bootloader</strong><strong>：</strong><strong></strong></p>
<p>⑴ grub：/boot/grub/grub.conf配置文件</p>
<p># grub.conf generated by anaconda</p>
<p>#</p>
<p># Note that you do not have to rerun grub after making changes to this file</p>
<p># NOTICE:  You do not have a /boot partition.  This means that</p>
<p>#          all kernel and initrd paths are relative to /, eg.</p>
<p>#          root (hd0,0)</p>
<p>#          kernel /boot/vmlinuz-version ro root=/dev/sda1</p>
<p>#          initrd /boot/initrd-version.img</p>
<p>#boot=/dev/sda</p>
<p>default=0</p>
<p>timeout=5</p>
<p>splashimage=(hd0,0)/boot/grub/splash.xpm.gz</p>
<p>hiddenmenu</p>
<p>title Red Hat Enterprise Linux Server (2.6.18-8.el5)</p>
<p>        root (hd0,0)                              </p>
<p>        <strong>注：</strong>hd0：第一个硬盘 ， 0：第一个分区</p>
<p>                hd0是由/boot/grub/device.map硬盘映射的。</p>
<p>       </p>
<p>kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet 安静：不显示selinux提示的错误信息等其它信息。</p>
<p><strong>注：</strong>根分区为卷标为／的。</p>
<p>       </p>
<p>initrd /boot/initrd-2.6.18-8.el5.img</p>
<p><strong>注：</strong>[root@vm5: /boot]#ls</p>
<p>config-2.6.18-8.el5  initrd-2.6.18-8.el5.img  System.map-2.6.18-8.el5</p>
<p>grub                 symvers-2.6.18-8.el5.gz  vmlinuz-2.6.18-8.el5</p>
<p>[root@vm5: /boot]#mkdir initrd</p>
<p>[root@vm5: /boot]#ls</p>
<p>config-2.6.18-8.el5  initrd                   symvers-2.6.18-8.el5.gz  vmlinuz-2.6.18-8.el5</p>
<p>grub                 initrd-2.6.18-8.el5.img  System.map-2.6.18-8.el5</p>
<p>[root@vm5: /boot]#gunzip &lt; initrd-2.6.18-8.el5.img &gt; initrd/initrd.img</p>
<p>[root@vm5: /boot]#cd initrd</p>
<p>[root@vm5: /boot/initrd]#ls</p>
<p>initrd.img</p>
<p>[root@vm5: /boot/initrd]#file initrd.img</p>
<p>initrd.img: ASCII cpio archive (SVR4 with no CRC)</p>
<p>[root@vm5: /boot/initrd]#cpio -iv &lt; initrd.img</p>
<p>sys</p>
<p>lib</p>
<p>lib/mptspi.ko</p>
<p>lib/ext3.ko        载入：ext3驱动模块</p>
<p>lib/mptbase.ko                   </p>
<p>lib/sd_mod.ko          载入：sd驱动模块</p>
<p>lib/ohci-hcd.ko     载入：other芯片驱动模块</p>
<p>lib/jbd.ko</p>
<p>lib/mptscsih.ko</p>
<p>lib/ehci-hcd.ko         载入：USB2.0驱动模块</p>
<p>lib/uhci-hcd.ko     载入：USB1.1驱动模块</p>
<p>lib/scsi_mod.ko         载入：SCSI驱动模块</p>
<p>lib/scsi_transport_spi.ko</p>
<p>etc</p>
<p>proc</p>
<p>init</p>
<p>bin</p>
<p>bin/nash</p>
<p>bin/modprobe</p>
<p>bin/insmod</p>
<p>sysroot</p>
<p>dev</p>
<p>dev/mapper</p>
<p>dev/tty7</p>
<p>dev/tty3</p>
<p>dev/tty2</p>
<p>dev/tty0</p>
<p>dev/ttyS0</p>
<p>dev/tty6</p>
<p>dev/ram</p>
<p>dev/ram1</p>
<p>dev/rtc</p>
<p>dev/zero</p>
<p>dev/tty11</p>
<p>dev/ptmx</p>
<p>dev/tty</p>
<p>dev/tty5</p>
<p>dev/console</p>
<p>dev/tty10</p>
<p>dev/ttyS1</p>
<p>dev/tty1</p>
<p>dev/tty8</p>
<p>dev/tty4</p>
<p>dev/null</p>
<p>dev/tty9</p>
<p>dev/ram0</p>
<p>dev/tty12</p>
<p>dev/ttyS2</p>
<p>dev/systty</p>
<p>dev/ttyS3</p>
<p>sbin</p>
<p>6761 blocks</p>
<p>[root@vm5: /boot/initrd]#ls</p>
<p>bin  dev  etc  init  initrd.img  lib  proc  sbin  sys  sysroot</p>
<p>[root@vm5: /boot/initrd]#vim init</p>
<p>#!/bin/nash</p>
<p> </p>
<p>mount -t proc /proc /proc</p>
<p>setquiet</p>
<p>echo Mounting proc filesystem</p>
<p>echo Mounting sysfs filesystem</p>
<p>mount -t sysfs /sys /sys</p>
<p>echo Creating /dev</p>
<p>mount -o mode=0755 -t tmpfs /dev /dev</p>
<p>mkdir /dev/pts</p>
<p>mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts</p>
<p>mkdir /dev/shm</p>
<p>mkdir /dev/mapper</p>
<p>echo Creating initial device nodes</p>
<p>mknod /dev/null c 1 3</p>
<p>mknod /dev/zero c 1 5</p>
<p>mknod /dev/systty c 4 0</p>
<p>mknod /dev/tty c 5 0</p>
<p>mknod /dev/console c 5 1</p>
<p>mknod /dev/ptmx c 5 2</p>
<p>mknod /dev/rtc c 10 135</p>
<p>mknod /dev/tty0 c 4 0</p>
<p>mknod /dev/tty1 c 4 1</p>
<p>mknod /dev/tty2 c 4 2</p>
<p>mknod /dev/tty3 c 4 3</p>
<p>mknod /dev/tty4 c 4 4</p>
<p>mknod /dev/tty5 c 4 5</p>
<p>mknod /dev/tty6 c 4 6</p>
<p>mknod /dev/tty7 c 4 7</p>
<p>mknod /dev/tty8 c 4 8</p>
<p>mknod /dev/tty9 c 4 9</p>
<p>mknod /dev/tty10 c 4 10</p>
<p>mknod /dev/tty11 c 4 11</p>
<p>mknod /dev/tty12 c 4 12</p>
<p>mknod /dev/ttyS0 c 4 64</p>
<p> </p>
<p>⑵ initrd：解决驱动问题（rd：run disk）</p>
<p>   initrd /boot/initrd-2.6.18-8.el5.img</p>
<p> </p>
<p> </p>
<p>l        <strong>第三步，装载内核</strong><strong>kernel</strong><strong>：</strong><strong></strong></p>
<p>kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet</p>
<p> </p>
<p>l        <strong>第四步，初始化</strong><strong>init</strong><strong>：</strong><strong></strong></p>
<p>/etc/inittab配置文件  →→初始化 /etc/rc.d/</p>
<p>#</p>
<p># inittab       This file describes how the INIT process should set up</p>
<p>#               the system in a certain run-level.</p>
<p>#</p>
<p># Author:       Miquel van Smoorenburg, &lt;miquels@drinkel.nl.mugnet.org&gt;</p>
<p>#               Modified for RHS Linux by Marc Ewing and Donnie Barnes</p>
<p>#</p>
<p> </p>
<p># Default runlevel. The runlevels used by RHS are:</p>
<p>#   0 &#8211; halt (Do NOT set initdefault to this)</p>
<p>#   1 &#8211; Single user mode</p>
<p>#   2 &#8211; Multiuser, without NFS (The same as 3, if you do not have networking)</p>
<p>#   3 &#8211; Full multiuser mode</p>
<p>#   4 &#8211; unused</p>
<p>#   5 &#8211; X11</p>
<p>#   6 &#8211; reboot (Do NOT set initdefault to this)</p>
<p>#</p>
<p>id:3:initdefault:                         设置默认的运行级别为：3</p>
<p> </p>
<p># System initialization.</p>
<p>si::sysinit:/etc/rc.d/rc.sysinit      sysinit:一定要运行完后面的脚本，再继续运行后面，有错也不停（继续运行后面程序）</p>
<p> </p>
<p>l0:0:wait:/etc/rc.d/rc 0             wait:等运行完后面脚本，再继续运行会面，有错就停。</p>
<p>l1:1:wait:/etc/rc.d/rc 1</p>
<p>l2:2:wait:/etc/rc.d/rc 2</p>
<p>l3:3:wait:/etc/rc.d/rc 3</p>
<p>l4:4:wait:/etc/rc.d/rc 4</p>
<p>l5:5:wait:/etc/rc.d/rc 5</p>
<p>l6:6:wait:/etc/rc.d/rc 6</p>
<p> </p>
<p># Trap CTRL-ALT-DELETE</p>
<p>ca::ctrlaltdel:/sbin/shutdown -t3 -r now</p>
<p> </p>
<p># When our UPS tells us power has failed, assume we have a few minutes</p>
<p># of power left.  Schedule a shutdown for 2 minutes from now.</p>
<p># This does, of course, assume you have powerd installed and your</p>
<p># UPS connected and working correctly. </p>
<p>pf::powerfail:/sbin/shutdown -f -h +2 &#8220;Power Failure; System Shutting Down&#8221;</p>
<p> </p>
<p># If power was restored before the shutdown kicked in, cancel it.</p>
<p>pr:12345:powerokwait:/sbin/shutdown -c &#8220;Power Restored; Shutdown Cancelled&#8221;</p>
<p> </p>
<p># Run gettys in standard runlevels</p>
<p>1:2345:respawn:/sbin/mingetty tty1                      respawn:可重生</p>
<p>2:2345:respawn:/sbin/mingetty tty2</p>
<p>3:2345:respawn:/sbin/mingetty tty3</p>
<p>4:2345:respawn:/sbin/mingetty tty4</p>
<p>5:2345:respawn:/sbin/mingetty tty5</p>
<p>6:2345:respawn:/sbin/mingetty tty6</p>
<p> </p>
<p> </p>
<p># Run xdm in runlevel 5</p>
<p>x:5:respawn:/etc/X11/prefdm –nodaemon</p>
<p> </p>
<p> </p>
<p>/etc/inittab配置文件  →→初始化： /etc/rc.d/rc.sysinit  键盘、鼠标驱动</p>
<p>                      （5步）   /etc/rc.d/rc  运行级别</p>
<p>                                /etc/rc.d/rc.local </p>
<p>                                                 系统环境配置</p>
<p>                                                                  </p>
<p> </p>
<p>l        <strong>说明：</strong></p>
<p>⑴    initrd先于kernel，如果kernel中有硬盘等驱动就不用initrd了。</p>
<p>RHEL5的kernel中没有硬盘驱动，所以得先initrd再装载kernel。</p>
<p> </p>
<p>⑵ 当前模块配置文件在：/boot/config-2.6.18-8.el5中，同/usr/local/src/`uname -r`/.config文件</p>
<p> </p>
<p>⑶ /boot/grub中，menu.lst -&gt; ./grub.conf</p>
<p> </p>
<p>⑷ 在第四步中，</p>
<p>/etc/inittab配置文件  →→初始化 /etc/rc.d/rc.sysinit  键盘、鼠标驱动</p>
<p>                              /etc/rc.d/rc  运行级别</p>
<p>                              /etc/rc.d/rc.local  系统环境配置</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>二、U盘引导制作方法、步骤：</strong></p>
<p>⑴ 对U盘分区、格式化为EXT3文件系统并且加可引导。</p>
<p>[root@vm5: ~]#fdisk /dev/sdb</p>
<p>按a，加可引导。</p>
<p>[root@vm5: ~]#partprobe</p>
<p>[root@vm5: ~]#mke2fs -j /dev/sdb1</p>
<p> </p>
<p>⑵ 安装目录树。</p>
<p>[root@vm5: /mnt/Server]#rpm -ivh &#8211;nodeps &#8211;force &#8211;root=/mnt/ filesystem-2.4.0-1.i386.rpm</p>
<p> </p>
<p>⑶ 安装grub。</p>
<p>[root@vm5: /mnt/Server]#rpm -ivh &#8211;nodeps &#8211;force &#8211;root=/mnt/ grub-0.97-13.i386.rpm</p>
<p> </p>
<p>⑶ 拷贝应用程序到U盘。注：不要覆盖刚刚生成的文件或目录。</p>
<p>[root@vm5: ~]#cp -rf /bin/* /mnt/bin/</p>
<p>[root@vm5: ~]#cp -rf /sbin/* /mnt/sbin/</p>
<p>[root@vm5: ~]#cp -rf /usr/bin/* /mnt/usr/bin/</p>
<p>[root@vm5: ~]#cp -rf /usr/sbin/* /mnt/usr/sbin/</p>
<p> </p>
<p>⑷ 拷贝库文件到U盘。注：不要覆盖刚刚生成的文件或目录。</p>
<p>[root@vm5: ~]#cp -rf /lib/* /mnt/lib/</p>
<p>[root@vm5: ~]#cp -rf /usr/lib/* /mnt/usr/lib/        ←如果文件太大，可不拷</p>
<p> </p>
<p>⑸ 拷贝/boot/*到U盘之后，在U盘中修改/mnt/boot/grub/grub.conf配置文件、修改/mnt/boot/grub/device.map硬盘映射文件等。</p>
<p>[root@vm5: ~]#cp -rf /boot/* /mnt/boot/</p>
<p>[root@vm5: /mnt]#vim boot/grub/grub.conf</p>
<p>改：default=0</p>
<p>timeout=5</p>
<p>hiddenmenu</p>
<p>title Red Hat Enterprise Linux Server  USB  LINUX  (2.6.18-8.el5)</p>
<p>        root (hd0,0)</p>
<p>        kernel /boot/vmlinuz-2.6.18-8.el5 ro root=/dev/sdb1 init=/bin/bash</p>
<p>        注：不能有多于的“空格”，否则，无法引导成功！</p>
<p>        initrd /boot/initrd_usb.img</p>
<p>[root@vm5: /mnt]#vim boot/grub/device.map</p>
<p>写：(hd0)    /dev/sdb</p>
<p> </p>
<p>⑹ 创建设备文件。            块 主 从</p>
<p>[root@vm5: ~]#mknod /mnt/dev/sdb b 8 16</p>
<p>[root@vm5: ~]#mknod /mnt/dev/sdb1 b 8 17</p>
<p>说明：主设备号：用同一个驱动。</p>
<p>从设备号：记录分区号。</p>
<p>[root@vm5: /mnt/Server]#rpm -ivh kernel-doc-2.6.18-8.el5.noarch.rpm安装内核文档，查看/usr/share/doc/kernel-doc-2.6.18/Documentation/devices.txt文档来学习主设备号、从设备号等说明。</p>
<p> </p>
<p>⑺ 加载驱动到initrd。 注：加载顺序不能错！</p>
<p>[root@vm5: ~]#mkinitrd &#8211;with=sd_mod &#8211;with=scsi_mod &#8211;with=uhci-mod &#8211;with=ehci-hcd &#8211;with=usb-storage /mnt/boot/ initrd_usb.img `uname -r`</p>
<p>说明：initrd_usb.img为U盘中/mnt/boot/grub/grub.conf配置文件中initrd /boot/initrd_usb.img 。</p>
<p> </p>
<p>⑻ 拷贝/etc/fstab和/etc/mtab，并加以修改。</p>
<p>[root@vm5: ~]#cp /etc/fstab /mnt/etc/fstab</p>
<p>只写：/dev/sdb1   /   ext3  defaults   1 1</p>
<p>[root@vm5: ~]#cp /etc/mtab /mnt/etc/mtab</p>
<p>只写：/dev/sdb1   /   ext3   rw  0 0</p>
<p> </p>
<p>⑼ 切换U盘/mnt/为／根分区。</p>
<p>[root@vm5: ~]#chroot /mnt</p>
<p> </p>
<p>⑽ 重装sdb，修复MBR。</p>
<p>sh-3.1#grub-install /dev/sdb</p>
<p>sh-3.1#grub-install &#8211;recheck /dev/sdb</p>
<p>              注：检测（也可不用）</p>
<p> </p>
<p>至此，U盘引导盘制作完毕！用sync命令同步一下磁盘，重启系统。</p>
<p>改BIOS为USB-HDD为第一启动，即可用U盘引导Linux系统了！！！</p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/10/create_usb_loading_media.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用sqlloader导入数据</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/09/sqlloader.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/09/sqlloader.html#comments</comments>
		<pubDate>Sat, 26 Sep 2009 07:57:00 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Oracle数据库管理]]></category>
		<category><![CDATA[sqlloader]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/09/sqlloader.html</guid>
		<description><![CDATA[

今天为开发数据库导入数据，使用sqlloader。记录一下遇到的问题及笔记。  1、表结构如下：
 oss@WINKSDB&#62; desc member_actions; Name              Null?    Type ----------------- -------- ------------ PHONE             NO... ]]></description>
			<content:encoded><![CDATA[<div id="Published By Juziyue-[4]1_124F523B08F540F6AD4293E61293381E_0862E224B1A14E30B1F5C72BD1E6A719_1"></div>
<p><span id="more-192"></span>
<div id="Published By Juziyue-[4]1_124F523B08F540F6AD4293E61293381E_0862E224B1A14E30B1F5C72BD1E6A719">今天为开发数据库导入数据，使用sqlloader。记录一下遇到的问题及笔记。<br/> <br/> <strong>1、表结构如下：</strong>
<pre class="sql"> oss@WINKSDB&gt; desc member_actions; Name              Null?    Type ----------------- -------- ------------ PHONE             NOT NULL VARCHAR2(50) ACTION_TIME       NOT NULL DATE URL                        VARCHAR2(80) APP                        VARCHAR2(20) ACTIVE_LEVEL               VARCHAR2(10) </pre>
<p> <strong>2、要导入的文件（infile），是由log分析得来：</strong><br />
<blockquote>[oracle@devdb: ~]$ll -th deactive_actionlist.2009-09-23-rw-r&#8211;r&#8211; 1 oracle oinstall 49M Sep 24 03:11 deactive_actionlist.2009-09-23[oracle@devdb: ~]$head !$head deactive_actionlist.2009-09-23<font face="宋体" color="#FF00FF" size="2">2009-09-23 00:00:04<strong>,314</strong></font> 13560338333 user/registeruser comm deactive2009-09-23 00:00:17,053 13563963585 user/registeruser comm deactive2009-09-23 00:02:05,704 13810843712 user/registeruser comm deactive2009-09-23 00:02:41,097 13609331107 user/registeruser comm deactive2009-09-23 00:02:43,330 13520106592 user/registeruser comm deactive2009-09-23 00:04:18,818 18702967004 user/registeruser comm deactive2009-09-23 00:05:52,878 15106936277 user/registeruser comm deactive2009-09-23 00:09:14,438 13483699551 user/registeruser comm deactive2009-09-23 00:09:37,988 15910669392 user/registeruser comm deactive2009-09-23 00:09:46,555 15819008127 user/registeruser comm deactive</p></blockquote>
<p> <strong>3、sqlloader的controlfile如下：</strong><br />
<blockquote>
<pre class="sql"> load data                                            --控制文件标识 infile 'deactive_actionlist.2009-09-23'        --要导入数据的文件名 truncate into table MEMBER_ACTIONS                  --truncate table MEMBER_ACTIONS_IMP后，再导入数据 fields terminated by &quot; &quot; optionally enclosed by '&quot;'        --字符终止于“空格”，并附上&quot;双引号(ACTION_TIME POSITION(1:19) date &quot;YYYY-MM-DD HH24:MI:SS&quot;,     --infile中的日期／时间精确到千分秒，而ACTION_TIME列 为DATE型field2 FILLER,                                               --所以多了一段3位的千分秒，要把它漏过去phone, url,app,active_level)                                                       --定义列对应顺序 </pre>
</blockquote>
<blockquote><p><strong>说明：</strong>INSERT：为缺省方式，在数据装载开始时要求表为空。APPEND：在表中追加新记录。REPLACE：使用一种传统DELETE语句；因此，如果要加载的表中已经包含许多记录，这个操作可能执行得很慢。TRUNCATE：则不同，它使用TRUNCATE SQL命令，通常会更快地执行，因为它不必物理地删除每一行。</p></blockquote>
<p> <strong>4、现在来导入并看一下产生的log：</strong><br />
<blockquote>[oracle@devdb: ~]$sqlldr oss/oss control=deactive.ctl <font face="宋体" color="#FF0000" size="2">direct=true</font> &#8212;导入性能果然很快！<font face="宋体" color="#FF0000" size="2">只用了5.75秒</font>。[oracle@devdb: ~]$cat deactive.logSQL*Loader: Release 11.1.0.7.0 &#8211; Production on Fri Sep 25 11:02:59 2009Copyright (c) 1982, 2007, Oracle. All rights reserved.Control File: deactive.ctlData File: deactive_actionlist.2009-09-23 Bad File: deactive_actionlist.bad Discard File: none specified (Allow all discards)Number to load: ALLNumber to skip: 0Errors allowed: 50Continuation: none specifiedPath used: DirectTable MEMBER_ACTIONS, loaded from every logical record.Insert option in effect for this table: TRUNCATE Column Name Position Len Term Encl Datatype&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;- &#8212;&#8211; &#8212;- &#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;ACTION_TIME 1:19 19 WHT O(&quot;) DATE YYYY-MM-DD HH24:MI:SSFIELD2 NEXT * WHT O(&quot;) CHARACTER (FILLER FIELD)PHONE NEXT * WHT O(&quot;) CHARACTER URL NEXT * WHT O(&quot;) CHARACTER APP NEXT * WHT O(&quot;) CHARACTER ACTIVE_LEVEL NEXT * WHT O(&quot;) CHARACTER Table MEMBER_ACTIONS: <font face="宋体" color="#FF0000" size="2">821263 Rows successfully loaded.</font> 0 Rows not loaded due to data errors. 0 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null. Date conversion cache disabled due to overflow (default size: 1000)Bind array size not used in direct path.Column array rows : 5000Stream buffer bytes: 256000Read buffer bytes: 1048576Total logical records skipped: 0Total logical records read: 821263Total logical records rejected: 0Total logical records discarded: 0Total stream buffers loaded by SQL*Loader main thread: 195Total stream buffers loaded by SQL*Loader load thread: 0Run began on Fri Sep 25 11:02:59 2009Run ended on Fri Sep 25 11:03:05 2009Elapsed time was: <font face="宋体" color="#FF0000" size="2">00:00:05.75</font>CPU time was: 00:00:03.26</p></blockquote>
<p> <strong>5、最后，看看导入的数据有没有问题：</strong>
<pre class="sql"> oss@WINKSDB&gt; select count(*) from member_actions;  COUNT(*)----------    821263oss@WINKSDB&gt; alter session set nls_date_format='yyyy-dd-mm hh24:mi:ss';Session altered.oss@WINKSDB&gt; col phone for a15oss@WINKSDB&gt; col url for a30oss@WINKSDB&gt; col app for a15oss@WINKSDB&gt; select * from member_actions where rownum &lt;= 10;PHONE           ACTION_TIME         URL                            APP             ACTIVE_LEVEL--------------- ------------------- ------------------------------ --------------- ---------------15850680739     2009-23-09 23:21:16 specialwinks                   comm            deactive15819468114     2009-23-09 23:21:16 winks/show                     comm            deactive15817936605     2009-23-09 23:21:16 winks/show                     comm            deactive13471875440     2009-23-09 23:21:16 message                        comm            deactive13262699996     2009-23-09 23:21:16 winks/show                     comm            deactive15129159347     2009-23-09 23:21:16 specialwinks                   comm            deactive13960018854     2009-23-09 23:21:16 specialwinks                   comm            deactive15860758584     2009-23-09 23:21:16 winks/show                     comm            deactive13880176827     2009-23-09 23:21:16 specialwinks                   comm            deactive15120901746     2009-23-09 23:21:16 config                         comm            deactive10 rows selected. </pre>
<p> 导入的数据没有问题！<br/> 该服务器的CPU为1颗4核的Intel(R) Xeon(R) CPU E5410 @ 2.33GHz &nbsp;&nbsp;&nbsp;&nbsp;内存：4G<br/> <br/> &#8211; The End -</div>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/09/sqlloader.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
