无法使用Powershell创建具有Hive Metastore的Azure HDInsight群集

时间:2015-12-22 21:18:57

标签: azure hive hdinsight azure-powershell metastore

当我尝试使用powershell cmdlet创建Azure HDInsight群集时出现错误:

New-AzureRmHDInsightClusterConfig  `
    | Add-AzureRmHDInsightMetastore `
        -SqlAzureServerName "$sqlDatabaseServerName.database.windows.net" `
        -DatabaseName $hiveMetaStoreDBName `
        -Credential $sqlServerCred `
        -MetastoreType HiveMetaStore `
    | New-AzureRmHDInsightCluster `
        -ResourceGroupName $resourceGroupName `
        -HttpCredential $clusterCreds `         
        -ClusterName $clusterName `
        -Location $location `
        -ClusterType $clusterType `
        -OSType $OSType `
        -Version "$hdVersion" `
        -SshCredential $clusterCreds `
        -DefaultStorageAccountName "$storageAccountName.blob.core.windows.net" `
        -DefaultStorageAccountKey $storageAccountKey `
        -ClusterSizeInNodes $clusterNodes

看起来PowerShell无法识别参数,因为它要求输入它们(见下文)。我输入所需的参数(Location,ClusterName,ClusterSizeInNodes),然后发生错误。

cmdlet New-AzureRmHDInsightCluster at command pipeline position 3
Supply values for the following parameters:
(Type !? for Help.)
Location: West Europe
ClusterName: xxxxxxxxx
ClusterSizeInNodes: 1
New-AzureRmHDInsightCluster : BadRequest: ParameterNullOrEmpty,Parameter 'ASVAccount.AccountName' cannot be null or 
empty.
At line:117 char:11
+         | New-AzureRmHDInsightCluster `
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [New-AzureRmHDInsightCluster], CloudException
+ FullyQualifiedErrorId : Hyak.Common.CloudException,Microsoft.Azure.Commands.HDInsight.NewAzureHDInsightClusterCom 
   mand

有人知道为什么会发生这种情况或者smdlet出了什么问题?

2 个答案:

答案 0 :(得分:0)

从错误消息中, .listitem.service h4 { width: 25%; } .listitem.service div { width: 73%; } cmdlet的$storageAccountName参数似乎为空或空,您可能需要进一步检查。

此外,我还强烈建议您同时为New-AzureRmHDInsightCluster cmdlet指定-DefaultStorageContainer。这将确保cmdlet能够解析存储帐户Uri的FQDN。

E.g。 asv://YourDefaultContainer@YourDefaultStorageAccountName.blob.core.windows.net/

希望这有帮助!

答案 1 :(得分:0)

Use below command for Cluster with Hive Metastore.

Here is a working PowerShell script, to be used with Azure ARM PowerShell, 1.0.1 or later – you can install Azure RM PS via web platform installer or follow this blog https://azure.microsoft.com/en-us/blog/azps-1-0/ 


Add-AzureRmAccount
$MyClusterName = "clustername";
$MyClusterLocation = "East US 2";
$NumClusterNodes = 2;
$MyClusterVersion = "3.2";
$MyHDInsightUserName = ""
$MyHDInsightPwd = ""
$MySqlAzureUserName = ""
$MySqlAzurePwd = ""
$MySqlAzureServerName = "*.database.windows.net"
$MySqlAzureDbName = "Dbtest"
$MyDefaultContainerName = "tastoreps"
$clusterResourceGroupName = "dirg"
# Use the correct Azure Subscription!
$subid = ""
Select-AzureRmSubscription -SubscriptionId $subid
# Storage key
$primaryStorageAcctName = "toragesouth"
$primaryStorageResourceGroupName = "storagerg"
# you need to use an ARM based storage as the primary account , classic storage won’t work as a primary account, known issue
$storageAccountKey = Get-AzureRmStorageAccountKey -ResourceGroupName $primaryStorageResourceGroupName -Name $primaryStorageAcctName | %{ $_.Key1 }
# credentials
$HdInsightPwd = ConvertTo-SecureString $MyHDInsightPwd -AsPlainText -Force
$HdInsightCreds = New-Object System.Management.Automation.PSCredential ($MyHDInsightUserName, $HdInsightPwd)
$SqlAzurePwd = ConvertTo-SecureString $MySqlAzurePwd -AsPlainText -Force
$SqlAzureCreds = New-Object System.Management.Automation.PSCredential ($MySqlAzureUserName, $SqlAzurePwd)
$config = New-AzureRmHDInsightClusterConfig -ClusterType Hadoop | 
Add-AzureRmHDInsightMetastore -SqlAzureServerName $MySqlAzureServerName -DatabaseName $MySqlAzureDbName -Credential $SqlAzureCreds -MetastoreType HiveMetastore | 
Add-AzureRmHDInsightMetastore -SqlAzureServerName $MySqlAzureServerName -DatabaseName $MySqlAzureDbName -Credential $SqlAzureCreds -MetastoreType OozieMetastore 
$config.DefaultStorageAccountName="$StorageAcctName.blob.core.windows.net"
$config.DefaultStorageAccountKey=$storageAccountKey
#create cluster
New-AzureRmHDInsightCluster -config $config -OSType Windows -clustername $MyClusterName -HttpCredential $HdInsightCreds -DefaultStorageContainer $MyDefaultContainerName -Location $MyClusterLocation -ResourceGroupName $clusterResourceGroupName -ClusterSizeInNodes $NumClusterNodes -Version $MyClusterVersion