本文說明如何查看虛擬機器 (VM) 執行個體可見的 CPU 核心數量。
查看 VM 詳細資料時,您可以確認 VM 是否具有預設可見 CPU 核心數,或這個數字是否已自訂。減少 VM 可見的 CPU 核心數量,有助於降低授權費用,同時不會降低 Persistent Disk 的效能限制。不過,減少可見的 CPU 核心數可能會影響網路效能。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Trusted Cloud by S3NS 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
- Set a default region and zone.
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
詳情請參閱 Trusted Cloud 驗證說明文件中的「Authenticate for using REST」。
必要的角色
如要取得查看 VM 詳細資料所需的權限,請要求管理員授予您 VM 或專案的 Compute 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1
) 身分與存取權管理角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。這個預先定義的角色具備
compute.instances.get
權限,可查看 VM 詳細資料。查看 VM 可見的 CPU 核心數量
如要判斷 VM 的可見 CPU 核心數量是否經過自訂,請選取下列其中一個選項:
主控台
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
在「Name」(名稱) 欄中,按一下 VM 名稱。
系統會開啟 VM 的詳細資料頁面,並選取「詳細資料」分頁標籤。
在「機器設定」專區中,檢查「自訂可見核心」的值。如果沒有顯示任何值,表示 VM 具有預設數量的可見 CPU 核心。
gcloud
如要查看 VM 的詳細資料,請使用
gcloud compute instances describe
指令。gcloud compute instances describe VM_NAME \ --zone=ZONE
更改下列內容:
VM_NAME
:VM 名稱。ZONE
:VM 所在的區域。
如果 VM 的可見 CPU 核心數量經過自訂,輸出內容會包含
visibleCoreCount
欄位,如下所示:advancedMachineFeatures: visibleCoreCount: VISIBLE_CORE_COUNT ...
如果輸出內容不含
visibleCoreCount
欄位,表示 VM 具有預設數量的可見 CPU 核心。REST
如要查看 VM 的詳細資料,請對
instances.get
方法發出GET
要求。GET https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME
更改下列內容:
PROJECT_ID
:VM 所在的專案 ID。ZONE
:VM 所在的區域。VM_NAME
:VM 名稱。
如果 VM 的可見 CPU 核心數量經過自訂,輸出內容會包含
visibleCoreCount
欄位,如下所示:{ ... "advancedMachineFeatures": { visibleCoreCount: VISIBLE_CORE_COUNT }, ... }
如果輸出內容不含
visibleCoreCount
欄位,表示 VM 具有預設數量的可見 CPU 核心。後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-08 (世界標準時間)。"],[[["This document provides instructions on how to check if a virtual machine (VM) has the default number of visible CPU cores or if it has been customized."],["Reducing the number of visible CPU cores can help decrease licensing costs, but it might impact network performance and overall VM performance."],["You can view the number of visible CPU cores through the Google Cloud console, by using the `gcloud compute instances describe` command, or by making a `GET` request to the `instances.get` method."],["If the `visibleCoreCount` field is present in the output, the VM has a customized number of visible CPU cores; otherwise, it has the default number."],["To view the details of the VM, the required permission is `compute.instances.get`, granted by the `Compute Instance Admin (v1)` role."]]],[]] -