共用方式為


建立 HPC Pack IaaS 計算節點的自訂 VM 映像

本文說明如何建立自己的自定義 VM 映射,以部署 HPC Pack 2016 叢集的 IaaS 計算節點。

有兩種不同的方式可以建立自定義的 VM 映射,一個用於 HPC Pack 2016 Update 3 和 HPC Pack 2019,另一個用於 HPC Pack 2016 RTM、HPC Pack 2016 Update 1 和 HPC Pack 2016 Update 2。 您應該根據前端節點的 HPC Pack 版本來選取正確的方式。

備註

HPC Pack Update 3 VM 映射和 HPC Pack Update 2(和更早版本)VM 映射之間的差異在於 HPC Pack 計算節點和 Windows Management Framework 5.1 必須在後者中預安裝。

小提示

您也可以使用 Azure Image Builder 功能,將自定義的 VM 映射建立自動化。

建立 HPC Pack 2016 Update 3 和 HPC Pack 2019 的自定義 VM 映像

步驟 1:在 Azure 中建立虛擬機

Azure 入口網站上,建立具有下列其中一個作系統的 Azure 虛擬機: Windows Server 2012、Windows Server 2012 R2、Windows Server 2016、Windows Server 2019

步驟 2:在虛擬機中安裝和設定您自己的應用程式

登入虛擬機,並安裝及設定您自己的應用程式。

步驟 3:使用 Sysprep 將虛擬機一般化

詳細連結: 在建立映像之前將 VM 一般化

  1. 登入您的 Windows 虛擬機。
  2. 開啟命令提示字元視窗,以系統管理員身分執行。
  3. 刪除 panther 目錄 (C:\Windows\Panther)。
  4. 然後將目錄變更為 %windir%\system32\sysprep,然後執行:sysprep.exe /oobe /generalize /mode:vm /shutdown

當 Sysprep 完成 VM 一般化時,VM 將會關閉。 不要重新啟動 VM。

在 Sysprep 完成後,請將虛擬機器的狀態設定為 [已一般化]

Set-AzVm -ResourceGroupName $rgName -Name $vmName -Generalized

步驟 4:建立 VM 映射

開啟 Azure 入口網站,從虛擬機清單中尋找虛擬機。 在虛擬機的 [ 概觀 ] 頁面上,按兩下 [ 擷取 ] 以從虛擬機建立受控映像。

  1. 開啟 Azure 入口網站
  2. 在左側功能表中,單擊 [虛擬機],然後尋找虛擬機。
  3. 在虛擬機的 [概 ] 頁面上,單擊上方功能表上的 [ 擷取]。
  4. [名稱] 中,輸入您想要用於影像的名稱。
  5. [資源群組 ] 中,選取 [ 新建 ] 並輸入名稱,或選取 [ 使用現有的 ],然後從下拉式清單中選取要使用的資源群組。
  6. 建立映像之後,選取 [自動刪除此虛擬機]。
  7. 按兩下 [建立 ] 以建立 VM 映像。

建立 HPC Pack 2016 Update 2 的自定義 VM 映射(或更早版本)

步驟 1:使用 HPC Pack 2016 Update 2 建立或選取 Azure IaaS 計算節點(或舊版)

您可以建立 Azure 虛擬機,並在其上手動安裝正確的 HPC Pack 2016 計算節點版本,或在現有的 HPC Pack 2016 叢集中選取目前執行的 Azure IaaS 計算節點。

如果未在 IaaS 計算節點中安裝 Windows Management Framework (WMF) 5.1 ,請下載並安裝它。

步驟 2:在 Azure IaaS 計算節點中安裝和設定您自己的應用程式

登入虛擬機,並安裝及設定您自己的應用程式。

步驟 3:從虛擬機卸載 VM 擴充功能

Azure 入口網站上,尋找對應的 Azure 虛擬機,單擊 [ 擴充功能],如果有的話,請卸載所有 VM 擴充功能。

步驟 4:從計算節點清除叢集特定資訊

以系統管理員身分登入 Azure IaaS 計算節點、以系統管理員身分開啟 Windows PowerShell 控制台,然後執行下列 PowerShell 腳本來清除叢集特定資訊。

# Step 1. Stop all the HPC services and change StartupType to Disabled
$hpcServices = @("HpcManagement", "HpcNodeManager", "msmpi", "HpcMonitoringClient", "HpcSoaDiagMon")
foreach($svc in $hpcServices)
{
    Stop-Service -Name $svc -Force -ErrorAction SilentlyContinue
    Set-Service -Name $svc -StartupType Disabled
}

# Step 2: Remove HPC logs and temp files from this node
$datadir = [System.Environment]::GetEnvironmentVariable("CCP_DATA", [System.EnvironmentVariableTarget]::Machine)
$logFilesPath = [System.IO.Path]::Combine($datadir, "LogFiles")
if(Test-Path $logFilesPath -PathType Container)
{
    Get-ChildItem -Path $logFilesPath | select -ExpandProperty FullName | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
Get-ChildItem -Path C:\Windows\Temp  | select -ExpandProperty FullName | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:TEMP | select -ExpandProperty FullName | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue

# Step 3: Remove CustomData.bin if it exists
Remove-Item "$env:SYSTEMDRIVE\AzureData\CustomData.bin" -Force -ErrorAction SilentlyContinue

# Step 4: Remove the HPC communication certificate
$thumbprint = Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\HPC -Name SSLThumbPrint
Remove-Item Cert:\LocalMachine\My\$thumbprint -ErrorAction SilentlyContinue
Remove-Item Cert:\LocalMachine\Root\$thumbprint -ErrorAction SilentlyContinue

# Step 5: Clear the information of the current HPC cluster
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\HPC -Name ClusterConnectionString -Value ""
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\HPC -Name SSLThumbPrint -Value ""
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\HPC -Name NonDomainRole -Value 0 -Type DWord
if(Test-Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\HPC)
{
    Set-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\HPC -Name ClusterConnectionString -Value ""
    Set-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\HPC -Name SSLThumbPrint -Value ""
    Set-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\HPC -Name NonDomainRole -Value 0 -Type DWord
}

[Environment]::SetEnvironmentVariable("CCP_SCHEDULER", "", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("CCP_CLUSTERCONNECTIONSTRING", "", [System.EnvironmentVariableTarget]::Machine)

步驟 5:使用 Sysprep 將虛擬機一般化

詳細連結: 在建立映像之前將 VM 一般化

  1. 登入您的 Windows 虛擬機。
  2. 開啟命令提示字元視窗,以系統管理員身分執行。
  3. 刪除 panther 目錄 (C:\Windows\Panther)。
  4. 然後將目錄變更為 %windir%\system32\sysprep,然後執行:sysprep.exe /oobe /generalize /mode:vm /shutdown

當 Sysprep 完成 VM 一般化時,VM 將會關閉。 不要重新啟動 VM。

在 Sysprep 完成後,請將虛擬機器的狀態設定為 [已一般化]

Set-AzVm -ResourceGroupName $rgName -Name $vmName -Generalized

步驟 6:建立 VM 映射

開啟 Azure 入口網站,從虛擬機清單中尋找虛擬機。 在虛擬機的 [ 概觀 ] 頁面上,按兩下 [ 擷取 ] 以從虛擬機建立受控映像。

  1. 開啟 Azure 入口網站
  2. 在左側功能表中,單擊 [虛擬機],然後尋找虛擬機。
  3. 在虛擬機的 [概 ] 頁面上,單擊上方功能表上的 [ 擷取]。
  4. [名稱] 中,輸入您想要用於影像的名稱。
  5. [資源群組 ] 中,選取 [ 新建 ] 並輸入名稱,或選取 [ 使用現有的 ],然後從下拉式清單中選取要使用的資源群組。
  6. 建立映像之後,選取 [自動刪除此虛擬機]。
  7. 按兩下 [建立 ] 以建立 VM 映像。