赞
踩
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中…
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中,您将继承云中存储文件的所有优点:
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:
但是,如前所述,不要像这样使用此功能…这很灵活! 我们可以利用其他两个有趣的选项:
We will approach those items in this article.
我们将在本文中介绍这些项目。
You can store both data and log files in Azure since SQL Server 2012 Cumulative Update 2.
自SQL Server 2012累积更新2起,您可以在Azure中存储数据和日志文件。
Here are the steps to follow, in order to be able to store files in Azure:
为了能够在Azure中存储文件,请按照以下步骤操作:
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:
创建成功后,您将可以在“存储”菜单中找到您的帐户:
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
创建一个凭证。
此步骤看起来很简单,但并非如此……首先,凭据名称应与容器URL完全相同,为了使内容更短,经过研究,我找到了使用PowerShell的方法,对此博客进行了解释:
http://sqlcommunity.com/SQL-TEAMS/SQLCAT
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”
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:
以下是创建混合数据库的示例代码:
-
- CREATE DATABASE [HybridDatabase]
- ON PRIMARY
- ( NAME = N'HybridDatabase', FILENAME = N'https://YourAccount.blob.core.windows.net/YourContainer/HybridDatabase.mdf' )
- LOG ON
- ( NAME = N'HybridDatabase_log', FILENAME = N'https:// YourAccount.blob.core.windows.net/ YourContainer /HybridDatabase_log.ldf')
- GO
-
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存储存储整个数据库。 在本文的下一部分中,我将解释已经提到的方案:
Keep in touch, because, in the second part, is where you will find the real reason to use this capability
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。