Azure PowerShell を使用して HDInsight の Apache Hadoop クラスターを管理する

Azure PowerShell を使用して、Azure のワークロードのデプロイと管理を制御し自動化することができます。 この記事では、Azure PowerShell Az モジュールを使用して Azure HDInsight の Apache Hadoop クラスターを管理する方法について説明します。 HDInsight PowerShell コマンドレットの一覧については、Az.HDInsight リファレンスを参照してください。

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

前提条件

Note

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

インストール済みの PowerShell Az モジュール

クラスターの作成

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

クラスターを一覧表示する

現在のサブスクリプションにあるクラスターすべてを一覧表示するには次のコマンドを使用します。

Get-AzHDInsightCluster

クラスターの表示

現在のサブスクリプションにある特定のクラスターの詳細を表示するには次のコマンドを使用します。

Get-AzHDInsightCluster -ClusterName <Cluster Name>

クラスターの削除

クラスターを削除するには、次のコマンドを使用します。

Remove-AzHDInsightCluster -ClusterName <Cluster Name>

クラスターが含まれるリソース グループを削除して、クラスターを削除することもできます。 リソース グループを削除すると、既定のストレージ アカウントを含め、グループ内のすべてのリソースが削除されます。

Remove-AzResourceGroup -Name <Resource Group Name>

クラスターのスケール

クラスターのスケール設定機能を使用すると、Azure HDInsight で実行しているクラスターによって使用される worker ノードの数を、クラスターを再作成することなく、変更できます。 Azure PowerShell を使用して Hadoop クラスターのサイズを変更するには、クライアント コンピューターから次のコマンドを実行します。

Set-AzHDInsightClusterSize -ClusterName <Cluster Name> -TargetInstanceCount <NewSize>

クラスターのスケーリングの詳細については、HDInsight クラスターのスケーリングに関するページを参照してください。

HTTP ユーザーの資格情報の更新

Set-AzHDInsightGatewayCredential は、Azure HDInsight クラスターのゲートウェイの HTTP 資格情報を設定します。

$clusterName = "CLUSTERNAME"
$credential = Get-Credential -Message "Enter the HTTP username and password:" -UserName "admin"

Set-AzHDInsightGatewayCredential -ClusterName $clusterName -HttpCredential $credential

既定のストレージ アカウントの検索

次の PowerShell スクリプトでは、既定のストレージ アカウント名と関連情報を取得する方法を示します。

#Connect-AzAccount
$clusterName = "<HDInsight Cluster Name>"

$clusterInfo = Get-AzHDInsightCluster -ClusterName $clusterName
$storageInfo = $clusterInfo.DefaultStorageAccount.split('.')
$defaultStoreageType = $storageInfo[1]
$defaultStorageName = $storageInfo[0]

echo "Default Storage account name: $defaultStorageName"
echo "Default Storage account type: $defaultStoreageType"

if ($defaultStoreageType -eq "blob")
{
    $defaultBlobContainerName = $cluster.DefaultStorageContainer
    $defaultStorageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $defaultStorageAccountName)[0].Value
    $defaultStorageAccountContext = New-AzStorageContext -StorageAccountName $defaultStorageAccountName -StorageAccountKey $defaultStorageAccountKey

    echo "Default Blob container name: $defaultBlobContainerName"
    echo "Default Storage account key: $defaultStorageAccountKey"
}

リソース グループの検索

Resource Manager モードでは、各 HDInsight クラスターは Azure リソース グループに属しています。 リソース グループを検索するには:

$clusterName = "<HDInsight Cluster Name>"

$cluster = Get-AzHDInsightCluster -ClusterName $clusterName
$resourceGroupName = $cluster.ResourceGroup

ジョブの送信

MapReduce ジョブを送信するには

HDInsight に含まれる MapReduce サンプルを実行する」を参照してください。

Apache Hive ジョブを送信するには

PowerShell を使用して Apache Hive クエリを実行する」を参照してください。

Apache Sqoop ジョブを送信するには

HDInsight での Apache Sqoop の使用に関するページを参照してください。

Apache Oozie ジョブを送信するには

HDInsight での Oozie と Hadoop を使用したワークフローの定義と実行」を参照してください。

Azure BLOB ストレージにデータをアップロードする

HDInsight へのデータのアップロードに関するページを参照してください。

参照