Op Linux gebaseerde clusters maken in HDInsight met behulp van Azure PowerShell

Azure PowerShell is een krachtige scriptomgeving die u kunt gebruiken om de implementatie en het beheer van uw workloads in Microsoft Azure te beheren en automatiseren. Dit document bevat informatie over het maken van een HDInsight-cluster op basis van Linux met behulp van Azure PowerShell. Het bevat ook een voorbeeldscript.

Als u nog geen abonnement op Azure hebt, maak dan een gratis account aan voordat u begint.

Vereisten

Notitie

U wordt aangeraden de Azure Az PowerShell-module te gebruiken om te communiceren met Azure. Zie Azure PowerShell installeren om aan de slag te gaan. Raadpleeg Azure PowerShell migreren van AzureRM naar Az om te leren hoe u naar de Azure PowerShell-module migreert.

Azure PowerShell Az-module.

Cluster maken

Waarschuwing

HDInsight-clusters worden pro rato per minuut gefactureerd, ongeacht of u er wel of niet gebruik van maakt. Verwijder uw cluster daarom als u er klaar mee bent. Zie how to delete an HDInsight cluster (een HDInsight-cluster verwijderen).

Als u een HDInsight-cluster wilt maken met behulp van Azure PowerShell, moet u de volgende procedures uitvoeren:

  • Maak een Azure-resourcegroep
  • Een Azure Storage-account maken
  • Een Azure Blob-container maken
  • Een HDInsight-cluster maken

Notitie

Het gebruik van PowerShell voor het maken van een HDInsight-cluster met Azure Data Lake Storage Gen2 wordt momenteel niet ondersteund.

Het volgende script laat zien hoe u een nieuw cluster maakt:

# Login to your Azure subscription
$context = Get-AzContext
if ($context -eq $null) 
{
    Connect-AzAccount
}
$context

# If you have multiple subscriptions, set the one to use
# $subscriptionID = "<subscription ID to use>"
# Select-AzSubscription -SubscriptionId $subscriptionID

# Get user input/default values
$resourceGroupName = Read-Host -Prompt "Enter the resource group name"
$location = Read-Host -Prompt "Enter the Azure region to create resources in"

# Create the resource group
New-AzResourceGroup -Name $resourceGroupName -Location $location

$defaultStorageAccountName = Read-Host -Prompt "Enter the name of the storage account"

# Create an Az.Storage account and container
New-AzStorageAccount `
    -ResourceGroupName $resourceGroupName `
    -Name $defaultStorageAccountName `
    -Type Standard_LRS `
    -Location $location
$defaultStorageAccountKey = (Get-AzStorageAccountKey `
                                -ResourceGroupName $resourceGroupName `
                                -Name $defaultStorageAccountName)[0].Value

$storageAccountResourceId = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -AccountName $defaultStorageAccountName).Id  

$defaultStorageContext = New-AzStorageContext `
                                -StorageAccountName $defaultStorageAccountName `
                                -StorageAccountKey $defaultStorageAccountKey

# Get information for the HDInsight cluster
$clusterName = Read-Host -Prompt "Enter the name of the HDInsight cluster"
# Cluster login is used to secure HTTPS services hosted on the cluster
$httpCredential = Get-Credential -Message "Enter Cluster login credentials" -UserName "admin"
# SSH user is used to remotely connect to the cluster using SSH clients
$sshCredentials = Get-Credential -Message "Enter SSH user credentials" -UserName "sshuser"

# Default cluster size (# of worker nodes), version, type, and OS
$clusterSizeInNodes = "4"
$clusterVersion = "5.1"
$clusterType = "Hadoop"
$clusterOS = "Linux"
# Set the storage container name to the cluster name
$defaultBlobContainerName = $clusterName

# Create a blob container. This holds the default data store for the cluster.
New-AzStorageContainer `
    -Name $clusterName -Context $defaultStorageContext 

# Create the HDInsight cluster
    New-AzHDInsightCluster `
    -ResourceGroupName $resourceGroupName `
    -ClusterName $clusterName `
    -Location $location `
    -ClusterSizeInNodes $clusterSizeInNodes `
    -ClusterType $clusterType `
    -OSType $clusterOS `
    -Version $clusterVersion `
    -HttpCredential $httpCredential `
    -StorageAccountResourceId $storageAccountResourceId `
    -StorageAccountKey $defaultStorageAccountKey `
    -StorageContainer $defaultBlobContainerName `
    -SshCredential $sshCredentials

De waarden die u opgeeft voor de clusteraanmelding, worden gebruikt om het Hadoop-gebruikersaccount voor het cluster te maken. Gebruik dit account om verbinding te maken met services die worden gehost op het cluster, zoals web-UI's of REST API's.

De waarden die u opgeeft voor de SSH-gebruiker worden gebruikt om de SSH-gebruiker voor het cluster te maken. Gebruik dit account om een externe SSH-sessie op het cluster te starten en taken uit te voeren. Zie het document SSH gebruiken met HDInsight voor meer informatie.

Belangrijk

Als u meer dan 32 werkknooppunten wilt gebruiken (tijdens het maken van het cluster of door het cluster na het maken te schalen), moet u ook een hoofdknooppuntgrootte opgeven met ten minste 8 kernen en 14 GB RAM-geheugen.

Zie Prijsdetails voor Azure HDInsight voor meer informatie over knooppuntgrootten en de bijbehorende kosten.

Het kan tot 20 minuten duren om een cluster te maken.

Cluster maken: configuratieobject

U kunt ook een HDInsight-configuratieobject maken met behulp van de New-AzHDInsightClusterConfig cmdlet. Vervolgens kunt u dit configuratieobject wijzigen om extra configuratieopties voor uw cluster in te schakelen. Gebruik ten slotte de -Config parameter van de New-AzHDInsightCluster cmdlet om de configuratie te gebruiken.

Clusters aanpassen

Het cluster verwijderen

Waarschuwing

HDInsight-clusters worden pro rato per minuut gefactureerd, ongeacht of u er wel of niet gebruik van maakt. Verwijder uw cluster daarom als u er klaar mee bent. Zie how to delete an HDInsight cluster (een HDInsight-cluster verwijderen).

Problemen oplossen

Zie Vereisten voor toegangsbeheer als u problemen ondervindt met het maken van HDInsight-clusters.

Volgende stappen

Nu u een HDInsight-cluster hebt gemaakt, kunt u de volgende resources gebruiken om te leren werken met uw cluster.

Apache Hadoop-clusters

Apache HBase-clusters

Apache Spark-clusters