部署 ASP.NET 网站并以零停机时间更新 MSSQL 数据库 [英] Deploy ASP.NET web site and Update MSSQL database with zero downtime

查看:40
本文介绍了部署 ASP.NET 网站并以零停机时间更新 MSSQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 ASP.NET 网站和 MSSQL 数据库部署有疑问.我们正在托管asp.net 网站并开发新版本,更改了一些asp.net 文件并稍微修改了数据库.为什么要上传新版本的网站并在不停机的情况下升级 MSSQL 数据库?

I have question about ASP.NET web site and MSSQL database deployment. We are hosting asp.net web site and developed new version, the some asp.net files are changed and database is modified a little. What is the best why to upload new version of web site and upgrade MSSQL database without downtime?

推荐答案

在过去的 5 年里,我管理过一个大型网站,每月发布一次,并且在 95% 以上的时间里都实现了零停机.不幸的是,关键是确保数据库始终向后兼容,但仅限于以前的版本,因此您有机会回滚.

I've managed a large website for the past 5 years with monthly releases and manage to have zero downtime more than 95% of the time. The key, unfortunately, is ensuring that the database is always backwards compatible, but only to the previous release, so you have the opportunity to rollback.

因此,例如,如果您打算删除应用程序所依赖的列:

So, if you plan to drop a column, for example, that your application depends on:

  1. 将您的应用程序代码更改为不依赖于该列,然后发布(不删除数据库中的列).
  2. 下一版本中删除该列(因为应用程序不再依赖它).
  1. Change your application code to not depend on the column, and release that (without removing the column in the database).
  2. In the next release drop the column (as the application no longer relies on it).

这需要您的开发团队的一些纪律,但如果您拥有正确的环境设置(开发/测试/暂存/生产),则非常容易实现.

It takes some discipline from your dev team, but is surprisingly easy to achieve if you have proper the right environments setup (dev/test/staging/production).

发布时:

  1. 将数据库更改部署到尽可能接近生产环境的暂存环境.最好以自动化方式执行此操作,使用 SQL 比较和 SQL 数据比较之类的工具,以便您知道数据库与您的测试环境完全同步.
  2. 使用应用程序执行冒烟测试",但使用数据库架构,确保没有对数据库引入重大破坏性更改.
  3. 发布您的应用程序代码.
  4. 冒烟测试您的登台应用程序.
  5. 发布到生产环境.
  1. Deploy database changes to a staging environment, which is as close to production as possible. Do this preferably in an automated fashion, using something like SQL Compare and SQL Data Compare, so you know the database is completely up to date with your test environment.
  2. Perform "smoke tests" using the old application, but the new database schema, ensuring no major breaking changes have been introduced to the database.
  3. Release your application code.
  4. Smoke test your staging application.
  5. Release to production.

我们为确保网站零停机时间所做的另一件事是蓝绿部署.这涉及为每个网站设置 2 个文件夹,更新一个文件夹并在 IIS 主目录更新后切换.我在这里写了关于这个的博客:http://davidduffett.net/post/4833657659/blue-green-deployment-to-iis-with-powershell

Another thing we do to ensure zero downtime on the website is blue-green deployment. This involves having 2 folders for each website, updating one and switching the IIS home directory once it is up to date. I've blogged about this here: http://davidduffett.net/post/4833657659/blue-green-deployment-to-iis-with-powershell

这篇关于部署 ASP.NET 网站并以零停机时间更新 MSSQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆