在 Compute Engine 中建立 Linux VM 執行個體
瞭解如何使用 Google Cloud 控制台,在 Compute Engine 中建立 Linux 虛擬機器 (VM) 執行個體。
如要直接在 Google Cloud 控制台中,按照這項工作的逐步指南操作,請按一下「Guide me」(逐步引導):
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify 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.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify 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.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
- 啟用 Compute Engine API。
建立 Linux VM 執行個體
- 前往 Google Cloud 控制台的「Create an instance」(建立執行個體)頁面。
- 在「OS 和儲存空間」部分中,按一下「變更」,即可開始設定開機磁碟。
- 在「Public images」(公開映像檔) 分頁中,從「Operating system」(作業系統) 清單中選擇「Ubuntu」。
- 從「Version」(版本) 清單中選擇「Ubuntu 24.04 LTS」。
- 按一下「Select」(選取)。
- 在「Firewall」(防火牆) 區段中,選取「Allow HTTP traffic」(允許 HTTP 流量)。
- 按一下「Create」(建立),即可建立 VM。
VM 執行個體啟動需要一些時間。VM 執行個體準備就緒後,就會列在「VM instances」(VM 執行個體) 頁面中,並顯示綠色的狀態圖示。
Compute Engine 會將 roles/compute.instanceAdmin 角色授予建立 VM 執行個體的使用者。Compute Engine 也會將該使用者新增至 sudo 群組。
連線至 VM 執行個體
使用 Google Cloud 控制台連線至 VM 執行個體,並完成下列步驟。您會以存取 VM 執行個體頁面的使用者身分連線至 VM 執行個體。
- 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
-
在虛擬機器執行個體清單中,找到您要建立連線的執行個體,然後在該列中點選「SSH」SSH。

清除所用資源
為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
選取您在本教學課程中建立的 VM 執行個體所在的資料列。
依序點選「刪除」和「刪除」確認操作。
後續步驟
- 參閱教學課程內容,瞭解如何在新的執行個體上設定基本網路伺服器。
- 逐步完成 Google Cloud 控制台中的入門教學課程。
- 瞭解如何使用 gcloud CLI 指令列工具和 API 來建立及管理虛擬機器執行個體。
- 進一步瞭解適用於 Compute Engine 的 Linux 映像檔。
- 瞭解如何將檔案轉移至執行個體。