在 Compute Engine 中创建 Linux 虚拟机实例
了解如何使用 Google Cloud 控制台在 Compute Engine 中创建 Linux 虚拟机 (VM) 实例。
如需在 Google Cloud 控制台中直接遵循有关此任务的分步指导,请点击操作演示:
准备工作
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Compute Instance Admin (v1), Compute Security Admin, OSPolicyAssignment Admin, Service Account User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Compute Instance Admin (v1), Compute Security Admin, OSPolicyAssignment Admin, Service Account User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
-
- 启用 Compute Engine API。
创建 Linux 虚拟机实例
- In the Google Cloud console, go to the Create an instance page.
- In the Boot disk section, click Change to begin configuring your boot disk.
- 在 Public images 标签页上,从操作系统列表中选择 Ubuntu。
- 从版本列表中选择 Ubuntu 24.04 LTS。
- 点击选择。
- 在防火墙部分,选择 允许 HTTP 流量。
- 如需创建虚拟机,请点击创建。
启动虚拟机实例需要一段时间,请稍等片刻。准备就绪后,虚拟机实例会列在虚拟机实例页面上,并带有绿色状态图标。
Compute Engine 向创建虚拟机实例的用户授予 roles/compute.instanceAdmin
角色。Compute Engine 还会将该用户添加到 sudo
组。
连接到虚拟机实例
通过使用 Google Cloud 控制台并完成以下步骤,连接到虚拟机实例。您作为用于访问虚拟机实例页面的用户连接到虚拟机实例。
- In the Google Cloud console, go to the VM instances page.
-
In the list of virtual machine instances, click SSH in the row of
the instance that you want to connect to.
清理
为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。
在 Google Cloud 控制台中,前往虚拟机实例页面。
选择您在本教程中创建的虚拟机实例所在的行。
点击
删除,然后点击删除进行确认。
后续步骤
- 完成教程以在新实例上设置基础网络服务器。
- 在 Google Cloud 控制台中完成入门教程。
- 了解如何使用 gcloud CLI 命令行工具和 API 创建和管理虚拟机实例。
- 详细了解 Compute Engine 上的可用 Linux 映像。
- 了解如何将文件转移到实例。