镜像环境中的数据库故障转移导致来自 Web 应用程序的连接尝试失败,直到应用程序池重新启动

Db fail over in Mirrored environment causing connection attempts from web app to fail until the application pool is restarted

我有一个镜像 sql 服务器数据库环境。 IIS 中托管的负载平衡应用程序正在访问数据库。在连接字符串中,我提到了 FailOver 伙伴。当我执行从 db1 到 db2 的故障转移时,应用程序无法连接。

我收到的错误是:

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) at MyMethodName() at MyMethod() System.ComponentModel.Win32Exception (0x80004005): The network path was not found System.Data.SqlClient.SqlException (0x80131904): 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.ComponentModel.Win32Exception (0x80004005): The network path was not found.

一旦我重新启动应用程序池,应用程序将能够再次连接到数据库。 我的连接字符串如下所示。

<add name="SqlString" connectionString="Data Source=12.34.56.79,9100;Failover Partner=12.34.56.78,9100;Initial Catalog=test;Persist Security Info=True;User ID=####;Password=#####" />

我正在使用 Sql 服务器 2012,IIS 8.5,Windows 服务器 2012

如有任何帮助,我们将不胜感激

经过大量研究并得到许多团队的帮助,我解决了这个问题。

发现应用程序试图连接到数据库故障转移上的默认端口 sql 服务器 1433,即使在连接字符串中指定了端口号也是如此。

使用ClicConfig.exe

在端口号的两个应用程序服务器中指定了别名

此解决方案由 Microsoft 提供。