다음을 통해 공유


부트스트랩을 사용하여 HDInsight 클러스터 사용자 지정

부트스트랩 스크립트를 사용하여 프로그래밍 방식으로 Azure HDInsight의 구성 요소를 설치 및 구성할 수 있습니다.

HDInsight 클러스터를 만들 때 구성 파일 설정을 설정하는 방법에는 세 가지가 있습니다.

  • Azure PowerShell 사용
  • .NET SDK 사용
  • Azure Resource Manager 템플릿 사용

예를 들어 해당 프로그래밍 방식을 사용하여 다음 파일의 옵션을 구성할 수 있습니다.

  • clusterIdentity.xml
  • core-site.xml
  • gateway.xml
  • hbase-env.xml
  • hbase-site.xml
  • hdfs-site.xml
  • hive-env.xml
  • hive-site.xml
  • mapred-site
  • oozie-site.xml
  • oozie-env.xml
  • tez-site.xml
  • webhcat-site.xml
  • yarn-site.xml
  • server.properties(kafka-broker 구성)

만드는 동안 HDInsight 클러스터에 추가 구성 요소를 설치하는 방법에 대한 자세한 내용은 스크립트 작업을 사용하여 HDInsight 클러스터 사용자 지정(Linux)을 참조하세요.

필수 조건

  • PowerShell을 사용하는 경우 AZ 모듈이 필요합니다.

Azure PowerShell 사용

다음 PowerShell 코드는 Apache Hive 구성을 사용자 지정합니다.

Important

Spark2Defaults 매개 변수는 AzHDInsightConfigValue와 함께 사용해야 할 수 있습니다. 다음 코드 예제에 나와 있는 것처럼 매개 변수에 빈 값을 전달할 수 있습니다.

# hive-site.xml configuration
$hiveConfigValues = @{ "hive.metastore.client.socket.timeout"="90s" }

$config = New-AzHDInsightClusterConfig `
         -ClusterType "Spark"  `
    | Set-AzHDInsightDefaultStorage `
        -StorageAccountResourceId "$storageAccountResourceId" `
        -StorageAccountKey $defaultStorageAccountKey `
    | Add-AzHDInsightConfigValue `
        -HiveSite $hiveConfigValues `
        -Spark2Defaults @{}

New-AzHDInsightCluster `
    -ResourceGroupName $resourceGroupName `
    -ClusterName $hdinsightClusterName `
    -Location $location `
    -ClusterSizeInNodes 2 `
    -Version "4.0" `
    -HttpCredential $httpCredential `
    -SshCredential $sshCredential `
    -Config $config

완전히 작동하는 PowerShell 스크립트는 부록에서 찾을 수 있습니다.

변경을 확인하려면:

  1. https://CLUSTERNAME.azurehdinsight.net/으로 이동합니다. CLUSTERNAME은 클러스터의 이름입니다.
  2. 왼쪽 메뉴에서 Hive>구성>고급으로 이동합니다.
  3. 고급 hive 사이트를 확장합니다.
  4. hive.metastore.client.socket.timeout을 찾아 값이 90s인지 확인합니다.

다른 구성 파일을 사용자 지정하는 추가 샘플:

# hdfs-site.xml configuration
$HdfsConfigValues = @{ "dfs.blocksize"="64m" } #default is 128MB in HDI 3.0 and 256MB in HDI 2.1

# core-site.xml configuration
$CoreConfigValues = @{ "ipc.client.connect.max.retries"="60" } #default 50

# mapred-site.xml configuration
$MapRedConfigValues = @{ "mapreduce.task.timeout"="1200000" } #default 600000

# oozie-site.xml configuration
$OozieConfigValues = @{ "oozie.service.coord.normal.default.timeout"="150" }  # default 120

.NET SDK 사용

.NET용 Azure HDInsight SDK를 참조하세요.

Resource Manager 템플릿 사용

Resource Manager 템플릿에서 부트스트랩을 사용할 수 있습니다.

"configurations": {
    "hive-site": {
        "hive.metastore.client.connect.retry.delay": "5",
        "hive.execution.engine": "mr",
        "hive.security.authorization.manager": "org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider"
    }
}

Hadoop customizes cluster bootstrap Azure Resource Manager template.

spark2-defaults에서 구성을 전환하는 샘플 Resource Manager 템플릿 코드 조각은 스토리지에서 이벤트 로그를 정기적으로 정리합니다.

"configurations": {
    "spark2-defaults": {
        "spark.history.fs.cleaner.enabled": "true",
        "spark.history.fs.cleaner.interval": "7d",
        "spark.history.fs.cleaner.maxAge": "90d"
    }
}

참고 항목

부록: PowerShell 샘플

이 PowerShell 스크립트는 HDInsight 클러스터를 만들고 Hive 설정을 사용자 지정합니다. $nameToken, $httpPassword, $sshPassword 값을 입력해야 합니다.

####################################
# Service names and variables
####################################

$nameToken = "<ENTER AN ALIAS>"
$namePrefix = $nameToken.ToLower() + (Get-Date -Format "MMdd")
$resourceGroupName = $namePrefix + "rg"
$hdinsightClusterName = $namePrefix + "hdi"
$defaultStorageAccountName = $namePrefix + "store"
$defaultBlobContainerName = $hdinsightClusterName
$location = "East US"

####################################
# Connect to Azure
####################################

Write-Host "Connecting to your Azure subscription ..." -ForegroundColor Green
$sub = Get-AzSubscription -ErrorAction SilentlyContinue
if(-not($sub))
{
    Connect-AzAccount
}

# If you have multiple subscriptions, set the one to use
#$context = Get-AzSubscription -SubscriptionId "<subscriptionID>"
#Set-AzContext $context

####################################
# Create a resource group
####################################

Write-Host "Creating a resource group ..." -ForegroundColor Green
New-AzResourceGroup `
    -Name  $resourceGroupName `
    -Location $location

####################################
# Create a storage account and container
####################################
	
Write-Host "Creating the default storage account and default blob container ..."  -ForegroundColor Green
New-AzStorageAccount `
    -ResourceGroupName $resourceGroupName `
    -Name $defaultStorageAccountName `
    -Location $location `
    -SkuName Standard_LRS `
    -Kind StorageV2 `
    -EnableHttpsTrafficOnly 1
	
$defaultStorageAccountKey = (Get-AzStorageAccountKey `
                                -ResourceGroupName $resourceGroupName `
                                -Name $defaultStorageAccountName)[0].Value

$defaultStorageContext = New-AzStorageContext `
                                -StorageAccountName $defaultStorageAccountName `
                                -StorageAccountKey $defaultStorageAccountKey
								
New-AzStorageContainer `
    -Name $defaultBlobContainerName `
    -Context $defaultStorageContext #use the cluster name as the container name

####################################
# Create a configuration object
####################################

$hiveConfigValues = @{"hive.metastore.client.socket.timeout"="90s"}
$storageAccountResourceId = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName ` -Name $defaultStorageAccountName).Id

$config = New-AzHDInsightClusterConfig `
          -ClusterType "Spark"  `
    | Set-AzHDInsightDefaultStorage `
        -StorageAccountResourceId "$storageAccountResourceId" `
        -StorageAccountKey $defaultStorageAccountKey `
    | Add-AzHDInsightConfigValue `
        -HiveSite $hiveConfigValues `
		-Spark2Defaults @{}
		
####################################
# Set Ambari admin username/password
####################################

$httpUserName = "admin"  #HDInsight cluster username
$httpPassword = '<ENTER A PASSWORD>'

$httpPW = ConvertTo-SecureString -String $httpPassword -AsPlainText -Force
$httpCredential = New-Object System.Management.Automation.PSCredential($httpUserName,$httpPW)

####################################
# Set ssh username/password
####################################

$sshUserName = "sshuser" #HDInsight ssh user name
$sshPassword = '<ENTER A PASSWORD>'

$sshPW = ConvertTo-SecureString -String $sshPassword -AsPlainText -Force
$sshCredential = New-Object System.Management.Automation.PSCredential($sshUserName,$sshPW)

####################################
# Create an HDInsight cluster
####################################

New-AzHDInsightCluster `
    -ResourceGroupName $resourceGroupName `
    -ClusterName $hdinsightClusterName `
    -Location $location `
    -ClusterSizeInNodes 2 `
    -Version "4.0" `
    -HttpCredential $httpCredential `
    -SshCredential $sshCredential `
    -Config $config
	
####################################
# Verify the cluster
####################################

Get-AzHDInsightCluster `
    -ClusterName $hdinsightClusterName