创建虚拟 Windows 工作站


本教程介绍如何创建一个运行 Windows Server 2022 且具有虚拟显示的虚拟 Windows 工作站。如果虚拟机 (VM) 实例上的应用需要显示设备,但并不需要 GPU 的全部功能或者您不想支付其全部费用,那么虚拟显示设备就非常有用。

如需了解其他类型的虚拟工作站(包括 Linux),请参阅创建虚拟工作站简介

创建虚拟工作站后,您将学习如何使用HP Anywhere(以前称为 Teradici CAS)和 PC-over-IP (PCoIP®) 远程访问该工作站。PCoIP 是广泛应用于媒体娱乐、游戏开发、架构和工程行业的远程桌面协议。PCoIP 提供了对这些类型的工作负载至关重要的功能,例如色彩精确度、对多个显示器的支持、无损显示以及平板电脑压力灵敏度。

本教程假定您熟悉 Microsoft Windows 和 PowerShell 命令行。

目标

  • 创建一个 Compute Engine 虚拟机。此虚拟机用作虚拟工作站的基础。
  • 在虚拟工作站上安装 HP Anyware 软件。
  • 使用 PCoIP 软件客户端连接到虚拟工作站。

费用

本教程使用Google Cloud的以下收费组件:

您可使用价格计算器根据您的预计用量来估算费用。

虚拟工作站的构成资源以及影响本教程中所述费用的因素包括:

互联网数据传输表示从虚拟工作站流向本地显示客户端的数据,按互联网出站数据传输费用计费。影响 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 客户端软件(用于访问虚拟工作站)。
    • help.teradici.com 上的账号(用于下载 HP Anyware 软件)。注册账号是免费的。
    • HP Anyware 软件许可。您可以申请试用许可,或联系您的 HP 代表索取此虚拟工作站的试用注册代码。

架构

下图显示了按照本教程部署单个虚拟工作站需要用到的组件。图中显示的可选组件包括连接到虚拟工作站的几种不同方式、共享存储、用于提供第三方许可的另外一个虚拟机,以及代表渲染或计算农场的其他基础设施。

虚拟工作站基础架构。

选择一个区域。

部署虚拟工作站时需要考虑的一项重要因素是您的位置与您创建的虚拟机之间的延迟时间。延迟时间越短,体验越好。因此,建议您将虚拟机放置在与您的地理位置最近的区域和可用区中。

创建虚拟工作站

在 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:虚拟机实例的名称。
  • ZONE:与您的地理位置最近的可用区。部署虚拟工作站时需要考虑的一项重要因素是您的位置与您创建的虚拟机之间的延迟时间。延迟时间越短,体验越好。如需了解可用区的地理位置,请参阅可用的区域和可用区

创建虚拟工作站后,将显示虚拟机状态。输出类似于以下内容:

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 替换为要更改其密码的虚拟机的名称。

  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. 您现在可以使用新凭据连接到虚拟机实例

登录虚拟工作站

创建虚拟工作站后,请登录机器来配置该工作站。

  1. 在本地工作站上,使用原生 RDP 客户端通过虚拟工作站的外部 IP 地址连接到该虚拟工作站。
  2. 当系统提示您输入凭据时,请输入您之前生成的用户名和密码。
  3. 如果您看到证书警告,请忽略并点击继续

此时将显示虚拟工作站桌面。启动 Windows Server Manager 后将其关闭。

安装 Google Chrome

下一步是在虚拟机实例上安装 Chrome。

  1. 在 RDP 会话中,点击 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 主机部分
  2. 下载适用于 Windows 的 Standard Agent
  3. 如果您尚未登录,请点击登录下载
  4. 点击下载和脚本
  5. 完成代理安装过程,并选择运行已下载的 Standard Agent 可执行文件。按照提示将 Standard Agent 安装到默认位置。

注册 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 客户端部分,然后下载、安装并启动适用于您的操作系统的 PCoIP 软件客户端应用。

  2. Host Address 或 Registration Code 字段中,输入虚拟工作站的外部 IP 地址。如果需要,可以输入连接名称。

  3. 连接后,输入之前为虚拟工作站创建的用户名和密码,以进行身份验证。

    几秒钟后,系统会显示您的 Windows 桌面。

在虚拟工作站上激活音频

要在虚拟工作站上激活音频,请启用 Teradici 虚拟音频驱动程序作为默认播放设备。

  1. 在 Windows 虚拟机上,点击 Windows 任务栏上的“Start”按钮,然后输入 mmsys.cpl 以打开“Sound”控制台,并初始化 Teradici 虚拟音频驱动程序。

  2. 点击。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.

后续步骤