启用 Migrate to Virtual Machines 服务

在开始迁移之前,您必须在 Google Cloud 上启用 Migrate to Virtual Machines 服务,同时启用 Migrate to Virtual Machines 所需的所有其他 Google Cloud 服务。

标识宿主项目

Google Cloud 项目是执行下列操作的基础:创建、启用和使用 Google Cloud 服务,包括管理 API、启用结算功能、添加和移除协作者以及管理 Google Cloud 资源的权限。

Migrate to Virtual Machines 使用以下类型的项目:

  • 宿主项目(必需)

    使用宿主项目来控制迁移过程,并视情况托管运行迁移后工作负载的 Compute Engine 实例。您必须按照以下部分中的说明创建和配置宿主项目。

  • 目标项目(可选)

    目标项目定义运行迁移的虚拟机的 Compute Engine 实例的目标项目。您的宿主项目可用作目标项目。如果您想要将虚拟机迁移到其他项目,则必须将其作为目标项目添加到 Migrate to Virtual Machines。如需了解详情,请参阅添加目标项目

如需启用 Migrate to Virtual Machines 服务,您必须标识要用作宿主项目的 Google Cloud 项目:

  1. 在 Google Cloud 控制台的“项目选择器”页面上,选择或创建一个用作宿主项目的 Google Cloud 项目:

    转到项目选择器页面

  2. 记下所选项目的名称和 ID。

安装 gcloud CLI

在工作站上安装 gcloud CLI,该工作站还会安装 Google Cloud CLI。gcloud 是您用于创建和管理 Google Cloud 资源的主要 CLI 工具。您可以使用 gcloud 从命令行、脚本或其他自动化功能执行多项常见平台任务。

如需安装 gcloud CLI,请执行以下操作:

  1. 安装并初始化 gcloud CLI

  2. 更新 gcloud CLI:

    gcloud components update
  3. 确保 gcloud CLI 有权访问您的数据和服务:

    gcloud auth login
  4. 您的浏览器会打开一个新标签页,并提示您选择一个账号。

在宿主项目上启用必需的服务

在宿主项目中,启用 Migrate to Virtual Machines 服务所需的 Google Cloud 服务。如需详细了解这些服务,请参阅 gcloud services

Migrate to Virtual Machines 的宿主项目要求您启用以下 Google Cloud 服务:

名称 标题
vmmigration.googleapis.com Migrate to Virtual Machines API
servicemanagement.googleapis.com Service Management API
servicecontrol.googleapis.com Service Control API
iam.googleapis.com Identity and Access Management (IAM) API
cloudresourcemanager.googleapis.com Cloud Resource Manager API
compute.googleapis.com Compute Engine API

如需启用所需的服务,请执行以下操作:

  1. 确保您已将默认项目设置为宿主项目。将 PROJECT_ID 替换为您的宿主项目的 ID:

    gcloud config set project PROJECT_ID
  2. 查看已在项目中启用的服务的列表:

    gcloud services list
  3. 如果您没有看到列出的所有必需服务,请启用它们:

    gcloud services enable vmmigration.googleapis.com servicemanagement.googleapis.com servicecontrol.googleapis.com iam.googleapis.com cloudresourcemanager.googleapis.com compute.googleapis.com 
  4. 您现在应该能够打开 Google Cloud 控制台中的 Migrate to Virtual Machines 页面:

    转到 Migrate to Virtual Machines 页面

使用预定义角色

Identity and Access Management 包括两个预定义角色,您可以使用这些预定义角色来控制组织内用户的访问权限:

角色 名称 说明
roles/vmmigration.admin VM Migration Administrator 允许用户创建新的 Migrate to Virtual Machine 来源并执行所有其他迁移操作。
roles/vmmigration.viewer VM Migration Viewer 允许用户在 Google Cloud 控制台中检索有关 Migrate to Virtual Machines 的信息。适用于正在执行迁移但未设置系统或添加新的迁移来源的用户。

例如,如果您希望组织中的用户能够查看迁移相关信息但无法执行迁移,请为用户分配 roles/vmmigration.viewer 角色。

后续步骤