www.sanotes.net
2010年03月12日

现在位置: 首页 > 所有 2008年09月 文章

使用sudo的一些问题

2008年09月27日 添加评论 1199次浏览

FAQ

收藏、分享这篇文章!

...
分类:Linux | 阅读全文

HTTP pipeline 和 persistent connection

2008年09月19日 添加评论 1340次浏览

来自Laurence:浏览器pipeline
IE, Firefox, and Safari ship with HTTP pipelining disabled by default; Opera is the only browser I know of that enables it. No pipelining means each request has to be answered and its connection freed up before t...

分类:HTTP | 阅读全文

24个最好免费下载电子书(Ebooks)的网站

2008年09月18日 添加评论 1298次浏览

24个最好免费下载电子书(Ebooks)的网站

收藏、分享这篇文章!

...
分类:链接 | 阅读全文

js脚本的并行download

2008年09月13日 添加评论 1342次浏览

今天Laurence 给我看了一个ppt,我觉得很好,因为默认js都是顺序加载的,但是通过一定的设置后,是可以并行加载的,这个对于减少js的加载等待很有帮助。
ppt http://stevesouders.com/docs/oscon...

分类:Apache | 阅读全文

Apache多虚拟主机的简单配置

2008年09月11日 添加评论 1598次浏览

作者:FinalBSD
日期:2008-09-11
原文地址:http://www.sanotes.net/html/y2008/181.html
需求:
一台apache上要服务很多的虚拟主机,这些虚拟主机的域名具有规律性,比如说是:xxx.example.com
作者:FinalBSD
日期:2008-09-11
原文地址:http://www.sanotes.net/html/y2008/181.html
需求:
一台apache上要服务很多的虚拟主机,这些虚拟主机的域名具有规律性,比如说是:xxx.example.com

实现:
使用mod_rewrite进行跳转
优点:
* 不需要为每一个虚拟主机配置一段;
* 新增了vhost不需要重启apache,只需要编辑vhosts.map即可;

缺点:
* 无法为特定的vhosts设定具体配置

配置:

RewriteEngine On
RewriteMap lowercase int:tolower

RewriteMap vhost txt:/usr/local/etc/apache22/vhost.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1

/usr/local/etc/apache22/vhost.map的内容是:

site1.example.com /usr/local/www/data/1
site2.example.com /usr/local/www/data/2
site3.example.com /usr/local/www/data/3
site4.example.com /usr/local/www/data/4
site5.example.com /usr/local/www/data/5
site6.example.com /usr/local/www/data/6

原理:
1.构建2个映射表,分别是lowercase和vhost;
2.对每个URL进行RewriteCond检查,比如http://Site5.Example.com/index.html
2.1 第一条RewriteCond:

RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$

1)这里首先查询lowercase表,lowercase表属于int类型,使用apache内部函数tolower将

key:Site5.Example.com替换为value:site5.example.com.

2)查完之后用查询到的Value进行RewriteCond判断

input='site5.example.com' pattern='^(.+)$' => matched

2.2 第二条RewriteCond:

RewriteCond ${vhost:%1} ^(/.*)$

1)这里首先查询vhost表,vhost表属于txt类型,key:site5.example.com对应value为/usr/local/www/data/5.
2)查完之后用查询到的value进行RewriteCond判断

input='/usr/local/www/data/5' pattern='^(/.*)$' => matched

3.在2条RewriteCond都符合的情况下,执行RewriteRule规则:

RewriteRule ^/(.*)$ %1/$1

将/下面的所有文件重写到%1/$1,这里的
%1:是上一个RewriteCond的value:/usr/local/www/data/5
$1:即(.*)的括号里面的内容,即请求的文件名
最终的执行为:

rewrite '/index.html' -> '/usr/local/www/data/5/index.html'

可以看详细的日志了解整个过程。
requested uri /index.html
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (3) applying pattern '^/(.*)$' to uri '/index.html'
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (5) map lookup OK: map=lowercase key=site5.example.com -> val=site5.example.com
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (4) RewriteCond: input='site5.example.com' pattern='^(.+)$' => matched
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (6) cache lookup FAILED, forcing new map lookup
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (5) map lookup OK: map=vhost[txt] key=site5.example.com -> val=/usr/local/www/data/5
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (4) RewriteCond: input='/usr/local/www/data/5' pattern='^(/.*)$' => matched
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (2) rewrite '/index.html' -> '/usr/local/www/data/5/index.html'
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (2) local path result: /usr/local/www/data/5/index.html
192.168.1.2 - - [11/Sep/2008:22:09:25 +0800] [site5.example.com/sid#2840feb8][rid#28cbe050/initial] (1) go-ahead with /usr/local/www/data/5/index.html [OK]

Reference:Apache模块 mod_rewrite

更强大的方法:使用mod_vhost_alias(由Tonny推荐):

UseCanonicalName Off
VirtualDocumentRoot /usr/local/www/data/%0

那么对http://site1.example.com/file.html的请求将会返回文件/usr/local/www/data/site1.example.com/file.html
Reference:Apache模块 mod_vhost_alias

Appendix:比较专业的模块(i_amok推荐)

http://www.oav.net/projects/mod_vhs/

如要在首页显示图片可以用此替换上句-->
分类:Apache | 阅读全文

F5的风扇故障

2008年09月10日 添加评论 1261次浏览

今天偶然发现F5上有大量报警:
Chassis fan 101:status (0) is bad.
Chassis fan 102:status (0) is bad.
Chassis fan 103:status (0) is bad.
Chassis fan 104:status (0) is bad.
Chassis fan 105:status (0) is bad.
今天偶然发现F5上有大量报警:
Chassis fan 101:status (0) is bad.
Chassis fan 102:status (0) is bad.
Chassis fan 103:status (0) is bad.
Chassis fan 104:status (0) is bad.
Chassis fan 105:status (0) is bad.
Chassis fan 106:status (0) is bad.
开始觉得这种报警是误报,于是没太在意,因为反正还有Slave在,因此我顺便检查了一下Slave,发现居然一样的错误非常多,顿时我傻眼了。

于是,重新检查了一下:
#system_check
010d0005:3: Chassis fan 101:status (0) is bad.
010d0005:3: Chassis fan 102:status (0) is bad.
010d0005:3: Chassis fan 103:status (0) is bad.
010d0005:3: Chassis fan 104:status (0) is bad.
010d0005:3: Chassis fan 105:status (0) is bad.
010d0005:3: Chassis fan 106:status (0) is bad.

# b platform
CHASSIS FAN
(101) DOWN! (102) DOWN! (103) DOWN! (104) DOWN! (105) DOWN! (106) DOWN!

Master和Slave的6个风扇全部为DOWN。靠,简直是噩梦。
让IDC同事马上到机房检查情况,发现也是很多报警信息在液晶屏上。而且机房通风情况良好,b platform输出的CPU温度为50摄氏度样子。

联系厂家,按照惯例,我们保存了配置,收集了相关信息。开始重启Slave,准备进行EUD检查(End User Diagnostics)。结果发现重启后起码10分钟没起来,无奈再次重启,很幸运,这次顺利起来了。再次进入系统发现6个Fan都是Active,

Shit!一次可耻的误报!

切换Master,在Master上进行和Slave一样的操作,遇到一样的问题,重启2次后问题解决。到此,警报解除,我们都如释重负。

PS:发现2台F5都有大量报警时,我非常紧张,想到了很多严重的后果。明天要好好做下F5的自动报警。

如要在首页显示图片可以用此替换上句-->
分类:F5 | 阅读全文

EditPlus结合SVN使用

2008年09月04日 添加评论 1358次浏览

http://www.toplee.com/blog/615.html

收藏、分享这篇文章!

...