Last active
August 29, 2015 14:02
-
-
Save dharkum/1b42076dd81f46ac094f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################### Begin Edits #################### | |
#region edits | |
param | |
( | |
# NOTE: All the storage accounts and containers need to be created on the same data center as the HDInsight cluster and would need to be created prior to running the script | |
# They can be created from the Azure Management Portal | |
# This is the name of your Azure Subscription that will be used for provisiong Azure HDInsight | |
[string]$PrimarySubscriptionName="xxx", | |
# This is the primary storage account that needs to be created on the same data center as your HDInsight Cluster | |
# This needs to be pre-provisioned prior to running the script | |
[string]$PrimaryStorageAccount="myhdi30primary", | |
# This is the name of the container in the primary storage account. This needs to be pre-provisioned prior to running this script. | |
[string]$PrimaryStorageContainer="install", | |
# This is the additional storage account that is used to storage the external JAR files for customizing the HDInsight Cluster. Needs to be pre-provisioned prior to running the script. | |
[string]$HiveLibStorageAccount="myhdi30libs", | |
# This is the name of the container in the additional storage account. Again, needs to be created prior to running the script. | |
[string]$HiveLibStorageContainer="libs", | |
# This is the data center where the HDInsight cluster and storage accounts are provisioned | |
[string]$HDInsightClusterLocation="West US", | |
#This is the name of the HDInsight cluster | |
[string]$HDInsightClusterName="MyHDI30", | |
#This is the size of the cluster # of data nodes | |
[string]$HDIClusterSize = "1", | |
#This is the version of the HDInsight cluster. Default version is 2.1, however you can choose to create 3.0 or 3.1 clusters | |
# Please refer to this page for HDInsight/HDP/Hadoop version mapping - http://azure.microsoft.com/en-us/documentation/articles/hdinsight-component-versioning/ | |
[string]$HDInsightClusterVersion="3.0", | |
# HDInsight cluster admin user name and password need to be specified here. This will be used for subsequent admin logins to the cluster for job submissions. | |
[string]$MyHDInsightUserName = "xxx", | |
[string]$MyHDInsightPwd = "xxx" | |
) | |
#endregion edits | |
#################### End Edits ####################### | |
#region code | |
# Credentials | |
Add-AzureAccount | |
Select-AzureSubscription $PrimarySubscriptionName | |
$HdInsightPwd = ConvertTo-SecureString $MyHDInsightPwd -AsPlainText -Force | |
$creds= New-Object System.Management.Automation.PSCredential ($MyHDInsightUserName, $HdInsightPwd) | |
$PrimarySubscriptionID = (Get-AzureSubscription $PrimarySubscriptionName).SubscriptionId | |
$PrimaryStorageAccountKey = Get-AzureStorageKey $PrimaryStorageAccount | %{ $_.Primary } | |
$HiveLibStorageAccountKey = Get-AzureStorageKey $HiveLibStorageAccount | %{ $_.Primary } | |
#This will be the credential used for the admin account of the HDInsight Cluster | |
#$creds = Get-Credential -Message "Please enter the admin account credentials for your HDInsight Cluster" | |
# Set Custom Configuration | |
$configvalues = new-object 'Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.DataObjects.AzureHDInsightHiveConfiguration' | |
$configvalues.Configuration = @{ “hive.exec.compress.output”=”true” } | |
$configvalues.AdditionalLibraries = new-object 'Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.DataObjects.AzureHDInsightDefaultStorageAccount' | |
$configvalues.AdditionalLibraries.StorageAccountName = "$HiveLibStorageAccount.blob.core.windows.net" | |
$configvalues.AdditionalLibraries.StorageAccountKey = $HiveLibStorageAccountKey | |
$configvalues.AdditionalLibraries.StorageContainerName = $HiveLibStorageContainer | |
# Create Azure HDInsight Cluster | |
New-AzureHDInsightClusterConfig -ClusterSizeInNodes $HDIClusterSize -ClusterType Hadoop ` | |
| Set-AzureHDInsightDefaultStorage -StorageAccountName "$PrimaryStorageAccount.blob.core.windows.net" -StorageAccountKey $PrimaryStorageAccountKey -StorageContainerName $PrimaryStorageContainer ` | |
| Add-AzureHDInsightConfigValues -Hive $configvalues ` | |
| New-AzureHDInsightCluster -Subscription $PrimarySubscriptionID -Credential $creds -Name $HDInsightClusterName -Location $HDInsightClusterLocation -Version $HDInsightClusterVersion | |
#endregion code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment