Azure HDInsight 클러스터에서 Data Lake Storage Gen1 사용

참고 항목

향상된 성능 및 새로운 기능을 위해 Azure Data Lake Storage Gen2를 사용하여 새 HDInsight 클러스터를 배포합니다.

HDInsight 클러스터에서 데이터를 분석하려면 데이터를 Azure Data Lake Storage Gen1 또는 Azure Data Lake Storage Gen2에 Azure Blob storage저장할 수 있습니다. 모든 스토리지 옵션을 사용하면 사용자 데이터를 잃지 않고 계산에 사용되는 HDInsight 클러스터를 안전하게 삭제할 수 있습니다.

이 문서에서는 Data Lake Storage Gen1이 HDInsight 클러스터에서 작동하는 방식에 대해 알아봅니다. Azure Blob Storage가 HDInsight 클러스터에서 작동하는 방식을 알아보려면 Azure HDInsight 클러스터에서 Azure Blob Storage 사용을 참조 하세요. HDInsight 클러스터를 만드는 방법에 대한 자세한 내용은 HDInsight에서 Apache Hadoop 클러스터 만들기를 참조하세요.

참고 항목

Data Lake Storage Gen1은 항상 보안 채널을 통해 액세스되므로 파일 시스템 체계 이름은 없습니다 adls . 항상 사용합니다 adl.

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.

HDInsight 클러스터의 가용성

Apache Hadoop은 기본 파일 시스템의 개념을 지원합니다. 기본 파일 시스템은 기본 체계 및 권한을 의미합니다. 상대 경로를 확인하는 데 사용할 수도 있습니다. HDInsight 클러스터를 만드는 동안 Azure Storage의 Blob 컨테이너를 기본 파일 시스템으로 지정합니다. 또는 HDInsight 3.5 이상 버전을 사용하면 몇 가지 예외를 제외하고 Azure Blob Storage 또는 Azure Data Lake Storage Gen1을 기본 파일 시스템으로 선택할 수 있습니다. 클러스터와 스토리지 계정은 동일한 지역에서 호스트되어야 합니다.

HDInsight 클러스터는 다음 두 가지 방법으로 Data Lake Storage Gen1을 사용할 수 있습니다.

  • 기본 스토리지로
  • 추가 스토리지로, Azure Blob Storage를 기본 스토리지로 사용합니다.

현재 일부 HDInsight 클러스터 유형/버전만 Data Lake Storage Gen1을 기본 스토리지 및 추가 스토리지 계정으로 사용할 수 있습니다.

HDInsight 클러스터 유형 Data Lake Storage Gen1을 기본 스토리지로 Data Lake Storage Gen1을 추가 스토리지로 주의
HDInsight 버전 4.0 아니요 아니요 ADLS Gen1은 HDInsight 4.0에서 지원되지 않습니다
HDInsight 버전 3.6 HBase 제외
HDInsight 버전 3.5 HBase 제외
HDInsight 버전 3.4
HDInsight 버전 3.3 아니요 아니요
HDInsight 버전 3.2

Warning

HDInsight HBase는 Azure Data Lake Storage Gen1에서 지원되지 않습니다.

Data Lake Storage Gen1 추가 스토리지 계정으로 사용하는 것은 성능에 영향을 미치지 않습니다. 또는 클러스터에서 Azure Blob Storage를 읽거나 쓸 수 있습니다.

Data Lake Storage Gen1을 기본 스토리지로 사용

HDInsight가 Data Lake Storage Gen1을 기본 스토리지로 배포하는 경우 클러스터 관련 파일은 Data Lake Storage에서 adl://mydatalakestore/<cluster_root_path>/만든 폴더의 이름인 위치에 <cluster_root_path> 저장됩니다. 각 클러스터에 대한 루트 경로를 지정하면 둘 이상의 클러스터에 대해 동일한 Data Lake Storage 계정을 사용할 수 있습니다. 따라서 다음 위치에 설치할 수 있습니다.

  • 클러스터 1은 경로를 사용할 수 있습니다. adl://mydatalakestore/cluster1storage
  • 클러스터 2는 경로를 사용할 수 있습니다. adl://mydatalakestore/cluster2storage

두 클러스터 모두 동일한 Data Lake Storage Gen1 계정 mydatalakestore를 사용합니다. 각 클러스터는 Data Lake Storage의 자체 루트 파일 시스템 액세스할 수 있습니다. Azure Portal 배포 환경에서는 루트 경로에 대해 /clusters/<clustername>과 같은 폴더 이름을 사용하라는 메시지를 표시합니다.

Data Lake Storage Gen1을 기본 스토리지로 사용하면 다음 경로에 대한 서비스 보안 주체 액세스 권한을 부여해야 합니다.

  • Data Lake Storage Gen1 계정 루트. 예: adl://mydatalakestore/.
  • 모든 클러스터 폴더의 폴더입니다. 예: adl://mydatalakestore/clusters.
  • 클러스터의 폴더입니다. 예: adl://mydatalakestore/clusters/cluster1storage.

서비스 주체를 만들고 액세스 권한을 부여하는 방법에 대한 자세한 내용은 Data Lake Storage 액세스 구성을 참조하세요.

클러스터 생성에 사용하기 위해 Azure KeyVault에서 인증서 추출

서비스 주체에 대한 인증서가 Azure Key Vault에 저장된 경우 인증서를 올바른 형식으로 변환해야 합니다. 다음 코드 조각은 전환을 수행하는 방법을 표시합니다.

먼저 Key Vault에서 인증서를 다운로드하고 SecretValueText.

$certPassword = Read-Host "Enter Certificate Password"
$cert = (Get-AzureKeyVaultSecret -VaultName 'MY-KEY-VAULT' -Name 'MY-SECRET-NAME')
$certValue = [System.Convert]::FromBase64String($cert.SecretValueText)

다음으로 SecretValueText를 인증서로 변환합니다.

$certObject = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $certValue,$null,"Exportable, PersistKeySet"
$certBytes = $certObject.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $certPassword.SecretValueText);
$identityCertificate = [System.Convert]::ToBase64String($certBytes)

그런 다음, $identityCertificate를 사용하여 다음 코드 조각에서처럼 새 클러스터를 배포할 수 있습니다.

New-AzResourceGroupDeployment `
    -ResourceGroupName $resourceGroupName `
    -TemplateFile $pathToArmTemplate `
    -identityCertificate $identityCertificate `
    -identityCertificatePassword $certPassword.SecretValueText `
    -clusterName  $clusterName `
    -clusterLoginPassword $SSHpassword `
    -sshPassword $SSHpassword `
    -servicePrincipalApplicationId $application.ApplicationId

Data Lake Storage Gen1을 추가 스토리지로 사용

Data Lake Storage Gen1을 클러스터에 대한 추가 스토리지로 사용할 수도 있습니다. 이러한 경우 클러스터 기본 스토리지는 Azure Blob Storage 또는 Azure Data Lake Storage Gen1 계정일 수 있습니다. 추가 스토리지로 Azure Data Lake Storage Gen1에 저장된 데이터에 대해 HDInsight 작업을 실행하는 경우 정규화된 경로를 사용합니다. 예시:

adl://mydatalakestore.azuredatalakestore.net/<file_path>

이제 URL에 cluster_root_path 없습니다. 이 경우 Data Lake Storage가 기본 스토리지가 아니기 때문입니다. 따라서 파일 경로를 제공하기만 하면 됩니다.

Data Lake Storage Gen1을 추가 스토리지로 사용하려면 서비스 주체에게 파일이 저장되는 경로에 대한 액세스 권한을 부여합니다. 예시:

adl://mydatalakestore.azuredatalakestore.net/<file_path>

서비스 주체를 만들고 액세스 권한을 부여하는 방법에 대한 자세한 내용은 Data Lake Storage 액세스 구성을 참조하세요.

둘 이상의 Data Lake Storage Gen1 계정 사용

Data Lake Storage 계정을 추가로 추가하고 둘 이상의 Data Lake Storage 계정을 추가할 수 있습니다. 하나 이상의 Data Lake Storage 계정의 데이터에 대한 HDInsight 클러스터 권한을 부여합니다. Data Lake Storage Gen1 액세스 구성을 참조하세요.

Data Lake Storage Gen1 액세스 구성

HDInsight 클러스터에서 Azure Data Lake Storage Gen1 액세스를 구성하려면 Microsoft Entra 서비스 주체가 있어야 합니다. Microsoft Entra 관리자만 서비스 주체를 만들 수 있습니다. 서비스 주체는 인증서를 사용하여 만들어야 합니다. 자세한 내용은 빠른 시작: HDInsight에서 클러스터 설정자체 서명된 인증서로 서비스 주체 만들기를 참조하세요.

참고 항목

Azure Data Lake Storage Gen1을 HDInsight 클러스터의 추가 스토리지로 사용하려는 경우 이 문서에서 설명한 대로 클러스터를 만드는 동안 이 작업을 수행하는 것이 좋습니다. 기존 HDInsight 클러스터에 Azure Data Lake Storage Gen1을 추가 스토리지로 추가하는 시나리오는 지원되지 않습니다.

액세스 제어 모델에 대한 자세한 내용은 Azure Data Lake Storage Gen1의 액세스 제어를 참조하세요.

클러스터에서 파일 액세스

HDInsight 클러스터에서 Data Lake Storage의 파일에 액세스할 수 있는 방법은 여러 가지입니다.

  • 정규화된 이름을 사용합니다. 이 방법을 사용하면 액세스하려는 파일에 대한 전체 경로를 제공합니다.

    adl://<data_lake_account>.azuredatalakestore.net/<cluster_root_path>/<file_path>
    
  • 단축된 경로 형식 사용. 이 방법을 사용하면 클러스터 루트까지의 경로를 다음으로 바꿉다.

    adl:///<file path>
    
  • 상대 경로 사용. 이 방법을 사용하면 액세스하려는 파일에 대한 상대 경로만 제공합니다.

    /<file.path>/
    

데이터 액세스 예제

예제는 클러스터의 헤드 노드에 대한 ssh 연결을 기반으로 합니다. 이 예제에서는 세 가지 URI 스키마를 모두 사용합니다. CLUSTERNAME 관련 값으로 바꿉 DATALAKEACCOUNT 다.

몇 가지 hdfs 명령

  1. 로컬 스토리지에 파일을 만듭니다.

    touch testFile.txt
    
  2. 클러스터 스토리지에 디렉터리를 만듭니다.

    hdfs dfs -mkdir adl://DATALAKEACCOUNT.azuredatalakestore.net/clusters/CLUSTERNAME/sampledata1/
    hdfs dfs -mkdir adl:///sampledata2/
    hdfs dfs -mkdir /sampledata3/
    
  3. 로컬 스토리지에서 클러스터 스토리지로 데이터를 복사합니다.

    hdfs dfs -copyFromLocal testFile.txt adl://DATALAKEACCOUNT.azuredatalakestore.net/clusters/CLUSTERNAME/sampledata1/
    hdfs dfs -copyFromLocal testFile.txt adl:///sampledata2/
    hdfs dfs -copyFromLocal testFile.txt /sampledata3/
    
  4. 클러스터 스토리지의 디렉터리 콘텐츠를 나열합니다.

    hdfs dfs -ls adl://DATALAKEACCOUNT.azuredatalakestore.net/clusters/CLUSTERNAME/sampledata1/
    hdfs dfs -ls adl:///sampledata2/
    hdfs dfs -ls /sampledata3/
    

Hive 테이블 만들기

설명용으로 세 개의 파일 위치가 표시됩니다. 실제 실행의 경우 항목 중 LOCATION 하나만 사용합니다.

DROP TABLE myTable;
CREATE EXTERNAL TABLE myTable (
    t1 string,
    t2 string,
    t3 string,
    t4 string,
    t5 string,
    t6 string,
    t7 string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '
STORED AS TEXTFILE
LOCATION 'adl://DATALAKEACCOUNT.azuredatalakestore.net/clusters/CLUSTERNAME/example/data/';
LOCATION 'adl:///example/data/';
LOCATION '/example/data/';

Ambari에서 스토리지 경로 식별

구성된 기본 저장소의 전체 경로를 식별하려면 HDFS 구성으로 이동하여 필터 입력 상자에 입력 fs.defaultFS 합니다.>

Data Lake Storage Gen1에 액세스할 수 있는 HDInsight 클러스터 만들기

Data Lake Storage Gen1에 액세스할 수 있는 HDInsight 클러스터를 만드는 방법에 대한 자세한 지침은 다음 링크를 사용합니다.

Data Lake Storage Gen1 액세스에 대한 HDInsight 인증서 새로 고침

다음 예제 PowerShell 코드는 로컬 파일 또는 Azure Key Vault에서 인증서를 읽고 새 인증서로 HDInsight 클러스터를 업데이트하여 Azure Data Lake Storage Gen1에 액세스합니다. 고유한 HDInsight 클러스터 이름, 리소스 그룹 이름, 구독 ID, app ID인증서의 로컬 경로를 제공합니다. 메시지가 표시되면 암호를 입력합니다.

$clusterName = '<clustername>'
$resourceGroupName = '<resourcegroupname>'
$subscriptionId = '01234567-8a6c-43bc-83d3-6b318c6c7305'
$appId = '01234567-e100-4118-8ba6-c25834f4e938'
$addNewCertKeyCredential = $true
$certFilePath = 'C:\localfolder\adls.pfx'
$KeyVaultName = "my-key-vault-name"
$KeyVaultSecretName = "my-key-vault-secret-name"
$certPassword = Read-Host "Enter Certificate Password"
# certSource
# 0 - create self signed cert
# 1 - read cert from file path
# 2 - read cert from key vault
$certSource = 0

Login-AzAccount
Select-AzSubscription -SubscriptionId $subscriptionId

if($certSource -eq 0)
{
    Write-Host "Generating new SelfSigned certificate"

    $cert = New-SelfSignedCertificate -CertStoreLocation "cert:\CurrentUser\My" -Subject "CN=hdinsightAdlsCert" -KeySpec KeyExchange
    $certBytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $certPassword);
    $certString = [System.Convert]::ToBase64String($certBytes)
}
elseif($certSource -eq 1)
{

    Write-Host "Reading the cert file from path $certFilePath"

    $cert = new-object System.Security.Cryptography.X509Certificates.X509Certificate2($certFilePath, $certPassword)
    $certString = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($certFilePath))
}
elseif($certSource -eq 2)
{

    Write-Host "Reading the cert file from Azure Key Vault $KeyVaultName"

    $cert = (Get-AzureKeyVaultSecret -VaultName $KeyVaultName -Name $KeyVaultSecretName)
    $certValue = [System.Convert]::FromBase64String($cert.SecretValueText)
    $certObject = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $certValue, $null,"Exportable, PersistKeySet"

    $certBytes = $certObject.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $certPassword.SecretValueText);

    $certString =[System.Convert]::ToBase64String($certBytes)
}

if($addNewCertKeyCredential)
{
    Write-Host "Creating new KeyCredential for the app"
    $keyValue = [System.Convert]::ToBase64String($cert.GetRawCertData())
    New-AzADAppCredential -ApplicationId $appId -CertValue $keyValue -EndDate $cert.NotAfter -StartDate $cert.NotBefore
    Write-Host "Waiting for 7 minutes for the permissions to get propagated"
    Start-Sleep -s 420 #7 minutes
}

Write-Host "Updating the certificate on HDInsight cluster..."

Invoke-AzResourceAction `
    -ResourceGroupName $resourceGroupName `
    -ResourceType 'Microsoft.HDInsight/clusters' `
    -ResourceName $clusterName `
    -ApiVersion '2015-03-01-preview' `
    -Action 'updateclusteridentitycertificate' `
    -Parameters @{ ApplicationId = $appId; Certificate = $certString; CertificatePassword = $certPassword.ToString() } `
    -Force

다음 단계

이 문서에서는 HDInsight로 HDFS 호환 Azure Data Lake Storage Gen1을 사용하는 방법을 알아보았습니다. 이 스토리지를 사용하면 적응 가능한 장기 보관 데이터 취득 솔루션을 빌드할 수 있습니다. 또한 HDInsight를 사용하여 저장된 구조화 및 구조화되지 않은 데이터 내의 정보를 잠금 해제합니다.

자세한 내용은 다음을 참조하세요.