预览模式: 普通 | 列表

最近在服务器的日志中出现许多Web事件的警告信息。时间间隔非常规律,一分钟出现一至两次,其错误信息摘取关键部分如下:

事件类型:    警告
事件来源:    ASP.NET 2.0.50727.0
事件种类:    Web 事件
事件 ID:    1309
日期:        2008-1-13
事件:        14:43:41
用户:        N/A
描述:
事件代码: 3005
事件消息: 发生了未处理的异常。
事件时间: 2008-1-13 14:43:41
事件时间(UTC): 2008-1-13 6:43:41
事件 ID: f94c4a45b696449db6df2a3d571059e3
事件序列: 110527
事件匹配项: 9121
事件详细信息代码: 0

异常信息:
    异常类型: HttpException
    异常消息: 无法使用前导 .. 在顶级目录上退出。
请求信息:
    请求 URL: http://dormforce.net/Music/*****.aspx?id=7085&id2=633358175566250000
    请求路径: /Music/*****.aspx
    用户主机地址: 66.249.66.38
    用户: 
    是否已经过身份验证: False
    身份验证类型: 
    线程帐户名: NT AUTHORITY\NETWORK SERVICE
线程信息:
    线程 ID: 1
    线程帐户名: NT AUTHORITY\NETWORK SERVICE
    是否正在模拟: False
    堆栈跟踪:    在 System.Web.Util.UrlPath.ReduceVirtualPath(String path)
   在 System.Web.Util.UrlPath.Reduce(String path)
   在 System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative)
   在 System.Web.HttpResponse.ApplyAppPathModifier(String virtualPath)
   在 System.Web.UI.HtmlControls.HtmlForm.GetActionAttribute()
   在 System.Web.UI.HtmlControls.HtmlForm.RenderAttributes(HtmlTextWriter writer)
   在 System.Web.UI.HtmlControls.HtmlControl.RenderBeginTag(HtmlTextWriter writer)
   在 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
   在 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   在 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   在 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
   在 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   在 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   在 System.Web.UI.Page.Render(HtmlTextWriter writer)
   在 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   在 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   在 System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

最初以为是源代码中的问题,打开源码仔细分析没有找到逻辑上的错误,不得其解。查找主机的IP地址,发现居然是GoogleBot 搜寻引擎机器人,后来在网上看到一篇文章,Get GoogleBot to crash your .NET 2.0 site

查看更多...

分类:asp.net | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 89

服务器的大用户量的承载方案

一、前言
二、编译安装
三、 安装MySQL、memcache
四、 安装Apache、PHP、eAccelerator、php-memcache
五、 安装Squid
六、后记

 

一、前言,准备工作
      当前,LAMP开发模式是WEB开发的首选,如何搭建一个高效、可靠、稳定的WEB服务器一直是个热门主题,本文就是这个主题的一次尝试。
我们采用的架构图如下:

查看更多...

分类:squid | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 174

squid 2.6版安装配置

1、 下载squid 2.6版的软件
官方网址:http://www.squid-cache.org/ 
到那里去下载最新版的 squid软件
将此软件包上传至 web主机。并在主机上将下载下来的软件包解压。如果你下载的 gz
包的话。就用tar    zxvf   XXXXX.gz (XXXX.gz 为你下载来的软件包名)  如果你下载的是 gz2
包。那么就用  tar    jxvf   XXXX.gz2(XXXX.gz2 为你下载来的软件包名)
2、 进入你解压出来的那个目录。然后执行编译安装
./configure  
--exec_prefix=/usr/local/squid  
--bindir=/usr/sbin  
--libexecdir=/usr/lib/squid  
--sysconfdir=/etc/squid  
--enable-poll  
--enable-snmp  
--enable-removal-policies="heap,lru"  
--enable-storeio="aufs,coss,diskd,null,ufs"  
--enable-ssl  
--with-openssl=/usr/kerberos  
--enable-delay-pools  
--enable-linux-netfilter  
--with-pthreads --enable-auth="basic"  
--with-winbind-auth-challenge  
--enable-useragent-log  
--enable-referer-log  
--disable-dependency-tracking  
--enable-cachemgr-hostname=localhost  
--disable-ident-lookups  
--enable-truncate  
--enable-underscores  
--datadir=/usr/share/squid  
--enable-basic-auth-helpers="NCSA"  
--enable-err-language="Simplify_Chinese"  
--enable-default-err-language="Simplify_Chinese"
编译完后再执行
make
make install
好了。安装完毕后,修改目录权限,默认是以"nobody"用户运行squid.所以我们要为
/usr/local/squid/var  设置相应的权限,否则会报以下错误
FATAL: Failed to make swap directory /usr/local/squid/var/cache: (13) Permission denied
Squid Cache (Version 2.5.STABLE13): Terminated abnormally.
CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 4
或者以下错误
FATAL: Cannot open '/usr/local/squid/var/logs/access.log' for writing.
         The parent directory must be writeable by the
         user 'nobody', which is the cache_effective_user
         set in squid.conf.
最简单的处理办法就是
chown -R nobody:nobody /usr/local/squid/var
ok,生成缓存目录
/usr/local/squid/sbin/squid -z
然后启动squid,测试一下是否成功
/usr/local/squid/bin/Runcache  
默认端口是3128,用ie测试一下,如果能看到中文的拒绝访问错误提示,就说明安装正确,
并且已经使用.
 
以后就可以直接/usr/local/squid/bin/Runcache   &  后台运行即可,  
现在我们开始讲如何配置 squid.conf 文件
visible_hostname localhost #你的主机名可以是localhost
http_port 211.XX.XX.XXX:80 vhost vport #你需要做 squid服务器的IP及端口号
icp_port 0
cache_mem 900 MB #squid  所使用的内存
cache_swap_low 90 #缓存最低使用
cache_swap_high 95 #缓存最高使用
maximum_object_size 20000 KB #当大于200000K 时不对文件进
maximum_object_size_in_memory 4096 KB #放入内存的最小大小
cache_dir ufs /dev/shm/tmp 1000 16 256 #这里我们会在后面再讲
  
cache_store_log none
cache_vary on #apache 的一个新特性。
emulate_httpd_log on #日志
cache_mgr tpsys@126.com #设置管理员的邮箱
logfile_rotate 0 #日志不保存
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h"
"%{User-Agent}>h" %Ss:%Sh #日志格式
pid_filename /home/squid/squid.pid #pid文件
cache_log /home/squid/var/logs/cache.log #日志
access_log /home/squid/var/logs/access.log combined #日志
acl all src 0.0.0.0/0.0.0.0   #允许所有地址访问
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe .rar  对这一些
扩名的文件不缓存
cache deny QUERY
acl picurl url_regex -i \.bmp$ \.png$ \.jpg$ \.gif$ \.jpeg$ \.rm$ #主要是防盗连。
acl mystie1 referer_regex -i .5i.la #对5i.la防盗连
http_access allow mystie1 picurl
acl mystie3 referer_regex -i .wg333.com#对 wg333.com防盗连
http_access allow mystie3 picurl
acl mystie4 referer_regex -i .99doc.com#对99doc.com防盗连
http_access allow mystie4 picurl
acl mystie2 referer_regex -i .orasos.com#对 orasos.com防盗连
http_access allow mystie2 picurl
acl nullref referer_regex -i ^$
http_access allow nullref
acl hasref referer_regex -i .+
http_access deny hasref picurl
  
acl Safe_ports port 80 # http #  开放80端口允许进来。
acl Safe_ports port 21 # ftp #  开放21端口允许进来。
http_access deny !Safe_ports
tcp_recv_bufsize 65535 bytes
acl OverConnLimit maxconn 36   #同一个客户端最多只允许连入36 个连接
http_access deny OverConnLimit
acl tianya referer_regex -i tianya
http_access deny tianya
deny_info http://www.baidu.com/logs.gif tianya
  
refresh_pattern -i .html 1440 100% 129600 reload-into-ims   #对HTML 进行缓存
refresh_pattern -i .shtml 1440 100% 129600 reload-into-ims #对SHTML进行缓存
refresh_pattern -i .htm 1440 100% 129600 reload-into-ims #对HTM进行缓存
refresh_pattern -i .gif 1440 100% 129600 reload-into-ims #对GIF进行缓存
refresh_pattern -i .swf 1440 100% 129600 reload-into-ims #对SWF进行缓存
refresh_pattern -i .png 1440 100% 129600 reload-into-ims #对 PNG进行缓存
refresh_pattern -i .bmp 1440 100% 129600 reload-into-ims #对BMP进行缓存
refresh_pattern -i .css 1440 100% 129600 reload-into-ims#对 CSS进行缓存  
refresh_pattern -i .jpg 1440 100% 129600 reload-into-ims #对 JPG 进行缓存
refresh_pattern -i .txt 1440 100% 129600 reload-into-ims #对TXT进行缓存
refresh_pattern -i .rhtml 1440 100% 129600 reload-into-ims #对RHTML进行缓存
refresh_pattern -i .xml 1440 100% 129600 reload-into-ims #对XML进行缓存
#以下内容和squid 2.5有所不一样。2.6 中需要通过 cache_peer来设定指向主机,如果你需要
做虚拟主机的话。你可以省略 name=a  这个关建字  举例说明
cache_peer 192.168.8.105 parent 80 0 no-query originserver name=a  
#每一个name 关建字。必须要和下面的 cache_peer_domain  一起来使用。
cache_peer 192.168.8.161 parent 888 0 no-query originserver name=b
#这里的888  和  808  分别指的是你的apache  或者 IIS  绑定的主机头里的端口号。我们这里
是为了安全,所以不采用80端口
cache_peer 192.168.8.88  parent 808 0 no-query originserver name=c
#808后面的0 为 icp_port 0  这什值。我们目前用不到。所以先不管。你只要写0 就行
cache_peer_domain b .orasos.com
#比如这一句话的意思就是。当orasos.com这外域来访问 squid时。Squid通确定他使用的是
什么域名  这里使用的是 orasos.com  然后来查询 cache_peer_domain  中有没有这个域名。如
果有则取这个域名的cache_peer的name  值   我们这里是b  然后再和cache_peer中去比对。
有没有name=b这个主机指向。如果有,就从这个主机指向那里取数据
cache_peer_domain a .5i.la
cache_peer_domain a .99doc.com
cache_peer_domain a .wg333.com
cache_effective_user nobody
cache_effective_group nobody
好了。写了这么多。安装和配置就搞定了。
如果你能看的明白话。我想你装一个Squid起来的话。是绝对不会在问题了的。

 

分类:squid | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 205

批量清除Squid缓存的小工具

很实用的一个清除squid缓存的小工具:
http://www.wa.apana.org.au/~dean/squidpurge/

wget http://www.wa.apana.org.au/~dean/sources/purge-20040201-src.tar.gz
tar zxvf purge-20040201-src.tar.gz

查看更多...

分类:squid | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 201

rhel5基本命令

2 基本命令使用


2.1 VI

查看更多...

分类:squid | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 274

服务器应用程序不可用的解决方法

重启win2003后,打了各式各样的补丁,发现以前即拖即用的方法不适用了,打开的.net页面全是服务器应用程序不可用,郁闷了半天,也上网找了半天,才发现是程序池的问题,解决方法如下:

首先要确认启动的首页是否已定义,默认是没有index.aspx 页面的,要加上去,然后,确认下WEB应用程序是否在根目录下面,比如,你把IIS的根目录改指到另一个地址,会发生这样的错误

最后,在 应用程序池-->属性-->标识-->预定义帐户 为 本地系统

又或者麻烦一点,新建一个程序池:
1. 单击“开始”,指向“程序”,然后单击“控制面板”。
2. 双击“管理工具”,然后双击“Internet 信息服务 (IIS)”。
3. 右键单击“应用程序池”,指向“新建”,然后单击“应用程序池”。
4. 在“应用程序池 ID”文本框中键入 AppPool1。
5. 单击“确定”。

将应用程序分配到应用程序池
1. 单击“开始”,指向“程序”,然后单击“控制面板”。
2. 双击“管理工具”,然后双击“Internet 信息服务 (IIS)”。
3. 双击“Web 站点”。
4. 双击“默认 Web 站点”。
5. 右键单击“DebugApp1”,然后单击“属性”。
6. 在“主目录”标签中的“应用程序池”列表框中选择“AppPool1”,然后单击“确定”。
分类:asp.net | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 412

SQL由列转行示例

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetType]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetType]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Get_Data]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)

查看更多...

Tags: mssql sql2000

分类:MSSQL | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 314

在ASP.NET中自动给URL地址加上超链接

作为一个程序员,在完成设计后还要根据程序的情况以及用户的反映不断对程序进行改进,这样才能不断地完善自己的作品。笔者在制作完软件商务网的论坛后,发现人们总喜欢在帖子中加上各种有用的URL链接或Email地址。而笔者当初设计时没有考虑到这一点,使得这些URL链接或Email地址只能以文字的形式而并不是以超链接的形式显示,其它浏览帖子的人还必须把这些URL链接拷贝到浏览器中或把Email地址拷贝到Outlook中才能转到相应的链接地址或发送电子邮件到相应的Email地址。

  发现这个问题后,笔者即着手进行解决。首先是从网上查找有关这方面的现在代码,可惜的是,在搜索引擎上反复查找也没有发现这方面的文章。后来一想,干脆自己用ASP.NET编写一个。

  要想自动显示超链接的关键在于如何能正确识别超链接,毫无疑问的,最有效的方法是用正则表达式。正则表达式是由普通字符(例如字符 a 到 z)以及特殊字符(称为元字符)组成的文字模式,描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。.NET基础类库中包含有一个名字空间和一系列可以充分发挥规则表达式威力的类,用它就可以自动探测出文字中的URL链接或Email地址。下面具体讲讲如何用ASP.NET(C#)一步步实现我们的目的:

  首先,要想在ASP.NET(C#)中使用正则表达式就必须把 System.Text.RegularExpressions 这个命名空间包含进来:

using System.Text.RegularExpressions;
  第二步是用正则表达式识别URL超链接:

查看更多...

分类:asp.net | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 318