RackSpace Cloud 中 IIS8 和 MSSQL 2012 之间的随机连接失败

RackSpace Cloud 中 IIS8 和 MSSQL 2012 之间的随机连接失败

背景

多年来,我将所有服务器功能(包括 IIS、Apache、MySql 和 MSSQL)都托管在单个服务器实例上,哎呀!随着客户群的增长,当服务器繁忙时,这会导致持续的 SQL 超时。在过去的一年里,我将其重组为三台服务器,一台用于 IIS + .Net 4 的 Windows Server 2012,一个用于 Apache 的 CentOS 实例,以及一台仅用于 MSSQL 2012 的 Windows Server 2012。这些服务器都是 RackSpace 云中的虚拟实例,除了一件事之外,似乎运行顺利……

在过去我已经习惯看到这样的数据库通信错误......

SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

或者

System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.

我理解这些,并且已经处理过它们,一般来说我不会再遇到它们了。

问题

我得到的是完全不同类型的超时错误,这些错误似乎与网络有关,例如......

[SqlException: 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)]

[Win32Exception: The specified network name is no longer available] 
[SqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)]

System.ComponentModel.Win32Exception (0x80004005): The semaphore timeout period has expired
System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.) 

System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

System.ComponentModel.Win32Exception (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

也许部分差异在于 IIS8 向我提供了比以前版本更具体的错误消息(是吗?)...但这些错误中的几个似乎是这两个 Windows Server 2012 实例之间的基本通信问题。我还注意到一些轶事证据,我的 FTP 客户端定期无法连接到 Web 服务器,并且 Windows 网络共享似乎间歇性断开连接。

所以我陷入了这样的境地:我拥有一台运转良好的机器,但每天都会莫名其妙地出现故障。由于我更像是一名开发人员,而不是 DBA 或服务器管理员……我感到很困惑。

我的连接字符串总是这样的......

SERVER=LiveDatabase;DATABASE=DataBaseName;UID=userid;PWD=pwd;Pooling=true;Min Pool Size=10;Max Pool Size=500;Connect Timeout=10;

其中 LiveDatabase 是计算机 SQL Server Native Client 配置中设置的别名。该别名随后指向 RackSpace 私有网络 192.168.xx 中的本地 IP 地址以及服务器需要连接的非标准端口。

这些“超时”发生在看似随机的存储过程上,包括对数据库开销很少或没有开销的过程。

答案1

所有问题似乎都指向网络连接问题,但检查以下内容应该会发现一些线索。

检查并确认以下内容:

  • 验证是否打开了正确的端口(1433)
  • 检查数据库用户权限
  • 尝试连续 ping SQL 服务器
  • 检查虚拟网卡的电源/睡眠选项
  • 看看 RackSpace 是否可以为您提供有关 NIC、服务器之间的网络通信(端口、子网等)的任何日志
  • 检查 Windows 日志和 SQL 服务器日志
  • 打开 SQL MGMT Studio 上的活动监视器,然后尝试重现错误(正在运行应用程序?)并监视活动监视器中的“最近的昂贵查询”

相关内容