Azure PowerShell を使用した HDInsight の Linux ベースのクラスターの作成

Azure PowerShell は、Microsoft Azure のワークロードのデプロイと管理を制御し、自動化するために使用できる強力なスクリプト作成環境です。 このドキュメントでは、Azure PowerShell を使用して Linux ベースの HDInsight クラスターを作成する方法について説明します。 また、スクリプトの例も含まれています。

Azure サブスクリプションをお持ちでない場合は、開始する前に 無料アカウント を作成してください。

前提条件

Note

Azure を操作するには、Azure Az PowerShell モジュールを使用することをお勧めします。 作業を開始するには、「Azure PowerShell のインストール」を参照してください。 Az PowerShell モジュールに移行する方法については、「AzureRM から Az への Azure PowerShell の移行」を参照してください。

Azure PowerShell Az モジュール。

クラスターの作成

警告

HDInsight クラスターの料金は、そのクラスターを使用しているかどうかに関係なく、分単位で課金されます。 使用後は、クラスターを必ず削除してください。 「HDInsight クラスターを削除する方法」をご覧ください。

Azure PowerShell を使用して HDInsight クラスターを作成するには、次の手順を完了する必要があります。

  • Azure リソース グループの作成
  • Azure Storage アカウントを作成する
  • Azure BLOB コンテナーの作成
  • HDInsight クラスターの作成

注意

PowerShell を使用して、Azure Data Lake Storage Gen2 を使用する HDInsight クラスターを作成することは現在サポートされていません。

次のスクリプトでは、新しいクラスターを作成する方法を示します。

# 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

クラスターのログインに指定する値は、クラスターの Hadoop ユーザー アカウントの作成に使用されます。 Web UI や REST API など、クラスターでホストされるサービスに接続するには、このアカウントを使用します。

SSH ユーザーに指定する値は、クラスターの SSH ユーザーの作成に使用されます。 このアカウントを使用してクラスターでリモート SSH セッションを開始し、ジョブを実行します。 詳細については、HDInsight での SSH の使用に関するドキュメントを参照してください。

重要

(クラスターの作成時または作成後のスケーリングで) 32 個を超える worker ノードを使用することを計画している場合は、コア数が 8 個以上、RAM が 14 GB 以上のヘッド ノード サイズも指定する必要があります。

ノードのサイズと関連コストに関する詳細については、「 HDInsight の価格」を参照してください。

クラスターを作成するには最大 20 分かかることがあります。

クラスターの作成: 構成オブジェクト

HDInsight の構成オブジェクトは、New-AzHDInsightClusterConfig コマンドレットを使用して作成することもできます。 作成後に、クラスターの追加の構成オプションを有効にするように、この構成オブジェクトを変更できます。 最後に、New-AzHDInsightCluster コマンドレットの -Config パラメーターを使用して構成を使用します。

クラスターのカスタマイズ

クラスターを削除する

警告

HDInsight クラスターの料金は、そのクラスターを使用しているかどうかに関係なく、分単位で課金されます。 使用後は、クラスターを必ず削除してください。 「HDInsight クラスターを削除する方法」をご覧ください。

トラブルシューティング

HDInsight クラスターの作成で問題が発生した場合は、「アクセス制御の要件」を参照してください。

次のステップ

これで HDInsight クラスターが正常に作成されたので、次のリソースを使用してクラスターの操作方法を学習してください。

Apache Hadoop クラスター

Apache HBase クラスター

Apache Spark クラスター