建立虛擬 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. 登入 Google Cloud 帳戶。如果您未曾使用過 Google Cloud,歡迎建立帳戶,親自體驗實際使用我們產品的成效。新客戶還能獲得價值 $300 美元的免費抵免額,用於執行、測試及部署工作負載。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Compute Engine API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

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

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Compute Engine API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

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

  • Google Chrome 瀏覽器,用於存取 Google Cloud 控制台。
  • Windows、Mac 或 Linux 適用的最新 PCoIP 用戶端軟體,用於存取虛擬工作站。
  • help.teradici.com 帳戶,用於下載 HP Anyware 軟體。註冊帳戶完全免費。
  • 現有的 HP Anyware 軟體授權和註冊碼。HP Anyware 已停止向新客戶銷售,因此不再提供新的試用授權。

架構

下圖顯示本教學課程在部署單一虛擬工作站時使用的元件。圖中顯示的選用元件包括連線至虛擬工作站、共用儲存空間、用於提供第三方授權的其他 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 主機軟體。如要透過 RDP 登入,您必須為使用者建立 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://docs.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. 在 RDP 工作階段中,按一下 Windows 工作列上的「Start」(開始) 按鈕,然後輸入 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」(PCoIP 主機) 專區。
  2. 下載 Standard Agent for Windows。
  3. 如果尚未登入,請按一下「登入以下載」。
  4. 按一下「下載和指令碼」。
  5. 完成代理程式安裝程序,並選擇執行下載的標準代理程式執行檔。按照提示在預設位置安裝 Standard Agent。

註冊 Anyware Standard Agent

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

  1. 在「License Registration」(授權註冊) 視窗中,輸入現有的 HP Anyware 註冊碼。

  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. 前往 Google Cloud 控制台的「Manage resources」(管理資源) 頁面。

    前往「Manage resources」(管理資源)

  2. 在專案清單中選取要刪除的專案,然後點選「Delete」(刪除)。
  3. 在對話方塊中輸入專案 ID,然後按一下 [Shut down] (關閉) 以刪除專案。

後續步驟