在 ASP.NET web.config 文件中设置备份数据库服务器

发布于 2024-07-07 05:53:23 字数 746 浏览 15 评论 0原文

我目前有一个 asp.net 网站托管在两台位于 Cisco 负载平衡器后面的 Web 服务器上。 这两个 Web 服务器引用单个 MSSQL 数据库服务器。

由于该数据库服务器存在单点故障,因此我添加了一个额外的 MSSQL 服务器用于备份。 我想设置我的 web.config 文件以将所有内容写入两个 MSSQL 服务器,但仅从“主”数据库服务器读取,除非由于某种原因无法访问它,此时将使用备份 MSSQL 服务器。

这可以通过 web.config 文件设置实现,还是必须在代码中完成? 预先感谢您的任何帮助。

新的信息: 经过过去几天的研究,我只是想添加有关此主题的更多信息 - Microsoft TechNet 有一篇很好的文章标题“通过数据库镜像实现应用程序故障转移”(http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/implappfailover.mspx#EMD)。

这特别涵盖了 Microsoft SQL Server 2005 中的数据库镜像功能以及新的“故障转移伙伴”连接字符串关键字,该关键字允许您在单个连接字符串中指定两个服务器/数据库实例。

如果您有兴趣实现此类功能,那么这篇文章非常值得一读。

I currently have an asp.net website hosted on two web servers that sit behind a Cisco load balancer. The two web servers reference a single MSSQL database server.

Since this database server is a single point of failure, I'm adding an additional MSSQL server for backup. I would like to setup my web.config files to write everything to both MSSQL servers, but only read from the "primary" database server unless it is unreachable for some reason, at which point the backup MSSQL server would be used.

Is this possible via a web.config file setting, or must this be done in code? Thanks in advance for any help.

New Information:
I just wanted to add further information on this topic after researching it for the past several days - Microsoft TechNet has a good article title "Implementing Application Failover with Database Mirroring" (http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/implappfailover.mspx#EMD).

This specifically covers the database mirroring feature in Microsoft SQL Server 2005 and the new new "Failover Partner" connection string keyword that allows you to specify two server/db instances in a single connection string.

The article is well worth a read if your interested in implementing this type of feature.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌梦深 2024-07-14 05:53:23

您想要的称为“故障转移”,如果一个数据库发生故障,您的查询将自动重定向到另一个数据库。 这是在数据库级别实现的,而不是在应用程序级别实现的。 有很多用于设置故障转移群集的演练等:这是一个 SQL 2000,另一个用于 SQL 2005。 基本上,一旦设置完毕,主数据库就会将所有活动传达给辅助数据库。 如果主服务器发生故障,辅助服务器(几乎)是最新的并接管。

服务器形成一个集群,看起来就像一个单元 - 类似于负载平衡的 Web 服务器在外部世界中的外观。 备份监控主服务器,如果主服务器停止响应,备份将接管接收查询。 如果您正在谷歌搜索,请尝试添加关键字“数据库镜像”和“仲裁”。

What you want is called "failover", where if one database fails your queries are automatically redirected to the other. This is acheived at the database level, not the application. There are a lot of walkthroughs etc for setting up failover clusters: here's one for SQL 2000, and another for SQL 2005. Basically, once you set it up, the primary database communicates all activity to the secondary one. If the primary fails, the secondary is (almost) up to date and takes over.

The servers form a cluster, and look like a single unit - similar to the way your load-balanced web servers look to the outside world. The backup monitors the primary, and if the primary stops responding, the backup takes over receiving queries. If you're Googling, try also looking adding the keywords "database mirroring" and "quorum".

月竹挽风 2024-07-14 05:53:23

它比这更复杂一点。 您的网页是否写入数据库? 或者只是阅读?

如果他们写入,那么您将不得不担心保持两个数据库同步,可能使用镜像或日志传送。

但你(本质上)谈论的是建立一个 SQL 集群。

Its a bit more complex than that. Does your webpage write to the databases? Or just read?

If they write, then you'll have to worry about keeping the 2 databases synchronized, probably using mirroring or log shipping.

But what you are (in essense) talking about doing is setting up a SQL cluster.

花开雨落又逢春i 2024-07-14 05:53:23

我写了一篇博客文章,展示了如何设置 MSSQL 数据库镜像以及如何从托管代码的角度实际利用它:
http://www.improve。 dk/blog/2008/03/23/sql-server-mirroring-a-practical-approach

I've written a blog entry that shows how to setup MSSQL Database mirroring as well as how to actually utilize it from a managed code perspective:
http://www.improve.dk/blog/2008/03/23/sql-server-mirroring-a-practical-approach

轮廓§ 2024-07-14 05:53:23

“Rick”的回答很好,但我只想添加我的 2 美分信息。 通常,对于没有大量昂贵设备的故障转移设置,我会这样设置:

您可以让 2 个 SQL Server 机器等待请求,并拥有第三个机器低端系统,将 SQL Server 2005 Express 作为“健康”监控”。 这样您可以节省 10K 美元的包装费用和一个 SQL Server 许可证。 SQL Server Express(如免费)可以在两个数据库服务器之间进行运行状况监控,没有任何问题。

这就是我的设置:)

Nice answer from "Rick" but I just wanted to add my 2 cents of information. Normally for a setup with failover without a lot of expensive equipment, I would set it up like that:

You can have your 2 SQL Server box waiting for request and have a third box low-end system with SQL Server 2005 Express as a "health monitoring". What that saves you is 10K$ for the box and one SQL Server licence. SQL Server Express (as in Free) can do the health monitoring between the 2 databases servers without any issues.

That is my setup :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文