Azure的无缝升级时,数据库架构的变化 [英] Azure seamless upgrade when database schema changes

查看:167
本文介绍了Azure的无缝升级时,数据库架构的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有一个生产和分期部署都用自己的(SQL Azure的)数据库。如果分期模式已发生变化,需要部署到生产是有一个定义实现对生产数据库的数据库升级(无需停机)的方式?

Let's say I have a production and staging deployment both using their own (SQL Azure) databases. If the schema in staging has changed and needs to be deployed to production is there a defined way of achieving the database upgrade on the production database (without downtime)?

例如。如果我换VIP升级< - >生产(并在同一时间莫名其妙地自动更改连接字符串)什么是自动升级的SQL Azure数据库的最佳工艺

e.g. If I swap VIP staging <-> production (and at same time automate changing connection strings somehow) what is the best process to automate upgrading the sql azure database.

我的思想会发现在RoleEnvironmentChanging环境的变化(虽然不知道,VIP交换甚至触发RoleEnvironmentChanginng),并反对将要数据库运行SQL脚本(即正式版)在这一点上,但是我需要确保该脚本只运行一次,将有多个实例过渡。

My thought would be to spot the environment change in RoleEnvironmentChanging (though not sure that VIP swap even fires RoleEnvironmentChanginng) and run the sql script against the to-be database (i.e. prod) at that point, however I need to make sure that script is only run once and there will be multiple instances transitioning.

推荐答案

所以,你必须生产部署有它自己的SQL Azure数据库,并拥有自己的SQL Azure数据库部署分期。在这种情况下,这两个应用程序有各自的连接字符串指向两个不同的数据库。

So you have production deployment which has its own SQL Azure database and staging deployment which has its own SQL Azure database. In this situation both the application have their connection string pointing to two different databases.

您第一个要求是,当你交换部署或做一些事情来改变飞行数据库架构,我有与设计以下关注:

Your first requirement is to change the Database schema on fly when you swap the deployment or do something and I have the following concern with that design:


  1. 如果你写任何code中的角色里面做一次且仅一次的动作,也没有保证,这只会发生一次。它会发生多个时间取决于几个场景,如

  1. If you write any code inside the role to do "ONCE and only ONCE" action, there is no guarantee that that this will happen only ONCE. It will happen multiple time depend on several scenario such as

1.1,你VM需要由系统重新映像任何情况下,这code会做完全相同的是什么最后重新映像期间那样

1.1 In any situation you VM needs to be reimage by the system and this CODE will do the exactly same what it did during last reimage

1.2您可以保护它没有角色开始或VM开始通过一些外部关键的一些注册表的方法发生,但也充分证明机制没有发生。

1.2 You might protect it to not happen at role start or VM start by some registry method of some external key but there is full proof mechanism that not to happen.

由于它的当你准备要交换的部署我建议你可以:

Because of it I would suggest when you are ready to SWAP your deployments you can:

2.1运行脚本来更新生产相关的SQL Azure的架构(这​​将对下载应用程序没有任何影响,因为它没有被触及,但同时你的数据库架构进行更新,你可以更好地了解它如何影响您的应用程序)

2.1 Run the script to update to the production related SQL Azure schema (This will have no impact on application download because it is not touched but while your database schema is updated, you may know better how it impact your application)

2.2变化分期部署指向生产SQL Azure中配置(这不会有任何生产应用停机的话)

2.2 Change the configuration in staging deployment to point to production SQL Azure (This will not have any production application downtime at all)

2.3 SWAP部署(这也将没有任何应用程序停机时间)

2.3 SWAP the deployment (This will also have no application downtime)

所以,即使您手动更新DB模式,然后交换部署没有显著除了停机时间由DB需要更新架构。

So even when you manually update the DB Schema and then SWAP the deployment there is no significant downtime besides the time take by DB to update the schema.

这篇关于Azure的无缝升级时,数据库架构的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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