IIS应用程序池频繁崩溃的问题
昨天协助一个朋友处理了他们公司服务器上面IIS应用程序池频繁崩溃的问题。
1. 错误日志文件如下
【注意】 该文件位于 C:\WINDOWS\system32\LogFiles\HTTPERR 目录下
另外,IIS还会有一个日志,就是下面属性窗口中指定的
分析下来,这个错误日志中主要包含了三类错误
- 2009-05-30 10:43:27 203.208.60.137 48675 210.192.111.49 80 HTTP/1.1 GET /showroom/vulpes/product-detail/LRPST/Rubber-Series - 2006987705 Connection_Abandoned_By_AppPool MyApplicationPool :这个错误是说,连接被强制抛弃。
- 2009-05-30 11:25:50 211.167.234.158 13284 210.192.111.49 80 - - - - - Timer_ConnectionIdle -
- 2009-05-30 10:53:05 211.139.116.67 27664 210.192.111.49 80 - - - - - Timer_MinBytesPerSecond - 这两个错误是与时间有关的。
2. 分析错误原因
对于Timer_ConnectionIdle和Timer_MinBytesPerSecond ,可以考虑下面的处理措施
IIS6.0系统日志中出现此错误Timer_MinBytesPerSecond,Timer_ConnectionIdle
Description: The Error means The connection with the server has been terminated.
问题描述:这个错误是由于服务器连接被中断导致的。
If you check out the C:"Windows"system32"LogFiles"HTTPERR"httperr*.log files on the distribution server, you'll likely see either Timer_MinBytesPerSecond errors or Timer_ConnectionIdle errors. These are caused by IIS' default settings, contained within its metabase, which define the minimum traffic flow rate for a connection to be kept alive and the maximum idle time allowed before a connection is dropped. For some reason, SUS servers seem to take their good old time while downloading updates, and these parameters are exceeded and the distribution server drops 'em.
这个问题是由于在某些应用下,IIS的默认设置不当的
1) From IIS Manager, right click on the Internet Information Server (IIS) Manager root level folder and go to Properties. Check the box to enable direct metabase editing. Click OK.
1)打开Internet 信息服务(IIS)管理器,右键点“我的计算机”——属性,选上“允许直接编辑配置数据库(N)”,确定。
2) Open the C:\Windows\system32\inetsrv\MetaBase.xml file in Notepad. Do a search for "MinFileBytesPerSec". Change the setting for MinFileBytesPerSec from 240 to 0. Do another search, this time for "ConnectionTimeout" to be 600. Save changes and exit.
2)编辑C:"Windows"system32"inetsrv"MetaBase.xml文件,把MinFileBytesPerSec 参数值从240改为0,把ConnectionTimeout参数设成600。
3) Restart the IIS Admin service to effect the changes.
对于Connection_Abandoned_By_AppPool 的错误,经过分析大多都是因为应用程序本身的异常导致了程序池的工作进程不断重启。为此,我用了一个global.asax文件,来接管所有未处理的异常
<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script RunAt="server">
protected void Application_Error(object sender, EventArgs e)
{
string errorLog = Server.MapPath("Error.log");
FileStream fs = new FileStream(errorLog,FileMode.Append,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("时间:{0},错误消息:{1},地址:{2}", DateTime.Now.ToString(), Server.GetLastError().InnerException.Message,Request.Url.AbsolutePath);
Server.ClearError();
sw.Close();
}
</script>
同时,一定要确保web.config中将调试模式设置为false