当前位置:   article > 正文

azure blob_Azure Blob存储–将数据库文件放置在云中

blob storage

azure blob

Do you know that since SQL Server 2012 you can have your entire database stored in Azure, even if you have your server on-premises? This article will introduce you to this capability, showing the basic steps to allow your instance to be in contact with your Azure Blob Storage Account.

您是否知道从SQL Server 2012开始,即使您的服务器是本地服务器,也可以将整个数据库存储在Azure中? 本文将向您介绍此功能,并显示允许您的实例与Azure Blob存储帐户联系的基本步骤。

We already started a series of articles exploring all the possibilities in order to have a Hybrid scenario, mixing SQL Server and Azure. In the previous article, we talked about the possibility of perform backup to the cloud, directly or using the Managed Backups feature, which automates the FULL and transaction log operations, based on rules.

我们已经开始了一系列文章,探讨了所有可能性,以实现混合方案,将SQL Server和Azure混合在一起。 在上一篇文章中,我们讨论了直接执行备份到云或使用托管备份功能(基于规则自动执行FULL和事务日志操作)的备份的可能性。

In order to backup database files to Azure, we need to have an active Azure Blob Storage account. In this article we are going to take advantage of the same feature, but with another objective: store database files in Azure.

为了将数据库文件备份到Azure,我们需要有一个活动的Azure Blob存储帐户。 在本文中,我们将利用相同的功能,但还有另一个目标:将数据库文件存储在Azure中。

Yes, you can have you server, in your datacenter, under your control, within the reach of your hands, but the database files are in Azure…

是的,您可以在自己的控制范围内,在数据中心内控制服务器,但数据库文件在Azure中…

有人问“我为什么要这样做?”的那一刻。 ( That moment when someone asks “why I would do this?” )

Well, there are few reasons… To start, don’t think in this feature like “I will put mdf, ndf and ldf files in Azure Blob Storage, and that’s it”. No. The main idea is not that… Of course you can do this, but this is a feature that opens a new horizon.

嗯,有几个原因……首先,不要想像“我将mdf,ndf和ldf文件放入Azure Blob存储中,就是这样”之类的功能。 否。主要思想不是……当然可以做到这一点,但这是一个打开新视野的功能。

Having your files in Azure you will inherit all the advantages of store files in the cloud:

将文件放在Azure中,您将继承云中存储文件的所有优点:

  • Durable & highly available – Azure Blob storage automatically replicates your data, maintaining 3 copies within a single region.耐用且高度可用 – Azure Blob存储自动复制您的数据,在一个区域内维护3个副本。
  • Geo-redundancy – This option creates 3 additional in another Azure site for higher availability and disaster recovery, complementing the previous data replication.地理冗余 –此选项在另一个Azure站点中另外创建3个,以提供更高的可用性和灾难恢复,以补充先前的数据复制。
  • Unlimited” space – Well, there’s a limit, of 500 TB per Azure Blob Account. You can have up to 50 accounts per azure subscription.无限”空间 –嗯,每个Azure Blob帐户有500 TB的限制。 每个Azure订阅最多可以有50个帐户。
  • You pay for what you use – Check the price per GB 您为使用的内容付费 -在here.此处检查每GB的价格。

We are going to see all the possibilities, but let’s start from the very basic…

我们将看到所有可能性,但让我们从最基本的内容开始……

You can place your entire database in the Azure Blob Storage, but is this for you? It depends. Remember that you will be adding a new failure point in the system, probably your internet connection. And here is another problem, is the performance acceptable? How critical is your database?

您可以将整个数据库放在Azure Blob存储中 ,但是这适合您吗? 这取决于。 请记住,您将在系统中添加一个新的故障点,可能是您的Internet连接。 这是另一个问题,性能可以接受吗? 您的数据库有多重要?

You see, this is not for everyone. I cannot define a rule, but smaller and not highly accessed databases are the better candidates for this. The best is always test!

您知道,这并不适合所有人。 我无法定义规则,但是较小的数据库和访问量不高的数据库是更好的选择。 最好的永远是测试!

But as said before, don’t look to this feature like this… This is flexible! There are other two interesting options that we can take advantage:

但是,如前所述,不要像这样使用此功能…这很灵活! 我们可以利用其他两个有趣的选项:

  • Use this solution in a hybrid database as archival solution.
  • 混合数据库中将此解决方案用作存档解决方案
  • low-cost disaster recovery solution.低成本的灾难恢复解决方案

We will approach those items in this article.

我们将在本文中介绍这些项目。

我从哪个版本开始具有此功能? ( From which version I have this capability? )

You can store both data and log files in Azure since SQL Server 2012 Cumulative Update 2.

自SQL Server 2012累积更新2起,您可以在Azure中存储数据和日志文件。

有哪些先决条件? ( What are the prerequisites? )

Here are the steps to follow, in order to be able to store files in Azure:

为了能够在Azure中存储文件,请按照以下步骤操作:

  1. Have an Azure Blob Storage Account
    Using your Azure subscription, click on the “+ New” button, in the left-bottom of the Azure Portal, and follow the options: “Data Service”➜”Storage”➜”Quick Create”. Fill all the information and click on “Create Storage Account”:

    有一个Azure Blob存储帐户
    使用Azure订阅,单击Azure门户左下角的“ +新建”按钮,然后按照以下选项进行操作:“数据服务”➜“存储”➜“快速创建”。 填写所有信息,然后单击“创建存储帐户”:

    After a successful creation, you will be able to find your account in the “Storage” menu:

    创建成功后,您将可以在“存储”菜单中找到您的帐户:

  2. Create a credential.
    This step looks easy, but it isn’t… First of all, the Credential Name should be exactly the same as the Container URL, to make story shorter, after a research, I found a method using PowerShell, explained at this blog:
    http://sqlcommunity.com/SQL-TEAMS/SQLCAT

    The method is basic:

    创建一个凭证。
    此步骤看起来很简单,但并非如此……首先,凭据名称应与容器URL完全相同,为了使内容更短,经过研究,我找到了使用PowerShell的方法,对此博客进行了解释:
    http://sqlcommunity.com/SQL-TEAMS/SQLCAT

    该方法是基本的:
    • Download the PowerShell script (see the previous link).

      下载PowerShell脚本(请参阅上一个链接)。
    • Download you Publishing Profile from the following URL: https://manage.windowsazure.com/publishsettings/
    • 从以下URL下载发布配置文件: https : //manage.windowsazure.com/publishsettings/
    • Execute the following command, as Administrator, from the PowerShell Console:

      从PowerShell控制台以管理员身份执行以下命令:

      .\SASPolicyTokens.ps1 -PublishSettingsFile “C:\pprofile\publishing_profile.publishsettings” -SubscriptionName “Visual Studio Professional with MSDN” -StorageAccountName “TestAcct” -ContainerName “dbfiles” -NumContainers 1 -StoredAccessPolicy “SQLPolicy” -StartTime “3/1/2015” -ExpiryTime “3/1/2016” -LogFilePath “C:\pprofile\creds.txt”

      。\ SASPolicyTokens.ps1 -PublishSettingsFile“ C:\ pprofile \ publishing_profile.publishsettings” -SubscriptionName“带有MSDN的Visual Studio Professional” -StorageAccountName“ TestAcct” -ContainerName“ dbfiles” -NumContainers 1 -StoredAccessPolicy“ SQLPolicy” -StartTime“ 3/1” / 2015” -ExpiryTime“ 2016/3/1” -LogFilePath“ C:\ pprofile \ creds.txt”

    • The command will generate a txt file, with the commands to be executed on SQL Server. The command is going to create the required credentials.

      该命令将生成一个txt文件,其中包含要在SQL Server上执行的命令。 该命令将创建所需的凭据。
  3. Now that you are done with the credentials challenge, you can create/attach the database pointing to that container.

    既然完成了凭据挑战,您就可以创建/附加指向该容器的数据库。

    Here is a sample code to create a Hybrid database:

    以下是创建混合数据库的示例代码:

    1.  
    2. CREATE DATABASE [HybridDatabase]
    3. ON  PRIMARY
    4. ( NAME = N'HybridDatabase', FILENAME = N'https://YourAccount.blob.core.windows.net/YourContainer/HybridDatabase.mdf' )
    5. LOG ON
    6. ( NAME = N'HybridDatabase_log', FILENAME = N'https:// YourAccount.blob.core.windows.net/ YourContainer /HybridDatabase_log.ldf')
    7. GO
    8.  

    If your credentials are well created, this command will run with success… Make sure that your firewall is not blocking the connection!!

    如果您的凭据创建正确,则此命令将成功运行…确保您的防火墙没有阻止连接!

    Now you know the basics! You are already able to store an entire database using the Azure Blob Storage. In the next part of this article I will explain the already referred scenarios:

    现在您已经了解了基础知识! 您已经能够使用Azure Blob存储存储整个数据库。 在本文的下一部分中,我将解释已经提到的方案:

    • Hybrid database as archival solution

      混合数据库作为归档解决方案
    • Low-cost disaster recovery solution

      低成本灾难恢复解决方案

    Keep in touch, because, in the second part, is where you will find the real reason to use this capability

    声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/541117
推荐阅读
相关标签