建立虛擬 Windows 工作站


本教學課程說明如何建立執行 Windows Server 2022 的虛擬 Windows 工作站,並搭配虛擬螢幕。如果虛擬機器 (VM) 執行個體上的應用程式需要顯示裝置,但不需要 GPU 的完整功能或成本,虛擬顯示裝置就非常實用。

如要瞭解其他類型的虛擬工作站 (包括 Linux),請參閱「建立虛擬工作站簡介」。

建立虛擬工作站後,您會學習如何使用 HP Anyware (前身為 Teradici CAS),透過 PC-over-IP (PCoIP®) 技術遠端存取該工作站。PCoIP 是媒體和娛樂、遊戲開發、建築和工程業廣泛使用的遠端桌面通訊協定。為色彩準確度、多螢幕支援、無失真顯示和繪圖板壓力感應等工作負載提供不可或缺的功能。

本教學課程假設您熟悉 Microsoft Windows 和 PowerShell 指令列。

目標

  • 建立 Compute Engine VM。這個 VM 是虛擬工作站的基礎。
  • 在虛擬工作站上安裝 HP Anyware 軟體。
  • 使用 PCoIP 軟體用戶端連線到虛擬工作站。

費用

本教學課程使用Google Cloud的下列計費元件:

您可以使用 Pricing Calculator,根據您的預測使用量產生預估費用。

在本教學課程中,構成虛擬工作站的資源以及會影響費用的因素如下:

網際網路資料移轉是指從虛擬工作站串流至本機顯示用戶端的資料,按照網際網路輸出資料移轉費用計費。 在 PCoIP 工作階段期間,會影響資料傳輸的變數有頻寬、螢幕解析度、顯示監視器數量、使用的應用程式及各監視器上的活動類型。HP Anyware 的工作階段規劃指南可協助您瞭解不同的工作負載需求。

事前準備

本教學課程會使用 Google Cloud CLI,您可以透過從 Google Cloud console 啟動的 Cloud Shell 執行個體來執行。如要在本機工作站上使用 gcloud CLI,請安裝 Google Cloud CLI。本教學課程說明如何在 Cloud Shell 中執行指令;如果您是在工作站上使用 gcloud CLI,請視情況調整您的操作。

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Compute Engine API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Compute Engine API.

    Enable the API

  8. 此外,請確認您擁有下列項目:

    • Google Chrome 瀏覽器,用來存取 Google Cloud 控制台。
    • 最新的 Windows 版、Mac 版或 Linux 版 PCoIP Client 軟體,用來存取虛擬工作站。
    • help.teradici.com 建立帳戶,下載 HP Anyware 軟體。註冊帳戶完全免費。
    • HP Anyware 軟體授權。您可以申請試用授權,或是洽詢 HP 代表並索取試用註冊碼,以用於這個虛擬工作站。

架構

下圖顯示本教學課程在部署單一虛擬工作站時使用的元件。圖中的選用元件包括了連線至虛擬工作站、共用儲存空間的不同連線方式,以及用於提供第三方授權的其他 VM,還有代表算繪或運算伺服器陣列的其他基礎架構。

虛擬工作站基礎架構的架構。

選擇一個區域

有個重要因素會影響您部署虛擬工作站,那就是您所在位置與您所建立 VM 之間的時間延遲。延遲時間越短,您的體驗就會越好。因此,建議將 VM 放在地理位置離您最近的區域和可用區。

建立虛擬工作站

在 Cloud Shell 中,建立 Compute Engine 虛擬工作站執行個體:

gcloud compute instances create VM_NAME \
    --zone=ZONE \
    --machine-type=e2-standard-4 \
    --enable-display-device \
    --image-project=windows-cloud \
    --image-family=windows-2022 \
    --boot-disk-size=50 \
    --boot-disk-type=pd-balanced \
    --network=default

更改下列內容:

  • VM_NAME:VM 執行個體的名稱。
  • ZONE:地理位置離您最近的區域。有個重要因素會影響您部署虛擬工作站,那就是您所在位置與您所建立 VM 之間的時間延遲。延遲時間越短,體驗就會越好。如要瞭解區域的地理位置,請參閱「可用地區和區域」。

虛擬工作站建立完成後,畫面上會顯示 VM 的狀態,輸出內容會與以下所示內容類似:

NAME: test-workstation
ZONE: us-west1-b
MACHINE_TYPE: e2-standard-4
PREEMPTIBLE:
INTERNAL_IP: 10.138.XX.XXX
EXTERNAL_IP: XX.XXX.XXX.XXX
STATUS: RUNNING

請記下外部 IP 位址,本教學課程的後續步驟會用到。

建立 Windows 密碼

您將使用 RDP 存取 Windows 虛擬工作站,以安裝 HP Anyware Standard Agent 主機軟體。如要利用遠端桌面協定來登入,您必須為使用者設定 Windows 密碼。

  1. 在 Cloud Shell 中執行下列指令:

    gcloud compute reset-windows-password VM_NAME

    VM_NAME 替換為要變更密碼的 VM 名稱。

  2. 查看確認提示中的資訊:

    This command creates an account and sets an initial password for the
    user [username] if the account does not already exist.
    If the account already exists, resetting the password can cause the
    LOSS OF ENCRYPTED DATA secured with the current password, including
    files and stored passwords.
    
    For more information, see:
    https://cloud.google.com/compute/docs/instances/windows/generating-credentials#console
    
    Would you like to set or reset the password for [username] (Y/n)?
    
  3. 確認先前的提示後,請查看新憑證的確認訊息,如下所示:

    Resetting and retrieving password for [username] on [instance-name]
    Updated [https://www.googleapis.com/compute/v1/projects/project-name/zones/zone/instances/instance-name].
    ip_address: ip-address
    password:   password
    username:   username
    
  4. 您現在可以使用新憑證連線至 VM 執行個體

登入虛擬工作站

建立虛擬工作站之後,請登入該機器以進行設定。

  1. 在本地工作站上,使用 RDP 用戶端透過外部 IP 位址連線至虛擬工作站。
  2. 當系統提示您輸入憑證時,請輸入您先前產生的使用者名稱和密碼。
  3. 如果看到憑證警告,請忽略並按一下「繼續」

畫面上會隨即顯示虛擬工作站的桌面。Windows Server Manager 啟動完畢後,請關閉該管理員。

安裝 Google Chrome

下一步是在 VM 執行個體上安裝 Chrome。

  1. 在遠端桌面協定工作階段中,按一下 Windows 工作列上的「開始」按鈕,然後輸入 Windows PowerShell
  2. 在 Windows PowerShell 上按一下滑鼠右鍵,然後選取「以系統管理員身分執行」
  3. 在 PowerShell 提示中,啟用 HTTPS 要求:

    [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
    
  4. 下載並執行 Chrome 安裝程式:

    $installer = "$env:TEMP\chrome_installer.exe";
    Write-Host 'Downloading Chrome.'
    Invoke-WebRequest `
    'https://dl.google.com/chrome/install/latest/chrome_installer.exe' `
      -OutFile $installer
    Write-Host 'Installing Chrome.'
    & $installer /silent /install | Out-Default
    Remove-Item $installer
    
  5. 指令執行完成後,請關閉 PowerShell。

安裝 HP Anyware 軟體

HP Anyware 軟體提供的代理程式可在虛擬工作站上執行,並將桌面傳送給您的硬體或軟體用戶端。

  1. 在 Windows 執行個體上開啟 Google Chrome,然後前往 HP Anyware 支援頁面的「PCoIP Hosts」部分。
  2. 下載 Windows 版標準代理程式
  3. 如果尚未登入,請按一下「登入以下載」
  4. 按一下「下載內容和指令碼」
  5. 完成代理程式的安裝程序,然後選擇要執行已下載的標準代理程式執行檔的選項。請依照系統提示,在預設位置安裝標準代理程式。

註冊 Anyware Standard Agent

安裝程序完成後,系統會提示您輸入註冊碼。

  1. 在「License Registration」視窗中,輸入試用申請程序中收到的註冊代碼。

  2. 輸入註冊碼之後,請重新啟動 Windows 執行個體。

建立防火牆規則

PCoIP 用戶端會使用幾個通訊埠,與虛擬工作站通訊。您必須設定防火牆規則,允許流量傳送至虛擬工作站。

  • 請在 Cloud Shell 中 (而非虛擬工作站上),建立防火牆規則來開啟必要通訊埠:

    gcloud compute firewall-rules create allow-pcoip \
        --action=ALLOW \
        --rules=tcp:443,tcp:4172,udp:4172 \
        --source-ranges=0.0.0.0/0
    

使用 PCoIP 用戶端登入虛擬工作站

  1. 在您的本機電腦上,前往 HP Anyware 支援頁面的「PCoIP Clients」部分,然後下載、安裝並啟動您作業系統適用的 PCoIP 軟體用戶端應用程式。

  2. 在「Host Address or Registration Code」欄位中,輸入虛擬工作站的外部 IP 位址。如果想要輸入連線名稱,也可以輸入。

  3. 連線後,請輸入先前為虛擬工作站建立的使用者名稱和密碼進行身分認證。

    幾秒後,您就會看到 Windows 桌面。

啟用虛擬工作站的音訊

如要在虛擬工作站上啟用音訊,請將 Teradici Virtual Audio Driver 設為預設播放裝置。

  1. 在 Windows VM 中,按一下 Windows 工作列上的「開始」按鈕,然後輸入 mmsys.cpl 開啟「聲音」控制台,並初始化 Teradici 虛擬音訊驅動程式。

  2. 按一下 [Yes] (是)。Windows 會確認音訊驅動程式是否正常運作。

測試虛擬工作站

部署虛擬工作站之後,可以使用以下數種工具來測試工作站的效能和互動情況:

您也可以根據工作負載,進一步瞭解如何最佳化 PCoIP 效能

清除所用資源

如要避免系統向您的 Google Cloud 帳戶收取本教學課程中所用資源的相關費用,請刪除含有該項資源的專案,或者保留專案但刪除個別資源。

停止虛擬工作站的運作

停止運作的虛擬工作站會產生永久磁碟的使用費用,但您隨時都可以重新啟動虛擬工作站。如要停止虛擬工作站的運作,請執行下列指令:

gcloud compute instances stop VM_NAME

刪除所有元件

  1. 刪除虛擬工作站
  2. 刪除防火牆規則

刪除專案

  1. In the Google Cloud console, go to the Manage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

後續步驟