在 Compute Engine 中创建 Linux 虚拟机实例

了解如何使用 Google Cloud 控制台在 Compute Engine 中创建 Linux 虚拟机实例。


如需在 Google Cloud 控制台中直接遵循有关此任务的分步指导,请点击操作演示

操作演示


准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud 新手,请创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
  2. 在 Google Cloud Console 中的项目选择器页面上,选择或创建一个 Google Cloud 项目

    转到“项目选择器”

  3. 确保您的 Google Cloud 项目已启用结算功能

  4. 在 Google Cloud Console 中的项目选择器页面上,选择或创建一个 Google Cloud 项目

    转到“项目选择器”

  5. 确保您的 Google Cloud 项目已启用结算功能

  6. 启用 Compute Engine API。

    启用 Compute Engine API

创建 Linux 虚拟机实例

  1. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  2. In the Boot disk section, click Change to begin configuring your boot disk.
  3. Public images 标签页上,从操作系统列表中选择 Ubuntu
  4. 版本列表中选择 Ubuntu 20.04 LTS
  5. 点击选择
  6. 防火墙部分,选择 允许 HTTP 流量
  7. 如需创建虚拟机,请点击创建

启动实例需要一段时间,请稍等片刻。实例准备就绪后,将在虚拟机实例页面列出,并带有绿色状态图标。

Compute Engine 向创建虚拟机的用户授予 roles/compute.instanceAdmin 角色。Compute Engine 还会将该用户添加到 sudo 组。

连接到虚拟机实例

通过使用 Google Cloud Console 并完成以下步骤,连接到实例。您作为用于访问虚拟机实例页面的用户连接到虚拟机。

  1. 在 Google Cloud 控制台中,转到虚拟机实例页面。

    转到“虚拟机实例”

  2. 在虚拟机实例列表中,点击要连接的实例所在行中的 SSH

    实例名称旁边的 SSH 按钮。

清理

为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。

  1. 在 Google Cloud 控制台中,前往虚拟机实例页面。

    转到“虚拟机实例”

  2. 点击您创建的实例名称。

  3. 在实例详细信息页面顶部,点击删除

后续步骤