我有一个使用 SQL 2008 镜像镜像的数据库。
我有一个 Java 应用程序,在 Linux 上运行,使用 Microsoft SQL 类型 4 JDBC 驱动程序。
我将此设置复制为 QA 环境。
在我的 QA 环境中,当我手动对数据库进行故障转移时,如果已经建立了成功的连接,则故障转移是完全透明的。我不需要实现任何东西来让应用程序与新的原则(旧镜像)对话。
但是,在实时环境中,一旦我手动进行故障转移,连接就会停止工作。
实时环境和 QA 环境之间有很多不同之处,但我认为这不是这个过程的基础,数据库之间的通信在这两种情况下都非常本地化,并且没有防火墙(Windows Server 2008 中内置的防火墙除外) ) 在我的 java 应用程序和运行 SQL 2008 的 Windows 机器之间。
有没有人对我如何诊断这个问题有任何想法?或者谁能告诉我这种故障转移透明度是如何发生的,这样我就可以自己解决这个问题?
1 回答
This behaviour is handled by the SQL Server provider as part of the Client Redirect behaviour. This was part of the SQL Server 2005 JDBC (Java Database Connectivity) 1.1 Driver, I'm unsure if that provider was directly used for the new type 4 drivers though?
In your live environment, is your application successfully connecting to the primary server before it fails over, so it is able to cache the failover partner and make use of that when the failover occurs?
To be sure, you can explicitly state the failover partner in the connection string, which is the recommended practice:
jdbc:sqlserver://serverA:1433; databaseName=AdventureWorks; integratedSecurity=true; failoverPartner=serverB
The full documentation of the redirect behaviour can be found here.
The addition of the failover documentation here suggests that it could be a manual consideration.