IIS SQL连接在重载下失败;重置IIS暂时修复



服务器1:SQL Server 2008标准版服务器2:Windows 2008 Server R2,II 7.0

服务器2上的Web站点需要服务器上的SQL Server中的数据。

一切正常工作一段时间(有时几周)。然后,在重负载下,服务器2报告无法连接服务器1上的SQL Server。在Server 2上的IIS报告后,它无法连接到服务器1上的SQL,直到Server 2上的IIS重新启动后,它才会变得更好。也许重新启动应用程序池和完整的IIS重置一样。我不确定。

我尝试更改连接字符串,以将连接池大小增加到不合理的大值(1,000)。失败仍然发生。

网站用C#编写。数据访问层是NHIBERNATE。

这是例外的开始:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +428
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
   System.Data.SqlClient.SqlConnection.Open() +122
   NHibernate.Connection.DriverConnectionProvider.GetConnection() +60
   NHibernate.Impl.SessionFactoryImpl.OpenConnection() +39

有什么想法为什么会发生这种情况?如何诊断/修复它?我感到沮丧,并正在考虑剥夺NHIBERNATE,这可能需要几个月的时间,并且可能导致许多其他问题。

我认为您还必须增加连接超时值和连接池。这样它就不会在重载中发布与SQL Server的连接。

我的修复程序是配置SQL Server以允许无限数量的连接(设置为" 0&quot"的值。我仍然有一些连接问题,如原始帖子中所述,但没有那么多。因此,我还通过每个服务器上的二级以太网端口(网络服务器到SQL Server)设置了与SQL Server的直接连接,并使用服务器之间的196.168.1.x将连接保持私有,并使用其自己的以太网交换机未连接到公共开关。

最新更新