首页 > 代码库 > 使用PowerShell在Azure China创建Data Warehouse
使用PowerShell在Azure China创建Data Warehouse
微软的Azure Data Warehouse是基于MPP架构的分布式系统:
Control Node负责管理系统和接受用户的请求,Compute Node负责计算。
目前在国内Azure Data Warehouse已经落地了。可以使用新的Portal页面进行管理,也可以使用PowerShell进行管理。
本文将介绍用PowerShell的管理方式。包括创建、Scale out、Suspend和Resume。
1 环境准备
登陆Azure China,并创建Resource Group
$mycred = Get-Credential -UserName admin@xxxx.partner.onmschina.cn -Message hello Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $mycred New-AzureRmResourceGroup -Name hwdweast -Location "China East" ResourceGroupName : hwdweast Location : chinaeast ProvisioningState : Succeeded Tags : ResourceId : /subscriptions/xxxx-xxxx-xxxx/resourceGroups/hwdweast
2 创建Azure SQL Server
创建的SQL Server是V12版本
$sqlcred = Get-Credential -UserName hengwei -Message hello New-AzureRmSqlServer -ServerName hwdwsv -SqlAdministratorCredentials $sqlcred -ResourceGroupName hwdweast -Location "China East" -ServerVersion 12.0 ResourceGroupName : hwdweast ServerName : hwdweast Location : China East SqlAdministratorLogin : hengwei SqlAdministratorPassword : ServerVersion : 12.0 Tags :
3 给新创建的Database server配置Firewall规则,本例子中因为是测试,添加了所有可用的地址段
new-AzureRmSqlServerFirewallRule -FirewallRuleName all -StartIpAddress 1.1.1.1 -EndIpAddress 223.255.255.254 -ServerName hwdweast -ResourceGroupName hwdweast ResourceGroupName : hwdweast ServerName : hwdweast StartIpAddress : 1.1.1.1 EndIpAddress : 223.255.255.254 FirewallRuleName : all
4 创建Data WareHouse
New-AzureRmSqlDatabase -DatabaseName hwdwdbeast -RequestedServiceObjectiveName "DW100" -ServerName hwdwsv -ResourceGroupName hwdweast -Edition DataWarehouse -CollationName "SQL_Latin1_General_CP1_CI_AS" -MaxSizeBytes 10995116277760
ResourceGroupName : hwdweast ServerName : hwdweast DatabaseName : hwdwdbeast Location : China East DatabaseId : 3e5f4387-099d-4a7d-858d-0d663381663a Edition : DataWarehouse CollationName : SQL_Latin1_General_CP1_CI_AS CatalogCollation : MaxSizeBytes : 1099511627776 Status : Online CreationDate : 2016/10/5 13:46:19 CurrentServiceObjectiveId : 4e63cb0e-91b9-46fd-b05c-51fdd2367618 CurrentServiceObjectiveName : DW100 RequestedServiceObjectiveId : 4e63cb0e-91b9-46fd-b05c-51fdd2367618 RequestedServiceObjectiveName : ElasticPoolName : EarliestRestoreDate : 0001/1/1 0:00:00 Tags : ResourceId : /subscriptions/xxxx-xxxx-xxxx/resourceGroups/hwdweast/providers/Microsoft.Sql/servers/hwdw east/databases/hwdwdbeast CreateMode :
其中,
-Edition DataWarehouse 表明这个是Data Warehouse
-RequestedServiceObjectiveName "DW100" 指定Data Warehouse的大小,DW100表示有1个计算节点
-CollationName "SQL_Latin1_General_CP1_CI_AS" 指定字符集
-MaxSizeBytes 10995116277760 指定最大容量
几分钟的时间,一个Data Warehouse就创建好了。
4 更改Data Warehouse大小
set-azurermsqldatabase -DatabaseName hwdwdbeast -RequestedServiceObjectiveName "DW200" -ServerName hwdwsv -ResourceGroupName hwdweast ResourceGroupName : hwdweast ServerName : hwdweast DatabaseName : hwdwdbeast Location : China East DatabaseId : 3e5f4387-099d-4a7d-858d-0d663381663a Edition : DataWarehouse CollationName : SQL_Latin1_General_CP1_CI_AS CatalogCollation : MaxSizeBytes : 1099511627776 Status : Online CreationDate : 2016/10/5 13:46:19 CurrentServiceObjectiveId : 99e78a92-d724-4e1b-857b-2be661f3d153 CurrentServiceObjectiveName : DW200 RequestedServiceObjectiveId : 99e78a92-d724-4e1b-857b-2be661f3d153 RequestedServiceObjectiveName : ElasticPoolName : EarliestRestoreDate : 0001/1/1 0:00:00 Tags : ResourceId : /subscriptions/xxxx-xxxx-xxxx/resourceGroups/hwdweast/providers/Microsoft.Sql/servers/hwdw east/databases/hwdwdbeast CreateMode :
5 暂停某个Data Warehouse的服务
Suspend-AzureRmSqlDatabase -DatabaseName hwdwdbeast -ServerName hwdweast -ResourceGroupName hwdweast ResourceGroupName : hwdweast ServerName : hwdweast DatabaseName : hwdwdbeast Location : China East DatabaseId : 3e5f4387-099d-4a7d-858d-0d663381663a Edition : DataWarehouse CollationName : SQL_Latin1_General_CP1_CI_AS CatalogCollation : MaxSizeBytes : 1099511627776 Status : Paused CreationDate : 2016/10/5 13:46:19 CurrentServiceObjectiveId : 4e63cb0e-91b9-46fd-b05c-51fdd2367618 CurrentServiceObjectiveName : DW100 RequestedServiceObjectiveId : 4e63cb0e-91b9-46fd-b05c-51fdd2367618 RequestedServiceObjectiveName : ElasticPoolName : EarliestRestoreDate : 0001/1/1 0:00:00 Tags : ResourceId : /subscriptions/xxxx-xxxx-xxxx/resourceGroups/hwdweast/providers/Microsoft.Sql/servers/hwdw east/databases/hwdwdbeast CreateMode :
此时,数据还保留在Data Warehouse中,但计算单元已经停止计费了。
这种模式特别适合需要月末、季度末、年末进行报表统计的场景。
6 恢复某个Data Warehouse的服务
Resume-AzureRmSqlDatabase -DatabaseName hwdwdbeast -ServerName hwdweast -ResourceGroupName hwdweast ResourceGroupName : hwdweast ServerName : hwdweast DatabaseName : hwdwdbeast Location : China East DatabaseId : 3e5f4387-099d-4a7d-858d-0d663381663a Edition : DataWarehouse CollationName : SQL_Latin1_General_CP1_CI_AS CatalogCollation : MaxSizeBytes : 1099511627776 Status : Online CreationDate : 2016/10/5 13:46:19 CurrentServiceObjectiveId : 4e63cb0e-91b9-46fd-b05c-51fdd2367618 CurrentServiceObjectiveName : DW100 RequestedServiceObjectiveId : 4e63cb0e-91b9-46fd-b05c-51fdd2367618 RequestedServiceObjectiveName : ElasticPoolName : EarliestRestoreDate : 0001/1/1 0:00:00 Tags : ResourceId : /subscriptions/xxxx-xxxx-xxxx/resourceGroups/hwdweast/providers/Microsoft.Sql/servers/hwdw east/databases/hwdwdbeast CreateMode :
目前Data Warehouse还只能通过PowerShell的方式进行创建,将来China 的Azure也会和Global的Azure一样,通过图形化界面完成上面所有的操作。
使用PowerShell在Azure China创建Data Warehouse