Bagikan melalui


Membuat klaster berbasis Linux di HDInsight menggunakan Azure PowerShell

Azure PowerShell adalah lingkungan pembuatan skrip yang kuat yang dapat Anda gunakan untuk mengontrol dan mengotomatiskan penyebaran dan manajemen beban kerja Anda di Microsoft Azure. Dokumen ini menyediakan informasi tentang cara membuat kluster HDInsight berbasis Linux dengan menggunakan Azure PowerShell. Ini juga mencakup contoh skrip.

Jika Anda tidak memiliki langganan Azure, buat akun gratis sebelum Anda memulai.

Prasyarat

Catatan

Sebaiknya Anda menggunakan modul Azure Az PowerShell untuk berinteraksi dengan Azure. Untuk memulai, lihat Menginstal Azure PowerShell. Untuk mempelajari cara bermigrasi ke modul Az PowerShell, lihat Memigrasikan Azure PowerShell dari AzureRM ke Az.

Modul Azure PowerShell Az.

Membuat kluster

Peringatan

Tagihan untuk kluster HDInsight dirata-rata per menit, baik Anda menggunakannya maupun tidak. Pastikan untuk menghapus kluster Anda setelah selesai menggunakannya. Lihat cara menghapus kluster HDInsight.

Untuk membuat kluster HDInsight dengan menggunakan Azure PowerShell, Anda harus menyelesaikan prosedur berikut:

  • Membuat Grup Sumber Daya Azure
  • Buat akun Azure Storage
  • Buat kontainer Azure Blob
  • Buat kluster HDInsight

Catatan

Menggunakan PowerShell untuk membuat kluster HDInsight dengan Azure Data Lake Storage Gen2 saat ini tidak didukung.

Skrip berikut ini menunjukkan cara membuat kluster baru:

# 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

Nilai yang Anda tentukan untuk login kluster digunakan untuk membuat akun pengguna Hadoop untuk kluster. Gunakan akun ini untuk menyambungkan ke layanan yang dihosting pada kluster seperti UI web atau REST API.

Nilai yang Anda tentukan untuk pengguna SSH digunakan untuk membuat pengguna SSH untuk kluster tersebut. Gunakan akun ini untuk memulai sesi SSH jarak jauh pada kluster dan menjalankan pekerjaan. Untuk informasi selengkapnya, lihat dokumen Gunakan SSH dengan HDInsight.

Penting

Jika Anda berencana untuk menggunakan lebih dari 32 node pekerja (baik pada pembuatan kluster atau dengan menskalakan kluster setelah pembuatan), Anda juga harus menentukan ukuran node kepala dengan setidaknya 8 inti dan RAM 14 GB.

Untuk informasi selengkapnya tentang ukuran node dan biaya terkait, lihat Harga HDInsight.

Pembuatan kluster dapat memakan waktu hingga 20 menit.

Buat kluster: Objek konfigurasi

Anda juga dapat membuat objek konfigurasi HDInsight menggunakan New-AzHDInsightClusterConfig cmdlet. Anda kemudian dapat mengubah obyek konfigurasi ini untuk mengaktifkan opsi konfigurasi tambahan untuk kluster Anda. Terakhir, gunakan -Config parameter New-AzHDInsightCluster cmdlet untuk menggunakan konfigurasi tersebut.

Kustomisasi kluster

Menghapus kluster

Peringatan

Tagihan untuk kluster HDInsight dirata-rata per menit, baik Anda menggunakannya maupun tidak. Pastikan untuk menghapus kluster Anda setelah selesai menggunakannya. Lihat cara menghapus kluster HDInsight.

Pecahkan masalah

Jika Anda mengalami masalah dengan pembuatan kluster HDInsight, lihat persyaratan kontrol akses.

Langkah berikutnya

Sekarang setelah Anda berhasil membuat kluster HDInsight, gunakan hal berikut ini untuk mempelajari cara menggunakan kluster Anda.

Kluster Apache Hadoop

Kluster Apache HBase

Kluster Apache Spark