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

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

问题描述

我有ASP.NET网站和MSSQL数据库部署的问题。我们正在托管asp.net网站并开发新版本,一些asp.net文件被更改,数据库被修改了一点。什么是最好的上传新版本的网站和升级MSSQL数据库没有停机时间?

解决方案

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



所以,如果你计划例如,要删除列,您的应用程序依赖于:


  1. 将您的应用程序代码更改为不依赖于列,并释放(不删除数据库中的列)

  2. 下一个版本中删除列(因为应用程序不再依赖它)。

您的开发团队需要一些纪律,但如果您有正确的环境设置(dev / test / staging / production )



发布时:


  1. 将数据库更改部署到分期环境,尽可能接近生产。最好使用SQL比较和SQL数据比较等自动化方式进行此操作,以便您知道数据库与测试环境是完全不同的。

  2. 执行烟雾测试使用旧的应用程序,但新的数据库模式,确保没有对数据库引入重大的突破性更改。

  3. 发布应用程序

  4. 烟雾测试您的分期申请。

  5. 发布到生产。

另外我们做的是确保网站上的零停机时间是蓝绿色部署。这涉及到每个网站有两个文件夹,一旦更新,更新一个并切换IIS主目录。我在这里已经发表了这个消息: http:// davidduffett .net / post / 4833657659 / blue-green-deployment-to-iis-with-powershell


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?

解决方案

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. 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).

When you release:

  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.

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天全站免登陆