简体   繁体   English

Azure SQL数据库最快的备份/还原策略?

[英]The fastest backup/restore strategy for Azure SQL databases?

What is the fastest way to backup/restore Azure SQL database? 备份/还原Azure SQL数据库的最快方法是什么?

The background: We have the database with size ~40 GB and restoring it from the .bacbac file (~4GB of compressed data) in the native way by Azure SQL Database Import/Export Service takes up to 6-8 hours. 背景:我们拥有大小约为40 GB的数据库,并且Azure SQL数据库导入/导出服务以本机方式从.bacbac文件(~4GB压缩数据)恢复它需要长达6-8小时。 Creating .bacpac is also very long and takes ~2 hours. 创建.bacpac也很长,需要大约2个小时。

UPD: UPD:

在此输入图像描述

UPD. UPD。 Creating the database (by the way transactional consistent) copy using CREATE DATABASE [DBBackup] AS COPY OF [DB] takes only 15 minutes with 40 GB database and the restore is simple database rename. 使用CREATE DATABASE [DBBackup] AS COPY OF [DB]创建数据库(通过事务一致的方式)复制CREATE DATABASE [DBBackup] AS COPY OF [DB]只需15分钟,40 GB数据库,并且还原是简单的数据库重命名。

UPD. UPD。 Dec, 2014. Let me share with you our experience about the fastest way of DB migration schema we ended up with. 2014年12月。让我与您分享我们最终获得的数据库迁移模式最快方式的经验。

First of all, the approach with data-tier application (.bacpac) turned out to be not viable for us after DB became slightly bigger and it also will not work for you if you have at least one non-clustered index with total size > 2 GB until you disable non-clustered indexes before export - it's due to Azure SQL transaction log limit. 首先,数据层应用程序(.bacpac)的方法在DB变得稍微大一点后对我们来说是不可行的,如果你有至少一个总体大小的非聚集索引,它对你也不适用> 2 GB,直到您在导出之前禁用非聚集索引 - 这是由于Azure SQL事务日志限制。

We stick to Azure Migration Wizard that for data transfer just runs BCP for each table (parameters of BCP are configurable) and it's ~20% faster than approach with .bacpac. 我们坚持使用Azure迁移向导 ,对于数据传输,只需为每个表运行BCP(BCP的参数是可配置的),并且比使用.bacpac的方法快20%。

Here are some pitfalls we encountered with the Migration Wizard: 以下是我们在迁移向导中遇到的一些陷阱:

  1. We run into encoding troubles for non-Unicode strings. 我们遇到了非Unicode字符串的编码问题。 Make sure that BCP import and export runs with same collation. 确保BCP导入和导出以相同的排序规则运行。 It's -C ... configuration switch, you can find parameters with which BCP calling in .config file for MW application. 它是-C ...配置开关,您可以在MW应用程序中找到BCP调用.config文件的参数。
  2. Take into account that MW (at least the version that is actual at the moment of this writing) runs BCP with parameters that will leave the constraints in non-trusted state, so do not forget to check all non-trusted constraints after BCP import. 考虑到MW(至少是本文撰写时的实际版本)运行BCP,其参数将使约束处于不可信状态,因此不要忘记在BCP导入后检查所有不受信任的约束

If your database is 40GB it's long past time to consider having a redundant Database server that's ready to go as soon as the main becomes faulty. 如果您的数据库是40GB,那么很久以后就会考虑使用冗余的数据库服务器,一旦主服务器发生故障就可以立即服务。

You should have a second server running alongside the main DB server that has no actual routines except to sync with the main server on an hourly/daily basis (depending on how often your data changes, and how long it takes to run this process). 您应该在主数据库服务器旁边运行第二个服务器,该服务器没有实际例程,除非每小时/每天与主服务器同步(取决于数据更改的频率以及运行此过程所需的时间)。 You can also consider creating backups from this database server, instead of the main one. 您还可以考虑从此数据库服务器而不是主数据库服务器创建备份。

If your main DB server goes down - for whatever reason - you can change the host address in your application to the backup database, and spend the 8 hours debugging your other server, instead of twiddling your thumbs waiting for the Azure Portal to do its thing while your clients complain. 如果您的主数据库服务器出现故障 - 无论出于何种原因 - 您可以将应用程序中的主机地址更改为备份数据库,并花8小时调试您的其他服务器,而不是让您的拇指在等待Azure门户执行其操作而你的客户抱怨。

Your database shouldn't be taking 6-8 hours to restore from backup though. 您的数据库不应该花费6-8小时从备份恢复。 If you are including upload/download time in that estimate, then you should consider storing your data in the Azure datacenter, as well as locally. 如果您在此估算中包含上载/下载时间,则应考虑将数据存储在Azure数据中心以及本地。

For more info see this article on Business Continuity on MSDN: http://msdn.microsoft.com/en-us/library/windowsazure/hh852669.aspx 有关详细信息,请参阅MSDN上有关业务连续性的这篇文章: http//msdn.microsoft.com/en-us/library/windowsazure/hh852669.aspx

You'll want to specifically look at the Database Copies section, but the article is worth reading in full if your DB is so large. 您将需要专门查看“数据库副本”部分,但如果您的数据库太大,那么本文值得全文阅读。

Azure now supports Point in time restore / Geo restore and GeoDR features. Azure现在支持即时恢复/地理还原和GeoDR功能。 You can use the combination of these to have quick backup / restore. 您可以使用这些组合进行快速备份/还原。 PiTR and Geo restore comes with no additional cost while you have to pay for Geo replica PiTR和Geo恢复无需额外费用,而您需要支付Geo副本

There are multiple ways to do backup, restore and copy jobs on Azure. 有多种方法可以在Azure上执行备份,还原和复制作业。

  1. Point in time restore. 及时恢复。

Azure Service takes full backups, multiple differential backups and t-log backups every 5 minutes. Azure Service每5分钟进行一次完整备份,多个差异备份和t-log备份。

  1. Geo Restore 地理还原

same as Point in time restore. 与时间点恢复相同。 Only difference is that it picks up a redundant copy from a different blob storage stored in a different region. 唯一的区别是它从存储在不同区域的不同blob存储中获取冗余副本。

  1. Geo-Replication 地域复制

Same as SQL Availability Groups. 与SQL可用性组相同。 4 Replicas Async with read capabilities. 4副本与读取功能异步。 Select a region to become a hot standby. 选择要成为热备用的区域。

More on Microsoft Site here . 更多关于Microsoft网站的信息 Blog here . 博客在这里

Azure SQL Database already has these local replicas that Liam is referring to. Azure SQL数据库已经拥有Liam所指的这些本地副本。 You can find more details on these three local replicas here http://social.technet.microsoft.com/wiki/contents/articles/1695.inside-windows-azure-sql-database.aspx#High_Availability_with_SQL_Azure 您可以在http://social.technet.microsoft.com/wiki/contents/articles/1695.inside-windows-azure-sql-database.aspx#High_Availability_with_SQL_Azure找到有关这三个本地副本的更多详细信息。

Also, SQL Database recently introduced new service tiers that include new point-in-time-restore. 此外,SQL数据库最近引入了新的服务层,其中包括新的时间点恢复。 Full details at http://msdn.microsoft.com/en-us/library/azure/hh852669.aspx 有关详细信息,请访问http://msdn.microsoft.com/en-us/library/azure/hh852669.aspx

Key is to use right data management strategy as well that helps solve your objective. 关键是要使用正确的数据管理策略,这有助于解决您的目标。 Wrong architecture and approach to put everything on cloud can prove disastrous... here's more to it to read - http://archdipesh.blogspot.com/2014/03/windows-azure-data-strategies-and.html 将所有内容放在云上的错误架构和方法可能会带来灾难性的......这里有更多内容可供阅读 - http://archdipesh.blogspot.com/2014/03/windows-azure-data-strategies-and.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM