简体   繁体   English

SQL Server 2008数据库镜像

[英]SQL Server 2008 database mirroring

I have a little problem with the database connection. 我的数据库连接有点问题。 There are 2 database server: 有2个数据库服务器:

DBSA, DBSB

DBSA (primary server)
DBSB (mirrored server)

I connect with the following Connection String : 我连接以下连接字符串:

Data Source=DBSA;Failover Partner=DBSB;Persist Security Info=True;Initial Catalog=database;User ID=user;Password=password

When I run my program on my PC it works, but when I try the program on the web server in the DMZ the failover doesn't work. 当我在我的电脑上运行我的程序时它可以工作,但是当我在DMZ中的Web服务器上尝试该程序时,故障转移不起作用。

Does somebody knows the reason for this? 有人知道这个的原因吗?

=> I forgot to tell in the question. =>我忘了在问题中说出来。 There is also a witness server. 还有一个见证服务器。

The app must be getting the failover server name from the SQL server (probably not even the FQDN name) instead of the connection string in the web.config . 应用程序必须从SQL服务器获取故障转移服务器名称(可能甚至不是FQDN名称),而不是web.config中的连接字符串。

Try running ipconfig /flushdns then failover the SQL database and after you get the first SQL exception error run ipconfig /displaydns to see which name it cannot resolve. 尝试运行ipconfig /flushdns然后故障转移SQL数据库,并在得到第一个SQL异常错误后运行ipconfig /displaydns以查看它无法解析的名称。 My bet is it doesn't look anything like the DB alias you have set up in the connection string for failover partner... 我敢打赌它看起来不像你在故障转移伙伴的连接字符串中设置的数据库别名...

I had to deal with the same thing - Microsoft's implementation is a little convoluted since they're trying to cover every possible scenario. 我不得不处理同样的事情 - 微软的实施有点令人费解,因为他们试图涵盖所有可能的情况。

Run this on your principal db 在你的主要数据库上运行它

SELECT DB_NAME(database_id) AS 'DatabaseName'
, mirroring_role_desc 
, mirroring_safety_level_desc 
, mirroring_state_desc 
, mirroring_partner_instance
FROM
sys.database_mirroring WHERE mirroring_guid IS NOT NULL; 

The value returned in mirroring_partner_instance is the server name that will be used by your connection for failover, not what you specify in the config. mirroring_partner_instance中返回的值是您的连接将用于故障转移的服务器名称,而不是您在配置中指定的名称。 I imagine your PC can see this server using this name, where as when running in the DMZ it cannot. 我想你的PC可以使用这个名称看到这个服务器,而在DMZ中运行它不能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM