<?xml version="1.0" encoding="UTF-8"?>
  <feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html"><![CDATA[包子博客]]></title>
  <subtitle type="html"><![CDATA[创造机会的人是勇者；等待机会的人是愚者]]></subtitle>
  <id>http://blog.iloveu.sh.cn/</id>
  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/" /> 
  <link rel="self" type="application/atom+xml" href="http://blog.iloveu.sh.cn/atom.asp" /> 
  <generator uri="http://www.pjhome.net/" version="2.8">PJBlog3</generator> 
  <updated>2012-01-04T21:37:28+08:00</updated>

  <entry>
	  <title type="html"><![CDATA[Linux Web服务器网站故障分析常用的命令]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2012-01-04T21:37:28+08:00</updated>
	  <published>2012-01-04T21:37:28+08:00</published>
		  <summary type="html"><![CDATA[系统连接状态篇：<br/> 1.查看TCP连接状态<br/> netstat -nat |awk &#39;{print $6}&#39;|sort|uniq -c|sort -rn<br/> <br/>netstat -n | awk &#39;/^tcp/ {++S[$NF]};END {for(a in S) print a, S[a]}&#39; 或<br/> netstat -n | awk &#39;/^tcp/ {++state[$NF]}; END {for(key in state) print key,&#34;t&#34;,state[key]}&#39;<br/> netstat -n | awk &#39;/^tcp/ {++arr[$NF]};END {for(k in arr) print k,&#34;t&#34;,arr[k]}&#39;<br/> <br/>netstat -n |awk &#39;/^tcp/ {print $NF}&#39;|sort|uniq -c|sort -rn<br/> <br/>netstat -ant | awk &#39;{print $NF}&#39; | grep -v &#39;[a-z]&#39; | sort | uniq -c<br/> <br/><br/><br/>2.查找请求数请20个IP（常用于查找攻来源）：<br/> <br/>netstat -anlp|grep 80|grep tcp|awk &#39;{print $5}&#39;|awk -F: &#39;{print $1}&#39;|sort|uniq -c|sort -nr|head -n20<br/> <br/>netstat -ant |awk &#39;/:80/{split($5,ip,&#34;:&#34;);++A[ip[1]]}END{for(i in A) print A[i],i}&#39; |sort -rn|head -n20<br/> <br/><br/><br/>3.用tcpdump嗅探80端口的访问看看谁最高<br/> <br/>tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F&#34;.&#34; &#39;{print $1&#34;.&#34;$2&#34;.&#34;$3&#34;.&#34;$4}&#39; | sort | uniq -c | sort -nr |head -20<br/> <br/><br/>4.查找较多time_wait连接<br/> <br/>netstat -n|grep TIME_WAIT|awk &#39;{print $5}&#39;|sort|uniq -c|sort -rn|head -n20<br/> <br/>5.找查较多的SYN连接<br/> <br/>netstat -an | grep SYN | awk &#39;{print $5}&#39; | awk -F: &#39;{print $1}&#39; | sort | uniq -c | sort -nr | more<br/> <br/>6.根据端口列进程<br/> <br/>netstat -ntlp | grep 80 | awk &#39;{print $7}&#39; | cut -d/ -f1<br/> <br/><br/>网站日志分析篇1（Apache）：<br/> <br/>1.获得访问前10位的ip地址<br/> <br/>cat access.log|awk &#39;{print $1}&#39;|sort|uniq -c|sort -nr|head -10<br/> cat access.log|awk &#39;{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}&#39;<br/> <br/>2.访问次数最多的文件或页面,取前20<br/> <br/>cat access.log|awk &#39;{print $11}&#39;|sort|uniq -c|sort -nr|head -20<br/> <br/>3.列出传输最大的几个exe文件（分析下载站的时候常用）<br/> <br/>cat access.log |awk &#39;($7~/.exe/){print $10 &#34; &#34; $1 &#34; &#34; $4 &#34; &#34; $7}&#39;|sort -nr|head -20<br/> <br/>4.列出输出大于200000byte(约200kb)的exe文件以及对应文件发生次数<br/> <br/>cat access.log |awk &#39;($10 &gt; 200000 &amp;&amp; $7~/.exe/){print $7}&#39;|sort -n|uniq -c|sort -nr|head -100<br/> <br/>5.如果日志最后一列记录的是页面文件传输时间，则有列出到客户端最耗时的页面<br/> <br/>cat access.log |awk&nbsp;&nbsp;&#39;($7~/.php/){print $NF &#34; &#34; $1 &#34; &#34; $4 &#34; &#34; $7}&#39;|sort -nr|head -100<br/> <br/>6.列出最最耗时的页面(超过60秒的)的以及对应页面发生次数<br/> <br/>cat access.log |awk &#39;($NF &gt; 60 &amp;&amp; $7~/.php/){print $7}&#39;|sort -n|uniq -c|sort -nr|head -100<br/> <br/>7.列出传输时间超过 30 秒的文件<br/> <br/>cat access.log |awk &#39;($NF &gt; 30){print $7}&#39;|sort -n|uniq -c|sort -nr|head -20<br/> <br/>8.统计网站流量（G)<br/> <br/>cat access.log |awk &#39;{sum+=$10} END {print sum/1024/1024/1024}&#39;<br/> <br/>9.统计404的连接<br/> <br/>awk &#39;($9 ~/404/)&#39; access.log | awk &#39;{print $9,$7}&#39; | sort<br/> <br/>10. 统计http status<br/> <br/>cat access.log |awk &#39;{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}&#39;<br/> cat access.log |awk &#39;{print $9}&#39;|sort|uniq -c|sort -rn<br/> <br/>10.蜘蛛分析，查看是哪些蜘蛛在抓取内容。<br/> <br/>/usr/sbin/tcpdump -i eth0 -l -s 0 -w - dst port 80 | strings | grep -i user-agent | grep -i -E &#39;bot|crawler|slurp|spider&#39;<br/> <br/><br/>网站日分析2(Squid篇）按域统计流量<br/> <br/>zcat squid_access.log.tar.gz| awk &#39;{print $10,$7}&#39; |awk &#39;BEGIN{FS=&#34;[ /]&#34;}{trfc[$4]+=$1}END{for(domain in trfc){printf &#34;%st%dn&#34;,domain,trfc[domain]}}&#39;<br/> <br/><br/>数据库篇<br/> 1.查看数据库执行的sql<br/> <br/>/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i &#39;Sel&#101;ct|Up&#100;ate|Del&#101;te|Ins&#101;rt|SET|COMMIT|ROLLBACK|Cr&#101;ate|Dro&#112;|Alt&#101;r|CALL&#39;<br/> <br/><br/>系统Debug分析篇<br/> 1.调试命令<br/> strace -p pid<br/> 2.跟踪指定进程的PID<br/> gdb -p pid<br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/330.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=330</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[[教程] DHD 刷机失败变砖的自救方法]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2011-12-22T09:04:20+08:00</updated>
	  <published>2011-12-22T09:04:20+08:00</published>
		  <summary type="html"><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 对于经常刷机的Android刷友来说，肯定会碰到刷机失败损坏recovery程序乃至手机无法启动的情况，也就是传说中的手机变砖块。不过刷机失败手机变砖并不是世界末日，略施小计就可以让你的Android手机重新复活，方法如下：<br/> <br/><br/><br/><br/>1. 在PC 上安装配置Android SDK 刷机失败后手机变砖无法在手机上完成操作，智能借助Android SDK工具，所以你必须在操作的PC上下载并安装Android SDK程序，程序下载地址和安装配置方法见Android SDK官网 <a href="http://developer.android.com/sdk/" target="_blank" rel="external">http://developer.android.com/sdk/</a><br/> <br/>2. 安装Android 手机USB 驱动程序 安装完Android SDK后就可以把手机通过USB线缆连接至PC，开启手机电源后PC会提示安装设备驱动程序，不要让系统自动查找驱动程序安装，选择自定义驱动程序位置，因为已经安装了Android SDK，驱动程序的位置默认为Android SDK的安装目录下的usb_driver子目录，选择从这个目录安装驱动程序。<br/> <br/>3. 下载一个可用Recovery 程序 变砖的Android手机能否复活的关键就是Recovery程序，因为recovery程序意味着你可以再次刷新的ROM，相当于给PC重新安装操作系统。Android平台有很多可用的recovery程序，推荐使用最常见的Clock Recovery程序，注意recovery程序针对不同手机型号有不同版本的程序，下载时注意和手机型号匹配。把下载的recovery程序放在某一目录备用，比如c:\\recovery-RA-Magic-v2.3.1.img<br/><br/> 4. 关键步骤：重新给变砖的手机安装recovery 程序 在PC上打开命令提示符（Windows系统，开始，运行，输入cmd回车），输入 #adb devices 回车，如果返回一串序列号说明手机已经正常连接。在命令提示符使用cd命令切换到recovery程序所在的目录。然后输入下面的命令<br/> # adb reboot bootloader 回车后手机应该会进入fastboot模式，然后再执行下面的命令把recovery程序安装到手机上<br/> #fastboot flash recovery-RA-Magic-v2.3.1.img 回车后如果看到下面的提示就说明recovery程序已经成功安装。<br/> fastboot flash recovery recovery-RA-Magic-v2.3.1.img<br/> sending ‘recovery’ (4594 KB)… OKAY<br/> writing ‘recovery’… OKAY<br/> 拔掉手机USB连接线，关机，重新按指定键看看是否可以重新进入recovery模式了，到这一部手机已经成功复活了，现在可以重新刷机给手机再安装一个操作系统了。]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/329.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=329</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[RSYNC On Unix &amp; Linux]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2011-12-02T10:45:20+08:00</updated>
	  <published>2011-12-02T10:45:20+08:00</published>
		  <summary type="html"><![CDATA[RSYNC是Linux,UNIX系统下的数据镜像及备份工具,具有可使本地和远程两台主机的文件,目录之间,快速同步镜像,远程数据备份等功能.在同步过程中,可根据远程服务器上的数据变动,相应的删除或者更新本地机的数据,同步数据不用全部传送,大大提高同步及备份文件的速度.同时在网络安全方面,也可以设置为SSH传输模式. 远程主机(Rsync Server)可为RSYNC daemon模式,开启之后将开放tcp4 873 port,等待本地主机(Rsync client)的连接,连接时远程主机会进行认证,确认合法用户进入,便开始进行资料传输,在第一次传输时会把整个资料都备份同步到本地主机上,在下一次传输时,添加相应参数则可根据远程主机的数据变动来相应调整同步操作. 本文只是 RSYNC 软件的一个简单应用操作文档,主要是给初学者一个初步介绍. <br/>软件及平台<br/>FreeBSD 5.2 (Server and Client) <br/>Server IP:172.18.5.251 Hostname: freebsd-1<br/>Client IP:172.18.5.247 Hostname: freebsd-2<br/>apache_1.3.29<br/>rsync-2.5.7<br/>目的<br/>备份Rsync Server(172.18.5.251)上的 /usr/local/www/data-dist 目录下所有内容,到Rsync Client(172.18.5.247)的/backup/www 下 <br/><br/>安装及配置<br/><br/>一,Rsync Server <br/>Step 1: 安装<br/>freebsd-1#cd /usr/ports/net/rsync<br/>freebsd-1#make install clean<br/>Step 3: 配置rsyncd.conf<br/>freebsd-1#vi /usr/local/etc/rsyncd.conf //加入以下内容 <br/>[www]<br/>comment = web server backup<br/>path = /usr/local/www/data-dist<br/>auth users = tonny<br/>uid = nobody<br/>gid = nogroup<br/>secrets file = /usr/local/etc/rsyncd.secrets<br/>read only = no<br/><br/>Step 4: 配置rsyncd.secrets<br/>freebsd-1#vi /usr/local/etc/rsyncd.secrets //加入以下内容 <br/>tonny:123456 // 认证所需的用户名/密码<br/>freebsd-1#chmod 600 rsyncd.secrets<br/><br/>Step 5: 配置rc.conf<br/>freebsd-1#vi /etc/rc.conf //加入以下内容 <br/>rsyncd_enable=&#34;YES&#34;<br/><br/>Step 6: 启动 Rsync daemon模式<br/>freebsd-1#vi /usr/local/etc/rc.d/rsyncd.sh //加入以下内容 <br/>command_args=&#34;-4 --daemon&#34; &lt;&lt;&lt;--- 启用ipv4 协议<br/>freebsd-1#/usr/local/etc/rc.d/rsyncd.sh start<br/><br/>Step 7: 检查Rsync daemon启动状态<br/>freebsd-1# sockstat | grep rsync<br/>root rsync 440 3 dgram -&gt; /var/run/log<br/>root rsync 440 4 tcp4 *:873 *:*<br/>二,Rsync Client<br/>Step 1: 安装<br/>freebsd-2#cd /usr/ports/net/rsync<br/>freebsd-2#make install clean<br/><br/>Step 2: 建立备份目录<br/>freebsd-2#cd /<br/>freebsd-2#mkdir -p backup/www<br/><br/>Step 3: 配置rsyncd.secrets<br/>freebsd-2#vi /usr/local/etc/rsyncd.secrets //加入以下内容 <br/>123456 //Rsync Server上的认证密码,不用输入用户名<br/>freebsd-2#chmod 600 rsyncd.secrets<br/><br/>Step 4: 检查备份同步状态<br/>freebsd-2#/usr/local/bin/rsync -avzP --del&#101;te <br/>--password-file=/usr/local/etc/rsyncd.secrets tonny@172.18.5.251::www <br/>/backup/www/<br/><br/>---&gt;&gt;&gt; 将Rsync Server的Web页面,备份或同步到了Rsync Client的/backup/www下 <br/><br/>Step 5: Auto Rsync Shell:<br/>freebsd-2#cd /usr/local/etc/rc.d/ <br/>freebsd-2#chmod a-x rsyncd.sh<br/>freebsd-2#vi rsync.sh //加入以下内容<br/>#!/bin/sh<br/>/usr/local/bin/rsync -avzP --del&#101;te <br/>--password-file=/usr/local/etc/rsyncd.secrets tonny@172.18.5.251::www <br/>/backup/www/<br/>freebsd-2#chmod a+x rsync.sh<br/>freebsd-2#crontab -e //加入以下内容(每天下午5点半自动备份同步)<br/>30 17 * * * /usr/local/etc/rc.d/rsync.sh<br/>三,高级应用(Rsync With SSH)<br/>Rsync Server<br/>freebsd-1#/usr/bin/ssh-keygen -d<br/>Rsync Client<br/>freebsd-2#/usr/bin/ssh-keygen -d <br/>freebsd-2#scp ~/.ssh/id_dsa.pub 172.18.5.251:/root/.ssh/authorized_keys<br/>freebsd-2#ssh-agent csh 或 (ssh-agent bash) ---&gt;&gt;&gt; #echo $SHELL <br/>查看当前SHELL<br/>freebsd-2#ssh-add id_dsa ---&gt;&gt;&gt; 输入 passphase<br/><br/>freebsd-2#/usr/local/bin/rsync -avzP --del&#101;te -e ssh <br/>172.18.5.251:/usr/local/www/data-dist/ /backup/www/<br/>PS: 参数说明<br/>-a, --archive archive mode, equivalent to -rlptgoD <br/>//档案模式<br/>-v, --verbose <br/>//详细模式<br/>-z, --compress compress file data <br/>//压缩文件<br/>-P equivalent to --partial --progress <br/>//显示进度<br/>--del&#101;te<br/>This tells rsync to del&#101;te any files on the receiving side <br/>that<br/>aren&#39;t on the sending side. <br/>//保持远程机器的文件同步性<br/>-e ssh use SSH connection <br/>//使用SSH连接,保证数据安全<br/><br/>参考<br/><a href="http://rsync.samba.org/" target="_blank" rel="external">http://rsync.samba.org/</a> rsync 网站 <br/><a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/openssh.html" target="_blank" rel="external">http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/openssh.html</a> <br/>freebsd handbook手册<br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/328.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=328</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[centos 下使用 yum 安装ntfs-3g]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2011-11-25T12:09:57+08:00</updated>
	  <published>2011-11-25T12:09:57+08:00</published>
		  <summary type="html"><![CDATA[用的rpmforge 装的。<br/><br/># wget <a href="http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm" target="_blank" rel="external">http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm</a><br/># rpm -ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm<br/># rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-*<br/># yum --enablerepo=rpmforge install -y fuse fuse-ntfs-3g dkms dkms-fuse]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/327.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=327</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[天秤座蜜语]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=2" label="心情日记" /> 
	  <updated>2011-11-03T08:53:32+08:00</updated>
	  <published>2011-11-03T08:53:32+08:00</published>
		  <summary type="html"><![CDATA[如果有一天，天秤变得更冷漠了，请记得，天秤曾经要人陪的时候你都只说忙...如果有一天，天秤变得目中无人了，请记得，曾经也没有人把我放在心里... 如果有一天，天秤不再在乎你了，请记得，曾经也没人听过天秤的心事... 如果有一天，天秤不再对你笑了，请记得，你曾经也没有问天秤过的快不快乐。]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/sensibility/326.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=326</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[最不会谈恋爱的五星座]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=2" label="心情日记" /> 
	  <updated>2011-10-18T10:41:49+08:00</updated>
	  <published>2011-10-18T10:41:49+08:00</published>
		  <summary type="html"><![CDATA[NO.1天秤座<br/>　　天秤座天生就是“逃避专业户”，尤其是和感情有关的问题，天秤座在感情上一直都比较被动，基本上是走配合对方的路线，从感情一开始考虑要不要接受犹豫不决，一直到缘尽时无法抽身，他们很难理出头绪，如果在一段感情中他万般牺牲却又换得被辜负的下场，天秤们往往会消沉好一阵子，甚至可能逃离熟悉的环境到陌生的环境重新开始。<br/><br/><br/><br/>虽然说 都喜欢本分点的女孩。但好像真的对于这种性格 很难和本分的女孩发展到一起。<br/>大家都被动了 还怎么谈朋友和发展起来呢。。<br/>看来我只能和很主动激情 奔放 的人能谈的起来和发展]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/sensibility/325.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=325</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[Smack That--棚拍比基尼（打酱油视频作品） ]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=33" label="摄影作品" /> 
	  <updated>2011-09-07T22:12:07+08:00</updated>
	  <published>2011-09-07T22:12:07+08:00</published>
		  <summary type="html"><![CDATA[学校上棚拍课，因无引闪器，旁边打酱油拍段视频玩玩<br/><div class="UBBPanel"><div class="UBBTitle"><img src="http://blog.iloveu.sh.cn/images/flash.gif" alt="" style="margin:0px 2px -3px 0px" border="0"/>Flash动画</div><div class="UBBContent"><a id="temp77956_href" href="http://blog.iloveu.sh.cn/javascript:MediaShow('swf','temp77956','http://player.youku.com/player.php/sid/XMzAxNzk5NjE2/v.swf','600','400')"><img name="temp77956_img" src="http://blog.iloveu.sh.cn/images/mm_snd.gif" style="margin:0px 3px -2px 0px" border="0" alt=""/><span id="temp77956_text">在线播放</span></a><div id="temp77956"></div></div></div><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/photogragh/324.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=324</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[COM+ The run-time environment has detected an inco]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2011-09-01T10:34:44+08:00</updated>
	  <published>2011-09-01T10:34:44+08:00</published>
		  <summary type="html"><![CDATA[DeskTop Heap Exhaustion <br/><br/>Ran into another mine field the other day - blew my foot right off before I could even realize what was happening. <br/><br/>The client received this error: <br/><br/>The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, o&#114; other factors. Error in d:\nt\com\complus\src\comsvcs\threads\stathread.cpp(284), hr = 80070000: CSTAThread: CoGetApartmentID failed<br/><br/>The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, o&#114; other factors. Error in d:\nt\com\complus\src\comsvcs\threads\stathread.cpp(271), hr = 80070057: CSTAThread: CoInitializeEx failed<br/><br/>The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, o&#114; other factors. Error in d:\nt\com\complus\src\comsvcs\threads\stathreadpool.cpp(1230), hr = 8000ffff: CSTAThreadPool: Unable to get bind thread.<br/><br/>The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, o&#114; other factors. Couldn&#39;t get ApartmentID from STAPool<br/><br/>The COM+ component was configured to use a large number of threads on startup but this was working fine for several years in production. The workaround was to reduce the number of pre-allocated threads, but why was this issue surfacing?<br/><br/>As it turns out, the desktop heap size was the root cause. Each process running on the desktop is treated differently for &#34;Interactive User&#34; vs &#34;Non-interactive User&#34;. Windows reads a registry key to determine how to treat these groups of users:<br/><br/>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows --&gt; SharedSection = 1024,3072,512 <br/>You can read up more on this here <a href="http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx." target="_blank" rel="external">http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx.</a> <br/><br/>In the settings above, you can see that the heap is set to 3072 KB for Interactive user and just 512 KB for non-interactive users. This heap is used for system resource (e.g. thread handles). The small size prevents dllhost.exe from creating more threads.<br/><br/>By increasing the heap allocated for non-interactive users (from 512 --&gt;1024) the problem was solved.<br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/323.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=323</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[在FreeBSD上建立一个功能完整的邮件服务器]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2011-08-30T13:52:37+08:00</updated>
	  <published>2011-08-30T13:52:37+08:00</published>
		  <summary type="html"><![CDATA[第一部分：安装邮件服务器：postfix+vm-pop3d+openwebmail<br/><br/><br/>以下的安装在FreeBSD 5.2.1系统上完成 <br/><br/>1．更新 ports <br/><br/># cvsup -gL 2 -h cvsup.freebsdchina.org /usr/share/examples/cvsup/ports-supfile&nbsp;&nbsp;<br/><br/><br/>2. 安装 openssl+apache 服务器&nbsp;&nbsp;<br/><br/># cd /usr/ports/security/openssl <br/># make install <br/># make clean <br/># cd /usr/ports/www/apache2 <br/># make install&nbsp;&nbsp;<br/># make clean&nbsp;&nbsp;<br/># vi /etc/rc.conf <br/><br/>apache2_enable=&#34;YES&#34; <br/><br/><br/>3. 安装 openwebmail&nbsp;&nbsp;<br/><br/># cd /usr/ports/mail/openwebmail/&nbsp;&nbsp;<br/># make WITH_QUOTA=yes install <br/># make clean&nbsp;&nbsp;<br/><br/><br/>4. 安装 postfix ，在安装过程中用yes回答提出的问题 <br/><br/># cd /usr/ports/mail/postfix/&nbsp;&nbsp;<br/># make install <br/># make clean&nbsp;&nbsp;<br/><br/># vi /etc/rc.conf <br/><br/>为了能启动postfix加入：&nbsp;&nbsp;<br/><br/>sendmail_enable=&#34;YES&#34;&nbsp;&nbsp;<br/>sendmail_flags=&#34;-bd&#34;&nbsp;&nbsp;<br/>sendmail_pidfile=&#34;/var/spool/postfix/pid/master.pid&#34;&nbsp;&nbsp;<br/>sendmail_outbound_enable=&#34;NO&#34;&nbsp;&nbsp;<br/>sendmail_submit_enable=&#34;NO&#34;&nbsp;&nbsp;<br/><br/><br/>5. 安装 vm-pop3d&nbsp;&nbsp;<br/><br/># cd /usr/ports/mail/vm-pop3d&nbsp;&nbsp;<br/># make install&nbsp;&nbsp;<br/># make clean&nbsp;&nbsp;<br/><br/><br/>6. 配置 postfix&nbsp;&nbsp;<br/>&nbsp;&nbsp;<br/># vi /usr/local/etc/postfix/main.cf&nbsp;&nbsp;<br/><br/>添加： <br/><br/>myhostname = mail.hotsales.cn <br/>mydomain = mail.hotsales.cn <br/>virtual_alias_maps=hash:/usr/local/etc/postfix/virtual&nbsp;&nbsp;<br/>alias_maps=hash:/usr/local/etc/postfix/aliases&nbsp;&nbsp;<br/>default_privs=nobody&nbsp;&nbsp;<br/>allow_mail_to_commands = alias,forward,include&nbsp;&nbsp;<br/>allow_mail_to_files = alias,forward,include&nbsp;&nbsp;<br/><br/><br/>下面我加入一个 mail.hotsales.cn 的虚拟域，并添加一个用户baold <br/># vi /usr/local/etc/postfix/virtual&nbsp;&nbsp;<br/><br/>添加：&nbsp;&nbsp;<br/><br/>mail.hotsales.cn&nbsp;&nbsp;anything&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//之间用[tab] <br/>baold@mail.hotsales.cn&nbsp;&nbsp; baold.mail.hotsales.cn&nbsp;&nbsp;&nbsp;&nbsp; //之间用[tab]&nbsp;&nbsp;<br/><br/>执行下面的命令，生成 virtual.db：&nbsp;&nbsp;<br/><br/># cd /usr/local/etc/postfix/ <br/># postmap virtual <br/><br/># vi /usr/local/etc/postfix/aliases <br/><br/>添加：&nbsp;&nbsp;<br/><br/>baold.mail.hotsales.cn:/var/spool/virtual/mail.hotsales.cn/baold <br/><br/>执行下面的命令，生成 aliases.db:&nbsp;&nbsp;<br/><br/># cd /usr/local/etc/postfix <br/># postalias aliases <br/><br/>&nbsp;&nbsp;<br/><br/>7. 配置 vm-pop3d 使其开机自动执行&nbsp;&nbsp;<br/>&nbsp;&nbsp;<br/># cd /usr/local/etc/rc.d <br/># mv vm-pop3d.sh.sample vm-pop3d.sh <br/><br/>配置 openwebmail 支持 mail.hotsales.cn 域，创建下面的文件： <br/><br/># vi /usr/local/www/cgi-bin/openwebmail/etc/sites.conf/mail.hotsales.cn&nbsp;&nbsp;<br/><br/>=========================== mail.hotsales.cn ======================= <br/>auth_module auth_vdomain.pl <br/>auth_withdomain yes&nbsp;&nbsp;<br/>mailspooldir /var/spool/virtual/mail.hotsales.cn <br/>use_syshomedir no&nbsp;&nbsp;<br/>use_homedirspools no&nbsp;&nbsp;<br/>enable_autoreply no&nbsp;&nbsp;<br/>enable_setforward no&nbsp;&nbsp;<br/>enable_vdomain yes&nbsp;&nbsp;<br/>vdomain_admlist baold&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//这里设置了这个域的管理员 <br/>vdomain_maxuser 500&nbsp;&nbsp;<br/>vdomain_vmpop3_pwdpath /usr/local/etc/virtual <br/>vdomain_vmpop3_pwdname passwd&nbsp;&nbsp;<br/>vdomain_vmpop3_mailpath /var/spool/virtual&nbsp;&nbsp;<br/>vdomain_postfix_aliases /usr/local/etc/postfix/aliases&nbsp;&nbsp;<br/>vdomain_postfix_virtual /usr/local/etc/postfix/virtual&nbsp;&nbsp;<br/>vdomain_postfix_postalias /usr/local/sbin/postalias&nbsp;&nbsp;<br/>vdomain_postfix_postmap /usr/local/sbin/postmap&nbsp;&nbsp;<br/># quota设置部分 <br/>quota_module quota_du.pl <br/>quota_limit 52400&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //定义了邮箱大小 <br/>quota_threshold 85&nbsp;&nbsp;<br/>delmail_ifquotahit no&nbsp;&nbsp;<br/>delfile_ifquotahit no <br/>=========================== mail.hotsales.cn ======================= <br/><br/># mkdir -p /var/spool/virtual/mail.hotsales.cn&nbsp;&nbsp;<br/># chown nobody /var/spool/virtual/mail.hotsales.cn&nbsp;&nbsp;<br/># chgrp mail /var/spool/virtual/mail.hotsales.cn&nbsp;&nbsp;<br/><br/># mkdir -p /usr/local/etc/virtual/mail.hotsales.cn&nbsp;&nbsp;<br/># touch /usr/local/etc/virtual/mail.hotsales.cn/passwd&nbsp;&nbsp;<br/># chmod 644 /usr/local/etc/virtual/mail.hotsales.cn/passwd&nbsp;&nbsp;<br/><br/># htpasswd /usr/local/etc/virtual/mail.hotsales.cn/passwd baold <br/># chmod 755 /usr/local/www/cgi-bin/openwebmail/etc/users&nbsp;&nbsp;<br/><br/># sync <br/># reboot <br/><br/>8. 最后通过浏览器登陆到OPENWEBMAIL <br/><br/><a href="http://mail.hotsales.cn/cgi-bin/openwebmail/openwebmail.pl" target="_blank" rel="external">http://mail.hotsales.cn/cgi-bin/openwebmail/openwebmail.pl</a><br/><br/><br/><br/>第二部分：防病毒、垃圾邮件：clamav+amavisd-new+spam <br/><br/><br/>1．0 安装clamav: <br/><br/># cd /usr/ports/security/clamav <br/># make install <br/># make clean <br/><br/># vi /usr/local/etc/clamav.conf&nbsp;&nbsp;<br/>===============================clamav.conf============================ <br/># Comment o&#114; remove the line below. <br/># Example <br/>LogFile /var/log/clamav/clamd.log <br/>LogFileMaxSize 1M <br/>LogTime <br/>LogVerbose <br/>PidFile /var/run/clamav/clamd.pid <br/>DataDirectory /usr/local/share/clamav <br/>LocalSocket /tmp/clamd <br/>StreamMaxLength 10M <br/>MaxThreads 10 <br/>MaxDirectoryRecursion 15 <br/>User clamav <br/>ScanMail <br/>ScanArchive <br/>ScanRAR <br/>ArchiveMaxFileSize 10M <br/>ArchiveMaxRecursion 5 <br/>ArchiveMaxFiles 1000 <br/>ClamukoScanOnOpen <br/>ClamukoScanOnClose <br/>ClamukoScanOnExec <br/>ClamukoIncludePath /var/spool/virtual <br/>ClamukoMaxFileSize 6M <br/>ClamukoScanArchive <br/>===============================clamav.conf============================ <br/><br/>1.1 更新病毒库 <br/><br/># /usr/local/etc/rc.d/clamav-freshclam.sh start <br/><br/>2.0 安装amavisd-new <br/><br/># cd /usr/ports/security/amavisd-new <br/># make install <br/># make clean <br/><br/># cd /usr/local/etc <br/># mv amavisd.conf-dist amavisd.conf <br/># vi amavisd.conf <br/>============================== amavisd.conf =============================== <br/>$MYHOME = &#39;/var/amavis&#39;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# (default is &#39;/var/amavis&#39;) <br/>$mydomain = &#39;mail.hotsales.cn&#39;;&nbsp;&nbsp;&nbsp;&nbsp; # (no useful default) <br/>$daemon_user&nbsp;&nbsp;= &#39;vscan&#39;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (no default;&nbsp;&nbsp;customary: vscan o&#114; amavis) <br/>$daemon_group = &#39;vscan&#39;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (no default;&nbsp;&nbsp;customary: vscan o&#114; amavis) <br/><br/>$log_level = 0;&nbsp;&nbsp;<br/><br/>$sa_spam_subject_tag = &#39;***SPAM***&#39; <br/><br/>$virus_admin = &#34;root\@$mydomain&#34;; <br/>$spam_admin = &#34;baold\@$mydomain&#34;; <br/>$mailfrom_notify_admin&nbsp;&nbsp;&nbsp;&nbsp; = &#34;baold\@$mydomain&#34;; <br/>$mailfrom_notify_recip&nbsp;&nbsp;&nbsp;&nbsp; = &#34;baold\@$mydomain&#34;; <br/>$mailfrom_notify_spamadmin = &#34;baold\@$mydomain&#34;; <br/><br/>$inet_socket_bind = &#39;127.0.0.1&#39;; <br/>$forward_method = &#39;smtp:127.0.0.1:10025&#39;; <br/>$notify_method = $forward_method;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>$inet_socket_port = 10024; <br/>$max_servers&nbsp;&nbsp;=&nbsp;&nbsp;2; <br/><br/>[&#39;Clam Antivirus-clamd&#39;, <br/>&nbsp;&nbsp; \&amp;ask_daemon, [&#34;CONTSCAN {}\n&#34;, &#39;/tmp/clamd&#39;], <br/>&nbsp;&nbsp; qr/\bOK$/, qr/\bFOUND$/, <br/>&nbsp;&nbsp; qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ], <br/>============================== amavisd.conf =============================== <br/><br/>2.1 要启动clamav和amavisd-new需要配置一下/etc/rc.conf <br/><br/># vi /etc/rc.conf <br/><br/>spamd_enable=&#34;YES&#34; <br/>amavisd_enable=&#34;YES <br/>clamav_clamd_enable=&#34;YES&#34; <br/><br/><br/>3.0 由于在安装amavisd-new时spamassassin被一起安装了下面对其进行配置 <br/><br/>3.1 建立过滤规则： <br/><br/># cd /usr/local/etc/mail/spamassassin <br/># env LANG=C vi local.cf <br/>=============================== local.cf =============================== <br/># SpamAssassin config file for version x.xx <br/># generated by <a href="http://www.yrex.com/spam/spamconfig.php" target="_blank" rel="external">http://www.yrex.com/spam/spamconfig.php</a> (version 1.01) <br/><br/># How many hits before a message is considered spam. <br/>required_hits 4.0 <br/><br/># Whether to change the subject of suspected spam <br/>rewrite_subject 1 <br/><br/># Text to prepend to subject if rewrite_subject is used <br/>subject_tag *****SPAM***** <br/><br/># Encapsulate spam in an attachment <br/>report_safe 1 <br/><br/># Use terse version of the spam report <br/>use_terse_report 0 <br/><br/># Enable the Bayes system <br/>use_bayes 1 <br/><br/># Enable Bayes auto-learning <br/>auto_learn 1 <br/><br/># Enable o&#114; disable network checks <br/>skip_rbl_checks 1 <br/>use_razor2 0 <br/>use_dcc 0 <br/>use_pyzor 0 <br/><br/># Mail using languages used in these country codes will not be marked <br/># as being possibly spam in a foreign language. <br/># - chinese english&nbsp;&nbsp;<br/>ok_languages zh en&nbsp;&nbsp;<br/><br/># Mail using locales used in these country codes will not be marked <br/># as being possibly spam in a foreign language. <br/>ok_locales en zh <br/>score SUBJ_FULL_OF_8BITS 2 <br/>score NO_REAL_NAME 4.0 <br/>=============================== local.cf =============================== <br/><br/>3.2 下载新的垃圾邮件地址列表文件 <br/><br/># cd /usr/local/share/spamassassin <br/># fetch <a href="http://anti-spam.org.cn/rules/sa/55_diy_score.cf" target="_blank" rel="external">http://anti-spam.org.cn/rules/sa/55_diy_score.cf</a> <br/><br/><br/>4.0 对POSFIX进行配置，在他的配置文件中添加下面的一些内容 <br/><br/># vi /usr/local/etc/postfix/master.cf <br/><br/>---------------------- master.cf --------------------- <br/>smtp-amavis unix -&nbsp;&nbsp; -&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;smtp <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o smtp_data_done_timeout=1200 <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o disable_dns_lookups=yes <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>127.0.0.1:10025 inet n -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;smtpd <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o content_filter= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o local_recipient_maps= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o relay_recipient_maps= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o smtpd_restriction_classes= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o smtpd_client_restrictions= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o smtpd_helo_restrictions= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o smtpd_sender_restrictions= <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o mynetworks=127.0.0.0/8 <br/>---------------------- master.cf --------------------- <br/><br/># vi /usr/local/etc/postfix/main.cf <br/><br/>content_filter = smtp-amavis:[127.0.0.1]:10024 <br/><br/>好了，现在一个基于FreeBSD的功能相对完整的邮件服务器就建立起来了，虚拟域的管理员可以登陆OPENWEBMAIL进行用户的添加、删除等操作，虚拟用户可以通过OPENWEBMAIL修改自己的密码。<br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/322.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=322</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[在Redhat 9下实现双机热备和集群功能]]></title>
	  <author>
		 <name>冷酷到底</name>
		 <uri>http://blog.iloveu.sh.cn/</uri>
		 <email>seganert@iloveu.sh.cn</email>
	  </author>
	  <category term="" scheme="http://blog.iloveu.sh.cn/default.asp?cateID=5" label="技术交流" /> 
	  <updated>2011-08-30T13:51:14+08:00</updated>
	  <published>2011-08-30T13:51:14+08:00</published>
		  <summary type="html"><![CDATA[Red hat 9 linux的集群安装比较简单，需要的安装文件有以下几个：<br/>heartbeat-1.0.4-2.rh.9.um.1.i386.rpm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>heartbeat-pils-1.0.4-2.rh.9.um.1.i386.rpm&nbsp;&nbsp; <br/>heartbeat-stonith-1.0.4-2.rh.9.um.1.i386.rpm<br/>net-snmp-5.0.6-17.i386.rpm<br/>按顺序一次安装<br/>1、heartbeat-pils-1.0.4-2.rh.9.um.1.i386.rpm<br/>2、net-snmp-5.0.6-17.i386.rpm<br/>3、heartbeat-stonith-1.0.4-2.rh.9.um.1.i386.rpm<br/>4、heartbeat-1.0.4-2.rh.9.um.1.i386.rpm<br/>#rpm -ivh heartbeat-pils-1.0.4-2.rh.9.um.1.i386.rpm<br/>#rpm -ivh net-snmp-5.0.6-17.i386.rpm<br/>#rpm -ivh heartbeat-stonith-1.0.4-2.rh.9.um.1.i386.rpm<br/>#rpm -ivh heartbeat-1.0.4-2.rh.9.um.1.i386.rpm<br/>安装完成之后，开始配置主服务器。配置文件位于/etc/ha.d下，用rpm安装之后不会产生配置文件，需要从/usr/share/doc/heartbeat-1.0.4下，把ha.cf,,,,authkeys,,,,,,,,haresources,,,,三个文件cp到/etc/ha.d下面。<br/>文件在ha.cf是主要heartbeat的配置文件，authkeys是heartbeat的安全配置文件，haresource文件是heartbeat的资源文件<br/>其文件说明如下：<br/>ha.cf<br/>#############################################################################################<br/>#<br/># There are lots of options in this file.&nbsp;&nbsp;All you have to have is a set<br/># of nodes listed {&#34;node ...}<br/># and one of {serial, bcast, mcast, o&#114; ucast}<br/>#<br/># ATTENTION: As the configuration file is read line by line,<br/>#&nbsp;&nbsp;&nbsp;&nbsp; THE o&#114;DER OF DIRECTIVE MATTERS!<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp; In particular, make sure that the timings and udpport<br/>#&nbsp;&nbsp;&nbsp;&nbsp; et al are set before the heartbeat media are defined!<br/>#&nbsp;&nbsp;&nbsp;&nbsp; All will be fine if you keep them o&#114;dered as in this<br/>#&nbsp;&nbsp;&nbsp;&nbsp; example.<br/>#<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Note on logging:<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If any of debugfile, logfile and logfacility are defined then they<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will be used. If debugfile and/or logfile are not defined and<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logfacility is defined then the respective logging and debug<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; messages will be loged to syslog. If logfacility is not defined<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then debugfile and logfile will be used to log messges. If<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logfacility is not defined and debugfile and/or logfile are not<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defined then defaults will be used for debugfile and logfile as<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; required and messages will be sent there.<br/>#<br/># File to write debug messages to<br/>debugfile /var/log/ha-debug&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【heartbeat的debug信息记录文件】<br/>#<br/>#<br/>#&nbsp;&nbsp;File to write other messages to<br/>#<br/>logfile /var/log/ha-log&nbsp;&nbsp;&nbsp;&nbsp;【日志文件】<br/>#<br/>#<br/># Facility to use for syslog()/logger <br/>#<br/>logfacility local&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【记录日志在syslog中，可选项】<br/>#<br/>#<br/># A note on specifying &#34;how long&#34; times below...<br/>#<br/># The default time unit is seconds<br/>#&nbsp;&nbsp;10 means ten seconds<br/>#<br/># You can also specify them in milliseconds<br/>#&nbsp;&nbsp;1500ms means 1.5 seconds<br/>#<br/>#<br/># keepalive: how long between heartbeats?<br/>#<br/>keepalive&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;【每3秒发送一次keeplive消息】<br/>#<br/># deadtime: how long-to-declare-host-dead?<br/>#<br/>deadtime 15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【如果15秒没有收到keeplive消息将会认为节点已经失效】<br/>#<br/># warntime: how long before issuing &#34;late heartbeat&#34; warning?<br/># See the FAQ for how to use warntime to tune deadtime.<br/>#<br/>warntime 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【在日志中记录最后心跳last heartbeat-best 前的警告时间】<br/>#<br/>#<br/># Very first dead time (initdead)<br/>#<br/># On some machines/OSes, etc. the network takes a while to come up<br/># and start working right after you&#39;ve been rebooted.&nbsp;&nbsp;As a result<br/># we have a separate dead time for when things first come up.<br/># It should be at least twice the normal dead time.<br/>#<br/>initdead 60&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【如果节点的机器重启后，可能需要一些时间启动网络，这个时间与deadtime不一样，要单独对待】<br/>#<br/>#<br/># nice_failback:&nbsp;&nbsp;determines whether a resource will<br/># automatically fail back to its &#34;primary&#34; node, o&#114; remain<br/># on whatever node is serving it until that node fails.<br/>#<br/># The default is &#34;off&#34;, which means that it WILL fail<br/># back to the node which is declared as primary in haresources<br/>#<br/># &#34;on&#34; means that resources only move to new nodes when<br/># the nodes they are served on die.&nbsp;&nbsp;This is deemed as a<br/># &#34;nice&#34; behavior (unless you want to do active-active).<br/>#<br/>nice_failback on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【如果主节点失效之后，重新恢复后，不会再成为主节点，&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;只有当当前主节点失效，此节点才可恢复为主节点】<br/>#<br/># hopfudge maximum hop count minus number of nodes in config<br/>#hopfudge 1<br/># <br/>#<br/># Baud rate for serial ports...<br/># (must precede &#34;serial&#34; directives)<br/>#<br/>#baud 19200<br/>#<br/># serial serialportname ...<br/>#serial /dev/ttyS0 # Linux<br/>#serial /dev/cuaa0 # FreeBSD<br/>#serial /dev/cua/a # Solaris<br/>#<br/># What UDP port to use for communication?<br/>#&nbsp;&nbsp;[used by bcast and ucast]<br/>#<br/>#udpport 694<br/>#<br/># What interfaces to broadcast heartbeats over?<br/>#<br/>#bcast eth1&nbsp;&nbsp;# Linux<br/>#bcast eth1 eth2 # Linux<br/>#bcast le0&nbsp;&nbsp;# Solaris<br/>#bcast le1 le2&nbsp;&nbsp;# Solaris<br/>#<br/># Set up a multicast heartbeat medium<br/># mcast [dev] [mcast group] [port] [ttl] [loop]<br/>#<br/># [dev]&nbsp;&nbsp;device to send/rcv heartbeats on<br/># [mcast group] multicast group to join (class D multicast address<br/>#&nbsp;&nbsp; 224.0.0.0 - 239.255.255.255)<br/># [port]&nbsp;&nbsp;udp port to sendto/rcvfrom (no reason to differ<br/>#&nbsp;&nbsp; from the port used for broadcast heartbeats)<br/># [ttl]&nbsp;&nbsp;the ttl value for outbound heartbeats.&nbsp;&nbsp;This affects<br/>#&nbsp;&nbsp; how far the multicast packet will propagate.&nbsp;&nbsp;(1-255)<br/># [loop]&nbsp;&nbsp;toggles loopback for outbound multicast heartbeats.<br/>#&nbsp;&nbsp; if enabled, an outbound packet will be looped back and<br/>#&nbsp;&nbsp; received by the interface it was sent on. (0 o&#114; 1)<br/>#&nbsp;&nbsp; This field should always be set to 0.<br/>#&nbsp;&nbsp;<br/>#<br/>mcast eth1 225.0.0.22 694 10&nbsp;&nbsp;&nbsp;&nbsp;【使用组播225.0.0.22，端口694发送keeplive消息】<br/>#<br/># Set up a unicast / udp heartbeat medium<br/># ucast [dev] [peer-ip-addr]<br/>#<br/># [dev]&nbsp;&nbsp;device to send/rcv heartbeats on<br/># [peer-ip-addr] IP address of peer to send packets to<br/>#<br/>#ucast eth0 192.168.1.2<br/>#<br/>#<br/># Watchdog is the watchdog timer.&nbsp;&nbsp;If our own heart doesn&#39;t beat for<br/># a minute, then our machine will reboot.<br/>#<br/>#watchdog /dev/watchdog<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#34;Legacy&#34; STONITH support<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using this directive assumes that there is one stonith <br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; device in the cluster.&nbsp;&nbsp;Parameters to this device are <br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read from a configuration file. The format of this line is:<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stonith &lt;stonith_type&gt; &lt;configfile&gt;<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOTE: it is up to you to maintain this file on each node in the<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cluster!<br/>#<br/>#stonith baytech /etc/ha.d/conf/stonith.baytech<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STONITH support<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You can configure multiple stonith devices using this directive.<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The format of the line is:<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stonith_host &lt;hostfrom&gt; &lt;stonith_type&gt; &lt;params...&gt;<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;hostfrom&gt; is the machine the stonith device is attached<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to o&#114; * to mean it is accessible from any host. <br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;stonith_type&gt; is the type of stonith device (a list of<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;supported drives is in /usr/lib/stonith.)<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;params...&gt; are driver specific parameters.&nbsp;&nbsp;To see the<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format for a particular device, run:<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stonith -l -t &lt;stonith_type&gt; <br/>#<br/>#<br/># Note that if you put your stonith device access information in<br/># here, and you make this file publically readable, you&#39;re asking<br/># for a denial of service attack ;-)<br/>#<br/>#<br/>#stonith_host *&nbsp;&nbsp;&nbsp;&nbsp; baytech 10.0.0.3 mylogin mysecretpassword<br/>#stonith_host ken3&nbsp;&nbsp;rps10 /dev/ttyS1 kathy 0 <br/>#stonith_host kathy rps10 /dev/ttyS1 ken3 0 <br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/># Tell what machines are in the cluster<br/># node nodename ... -- must match uname -n<br/>node rh-9-a&nbsp;&nbsp;&nbsp;&nbsp;【定义节点名称，必须是节点的主机名】<br/>node rh-9-b<br/>#<br/># Less common options...<br/>#<br/># Treats 10.10.10.254 as a psuedo-cluster-member<br/>#<br/>#ping www.163.com www.google.com<br/>#<br/># Started and stopped with heartbeat.&nbsp;&nbsp;Restarted unless it exits<br/>#&nbsp;&nbsp;&nbsp;&nbsp;with rc=100<br/>#<br/>#respawn userid /path/name/to/run<br/>＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃＃<br/>authkeys<br/> <br/> <br/>#<br/># Authentication file.&nbsp;&nbsp;Must be mode 600<br/>#<br/>#<br/># Must have exactly one auth directive at the front.<br/># auth send authentication using this method-id<br/>#<br/># Then, list the method and key that go with that method-id<br/>#<br/># Available methods: crc sha1, md5.&nbsp;&nbsp;Crc doesn&#39;t need/want a key.<br/>#<br/># You normally only have one authentication method-id listed in this file<br/>#<br/># Put more than one to make a smooth transition when changing auth<br/># methods and/or keys.<br/>#<br/>#<br/># sha1 is believed to be the &#34;best&#34;, md5 next best.<br/>#<br/># crc adds no security, except from packet corruption.<br/>#&nbsp;&nbsp;Use only on physically secure networks.<br/>#<br/>auth 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【指定认证加密方式，3 表示加密方式的行号】<br/>#1 crc<br/>#2 sha1 HI!<br/>3 md5 Hello!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【使用md5加密，密码为hello!】 <br/> <br/> <br/>####################################################################################################################################<br/> <br/>#<br/># This is a list of resources that move from machine to machine as<br/># nodes go down and come up in the cluster.&nbsp;&nbsp;Do not include<br/># &#34;administrative&#34; o&#114; fixed IP addresses in this file.<br/>#<br/># &lt;VERY IMPORTANT NOTE&gt;<br/># The haresources files MUST BE IDENTICAL on all nodes of the cluster.<br/>#<br/># The node names listed in front of the resource group information<br/># is the name of the preferred node to run the service.&nbsp;&nbsp;It is<br/># not necessarily the name of the current machine.&nbsp;&nbsp;If you are running<br/># nice_failback OFF then these services will be started<br/># up on the preferred nodes - any time they&#39;re up.<br/>#<br/># If you are running with nice_failback ON, then the node information<br/># will be used in the case of a simultaneous start-up.<br/>#<br/># BUT FOR ALL OF THESE CASES, the haresources files MUST BE IDENTICAL.<br/># If your files are different then almost certainly something<br/># won&#39;t work right.<br/># &lt;/VERY IMPORTANT NOTE&gt;<br/>#<br/># <br/># We refer to this file when we&#39;re coming up, and when a machine is being<br/># taken over after going down.<br/>#<br/># You need to make this right for your installation, then install it in<br/># /etc/ha.d<br/>#<br/># Each logical line in the file constitutes a &#34;resource group&#34;.<br/># A resource group is a list of resources which move together from<br/># one node to another - in the o&#114;der listed.&nbsp;&nbsp;It is assumed that there<br/># is no relationship between different resource groups.&nbsp;&nbsp;These<br/># resource in a resource group are started left-to-right, and stopped<br/># right-to-left.&nbsp;&nbsp;Long lists of resources can be continued from line<br/># to line by ending the lines with backslashes (&#34;\&#34;).<br/>#<br/># These resources in this file are either IP addresses, o&#114; the name<br/># of scripts to run to &#34;start&#34; o&#114; &#34;stop&#34; the given resource.<br/>#<br/># The format is like this:<br/>#<br/>#node-name resource1 resource2 ... resourceN<br/>#<br/>#<br/># If the resource name contains an :: in the middle of it, the<br/># part after the :: is passed to the resource script as an argument.<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Multiple arguments are separated by the :: delimeter<br/>#<br/># In the case of IP addresses, the resource script name IPaddr is<br/># implied.<br/>#<br/># For example, the IP address 135.9.8.7 could also be represented<br/># as IPaddr::135.9.8.7<br/>#<br/># THIS IS IMPORTANT!!&nbsp;&nbsp;&nbsp;&nbsp; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv<br/>#<br/># The given IP address is directed to an interface which has a route<br/># to the given address.&nbsp;&nbsp;This means you have to have a net route<br/># set up outside of the High-Availability structure.&nbsp;&nbsp;We don&#39;t set it<br/># up here -- we key off of it.<br/>#<br/># The broadcast address for the IP alias that is cr&#101;ated to support<br/># an IP address defaults to the highest address on the subnet.<br/>#<br/># The netmask for the IP alias that is cr&#101;ated defaults to the same<br/># netmask as the route that it sel&#101;cted in in the step above.<br/>#<br/># The base interface for the IPalias that is cr&#101;ated defaults to the<br/># same netmask as the route that it sel&#101;cted in in the step above.<br/>#<br/># If you want to specify that this IP address is to be brought up<br/># on a subnet with a netmask of 255.255.255.0, you would specify<br/># this as IPaddr::135.9.8.7/24 .&nbsp;&nbsp;<br/>#<br/># If you wished to tell it that the broadcast address for this subnet<br/># was 135.9.8.210, then you would specify that this way:<br/>#&nbsp;&nbsp;IPaddr::135.9.8.7/24/135.9.8.210<br/>#<br/># If you wished to tell it that the interface to add the address to<br/># is eth0, then you would need to specify it this way:<br/>#&nbsp;&nbsp;IPaddr::135.9.8.7/24/eth0<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; And this way to specify both the broadcast address and the<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interface:<br/>#&nbsp;&nbsp;IPaddr::135.9.8.7/24/eth0/135.9.8.210<br/>#<br/># The IP addresses you list in this file are called &#34;service&#34; addresses,<br/># since they&#39;re they&#39;re the publicly advertised addresses that clients<br/># use to get at highly available services.<br/>#<br/># For a hot/standby (non load-sharing) 2-node system with only<br/># a single service address, <br/># you will probably only put one system name and one IP address in here.<br/># The name you give the address to is the name of the default &#34;hot&#34;<br/># system.<br/>#<br/># Wh&#101;re the nodename is the name of the node which &#34;normally&#34; owns the<br/># resource.&nbsp;&nbsp;If this machine is up, it will always have the resource<br/># it is shown as owning.<br/>#<br/># The string you put in for nodename must match the uname -n name<br/># of your machine.&nbsp;&nbsp;Depending on how you have it administered, it could<br/># be a short name o&#114; a FQDN.<br/>#<br/>#-------------------------------------------------------------------<br/>#<br/># Simple case: One service address, default subnet and netmask<br/>#&nbsp;&nbsp;No servers that go up and down with the IP address<br/>#<br/>#just.linux-ha.org 135.9.216.110<br/>#<br/>#-------------------------------------------------------------------<br/>#<br/># Assuming the adminstrative addresses are on the same subnet...<br/># A little more complex case: One service address, default subnet<br/># and netmask, and you want to start and stop http when you get<br/># the IP address...<br/>#<br/>#just.linux-ha.org 135.9.216.110 http<br/>#-------------------------------------------------------------------<br/>#<br/># A little more complex case: Three service addresses, default subnet<br/># and netmask, and you want to start and stop http when you get<br/># the IP address...<br/>#<br/>#just.linux-ha.org 135.9.216.110 135.9.215.111 135.9.216.112 httpd<br/>#-------------------------------------------------------------------<br/>#<br/># One service address, with the subnet, interface and bcast addr<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; explicitly defined.<br/>#<br/>#just.linux-ha.org 135.9.216.3/28/eth0/135.9.216.12 httpd<br/>#<br/>#-------------------------------------------------------------------<br/>#<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; An example wh&#101;re a shared filesystem is to be used.<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Note that multiple aguments are passed to this script using<br/>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the delimiter &#39;::&#39; to separate each argument.<br/>#<br/>rh-9-a&nbsp;&nbsp;11.1.1.96/24/eth0&nbsp;&nbsp;&nbsp;&nbsp; 【定义主节点使用的公网IP，掩码和接口名称】<br/>#<br/># Regarding the node-names in this file:<br/>#<br/># They must match the names of the nodes listed in ha.cf, which in turn<br/># must match the `uname -n` of some node in the cluster.&nbsp;&nbsp;So they aren&#39;t<br/># virtual in any sense of the word.<br/>#<br/> <br/> <br/>根据情况更改配置文件，两台服务器的heartbeat配置必须一样，这样才能启动heartbeat,<br/>启动heartbeat:<br/>/etc/rc.d/init.d/heartbeat start [stop|restart]<br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.iloveu.sh.cn/article/technology/321.html" /> 
	  <id>http://blog.iloveu.sh.cn/default.asp?id=321</id>
  </entry>	
		
</feed>

