是否可以在 Azure Web 角色中运行 SQL Express?
我正在开发一个使用关系数据库(SQL Server 2008)的项目。本地(本地)应用程序读取和写入数据库。我正在为 Azure(MVC2 Web 角色)开发不同的前端,它将使用相同的数据,但以只读方式。如果我部署传统的 Web 应用程序,我将使用 SQL Express 充当本地数据库,并通过应用程序更新(数据更改非常缓慢)或通过某些同步系统来部署更改。
对于 Azure,情况有点阴暗(抱歉,我不得不这么做)。我似乎找不到任何信息来表明 SQL Express 是否可以在 Web 角色内部工作,如果可以,又该如何操作。有谁知道是否可以在 Azure Web 角色中使用 SQL Express?
如果被迫的话我可以做的其他选择:SQL CE 或使用 SQL Azure。两者都有很多缺点,而且绝对不够完美。
谢谢, 埃里克
编辑 我想我的场景可能还不够清晰。
此数据不会在部署之间发生变化,并且只能从 Web 角色内部访问;它基本上是一个静态缓存。本地部分有点转移注意力,因为它不会影响网络角色上的数据(除了作为其来源之外)。基本上,我想要做的是拥有一个本地数据存储/缓存,我可以使用现有的 T-SQL/DAL 代码。
虽然我可以使用 SQL Azure,但它不会添加任何内容,而且只会增加额外的开销和故障点。我也可以使用虚拟机角色,但这太昂贵/复杂。
在完美的世界中,我会将 MDF 打包到 cspkg 中(以便它与应用程序一起部署),然后在角色中本地使用它。如果没有办法做到这一点,那也没关系,我需要弄清楚其他解决方案的优缺点。我们并不生活在一个完美的世界中。 :)
I am working on a project which uses a relational database (SQL Server 2008). The local (on-premises) application both reads and writes to the database. I am working on a different front end for Azure (MVC2 Web Role), which will use the same data, but in a read only fashion. If I was deploying a traditional web app, I would use SQL Express to act as the local database, and deploy changes with updates to the application (the data changes very slowly) or via some sync system.
With Azure, the picture is a little cloudy (sorry, I had to). I can't seem to find any information to indicate if SQL Express will work inside of Web Roles, and if so, how to do it. Does anyone know if using SQL Express in an Azure web role is possible?
Other options I could do if forced: SQL CE or use SQL Azure. Both have a number of downsides, and are definitely less than perfect.
Thanks,
Erick
Edit
I think my scenario may not have been clear enough.
This data won't change between deployments, and is only accessed from within the Web Role; it is basically a static cache. The on-premises part is kind of a red herring, as it doesn't impact the data on the web role (aside from being its source). Basically, what I want to do is have a local data store/cache that I use existing T-SQL/DAL code with.
While I could use SQL Azure, it doesn't add anything, and if anything only adds additional overhead and failure points. I could also use a VM Role, but that is way too costly/complex.
In a perfect world, I would package the MDF into the cspkg (so it gets deployed with the app) and then use it locally from within the role. If there is no way to do this, then that is ok and I need to figure out the pros and cons of other solutions. We don't live in a perfect world. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您也许能够使用自定义 VHD 运行 SQL Express,但您将无法依赖该 VHD 上存在的任何数据。虚拟机在重新启动时会完全重置 - 重新启动后没有物理持久性。
如果您愿意,您也许可以在 Azure Blob 存储中找到整个 SQL Server 安装。
然而,在执行所有这些操作时,您只能拥有一个可以使用该数据库的工作人员/Web 角色。请记住:一个 SQL Server 数据库一次只能连接到一个 SQL Server。如果要横向扩展,则必须为每个 Web/辅助角色创建新的 SQL Server 实例。
除了成本问题之外,我想不出 SQL Express 中的任何内容应该成为 99.9% 的应用程序的阻碍。
You might be able to run SQL Express using a custom VHD but you won't be able to rely on any data every being present on that VHD. The VMs are completely reset when they reboot - there is no physical persistence across reboots.
If you wanted to, you might be able to locate your entire SQL Server installation in Azure blob storage.
However, in doing all of this, you'll only be able to have one worker/web role that can use that database. Remember: a SQL Server database can only be attached to one SQL Server at a time. If you want to scale out, you'll have to create new SQL Server instances for every web/worker role.
Outside of cost concerns, I can't think of anything that is in SQL Express that should be a show stopper for 99.9% of applications out there.
添加到 Jeremiah 的答案:SQL Azure 应该为您提供 SQL Express 目前所做的几乎所有功能,并且您可以使用同步服务将本地 SQL Server 与 SQL Azure 同步。
如果您将 SQL Express 安装到 VM 角色中,则仅该实例每月就要花费大约 90 美元,再加上 Blob 存储(您需要云驱动器以实现持久性)。根据定义,VM 角色(或任何角色)必须支持横向扩展;如果您出于某种原因要扩展到 2 个实例,则两个实例都需要自己的数据库副本,因此您需要为每个实例创建一个 Blob 快照。
但请记住,如果您选择在虚拟机中安装 SQL Express:一旦您拥有 2 个实例,并且每个实例的 Blob 存储容量为 20GB,您每月的费用将接近 200 美元,并且您需要维护虚拟机的操作系统补丁、SQL Express 配置和更新、故障恢复过程等。相比之下,20GB 的 SQL Azure 虽然价格相同为 200 美元,但将提供更好的性能并与同步服务配合使用,同时完全消除任何操作系统或数据库服务器管理任务来自你。
Adding to Jeremiah's answer: SQL Azure should give you nearly everything SQL Express does today, and you can use the Sync service to synchronize on-premise SQL Server with SQL Azure.
If you installed SQL Express into a VM role, you'd be consuming around $90 monthly just for that instance, plus blob storage (you'd want a Cloud Drive for durability). By definition, a VM Role (or any role) must support scale-out; if you were to scale to 2 instances for whatever reason, both instances would need their own copy of the database, so you'd need to create a blob snapshot for each instance.
Keep in mind, though, if you choose to install SQL Express in a VM: once you're at 2 instances, along with, say, 20GB per instance of blob storage, you're nearing $200 monthly and you're maintaining your VM's OS patches, SQL Express configuration and updates, failure recovery procedures, etc. In contrast, SQL Azure at 20GB, while costing the same $200, will offer better performance and works with the sync service, while completely removing any OS or database server management tasks from you.
添加到现有的答案以及对于任何想知道在云中运行 SQL Express 是否是个好主意的人:
它作为临时存储区域确实有意义。考虑这种架构方法:
假设您正在启动节点来运行作业。在每个节点的本地 SQL Express 中存储大量的计算结果可能是一个好主意,并在节点上的作业完成时立即提供聚合响应。可以在事后将不再热的结果传输到外部 SQL 服务器以供将来报告/等。从容量/延迟/成本的角度来看,SQL Azure 可能不是存储大量结果的最佳选择,并且 ATS 并不总是符合要求,特别是在涉及关系数据、性能或现有代码时。
To add to the already existing answers and for anyone wondering if its a good idea to run SQL Express in the cloud:
it does makes sense as a temporary storage area. Consider this architectural approach:
say you're spinning up nodes to run jobs. Storing a gazillion of calculation results might be a good idea inside a local SQL Express for each node, and provide the aggregated responses immediately when the job finishes on the node. Transfer of the no longer hot results to off-prem SQL server for future reporting/etc can be done afterwords. SQL Azure may not be optimal from the volume/latency/cost perspective to store gazillion of results and ATS will not always fit the bill, especially when relational data, performance or existing code are involved.
要扩展 David 提到的内容,您可以在此处注册 SQL Azure 数据同步 CTP2,它允许从 SQL Server 同步到 SQL Azure:http://www.microsoft.com/en-us/SQLAzure/datasync.aspx
确保使用 CTP2,因为 CTP1 不支持 SQL Server。
To expand on what David mentioned you can register for SQL Azure Data Sync CTP2 that would allow sync from SQL Server to SQL Azure here: http://www.microsoft.com/en-us/SQLAzure/datasync.aspx
Make sure to use CTP2 though since CTP1 did not support SQL Server.
如果它是只读本地缓存 - SQL CE 4 或 SQLite。
两者都有实体框架提供程序。
如果您正在写入它 - SQL Azure
If it's a read only local cache - SQL CE 4 or SQLite.
Both have Entity Framework providers.
If you're writing to it - SQL Azure