LoginSignup
0
0

More than 5 years have passed since last update.

複数ストレージアカウントを持つ HDInsight クラスタの作成

Posted at

HDinsight クラスタ作成時の制約

通常 Azure ポータルより HDInsight クラスタを作成する場合、ストレージアカウントは1つしか指定できません。また構築後に Azure ポータルからストレージアカウントを追加する事もできません。

PowerShell による HDInsight クラスタの作成

これに対し PowerShell による HDInsight クラスタの作成では、ストレージアカウントを追加して構築する事が可能です。これにより HDInsight コンピュートクラスタは複数のストレージに格納されているデータへアクセスする事が可能になります。

createcluser.ps1
# Azure サブスクリプションへのログイン
Login-AzureRMAccount

# 作成済みストレージアアカウント2つを利用 
$storageAccountResourceGroupName = "rg-storage"
$storageAccountName1 = "bigstorage1"
$storageAccountKey1 = (Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccountResourceGroupName -Name $storageAccountName1)[0].value
$storageAccountName2 = "bigstorage2"
$storageAccountKey2 = (Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccountResourceGroupName -Name $storageAccountName2)[0].value

# Spark クラスタ設定項目
$location = "Japan West"
$clusterResourceGroupName = "rg-sparkcluster"
$clusterName = "my-spark"
$sshCreds = Get-Credential
$webCreds = Get-Credential
$storageContainer = "sparkroot"

# Spark クラスタ用のリソースグループをストレージとは別に作成
New-AzureRMResourceGroup -Location $location -Name $clusterResourceGroupName

# 2つのストレージアカウントを持つ Spark クラスタを作成
New-AzureRmHDInsightClusterConfig `
            | Add-AzureRmHDInsightStorage `
                -StorageAccountName "$storageAccountName2.blob.core.windows.net" `
                -StorageAccountKey $storageAccountKey2 `
            | New-AzureRmHDInsightCluster `
                -ClusterType Spark `
                -ClusterTier Premium `
                -OSType Linux `
                -ClusterSizeInNodes 4 `
                -ResourceGroupName $clusterResourceGroupName `
                -ClusterName $clusterName `
                -HttpCredential $webCreds `
                -SshCredential $sshCreds `
                -Location $location `
                -DefaultStorageAccountName "$storageAccountName1.blob.core.windows.net" `
                -DefaultStorageAccountKey $storageAccountKey1 `
                -DefaultStorageContainer $storageContainer

上記スクリプトを実行すると Get-Credential により SSH および WEB ログイン用のユーザー名、パスワードの入力画面が 2 回ポップしてきます。それぞれに対話的な入力が必要です。
コマンドパイプライン.png

クラスタの作成が成功すると Azure ポータルの HDInsight 管理画面で以下のように2つのストレージアカウントが接続されているのが確認できます。
2ストレージpng.png

HDinsight クラスタの破棄と再作成

HDInisght クラスタのコンピュートノードは、通常の Azure 仮想マシンのように停止をする事が出来ません。現状ではクラスタの破棄と再作成を実施する事でクラスタのコンピュート課金を抑制する事が可能です。HDInisght クラスタを破棄した後も利用していたストレージを残しておけば、再度同じストレージをアタッチして作成する事で前回の HDInsight 構成や解析結果等を引き続き利用する事が可能です。このため上記スクリプトでは既存のストレージを利用して HDInsight クラスタを作成する流れを示しています。

以下の画面キャプチャは、HDInisght クラスタを破棄した後のストレージ内のデータ保持状態を示しています。同じストレージおよび storageContainer を指定して HDInsight クラスタを再作成する事で再利用できます。
sparkroot2.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0