本文說明如何查看現有虛擬機器 (VM) 執行個體的詳細資料。
查看 VM 詳細資料有助於瞭解其設定和狀態,例如附加的磁碟、建立時間戳記、機器類型和 VM ID。您可以使用 VM ID 參照 VM 的不變值。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
安裝 Google Cloud CLI。 安裝完成後,執行下列指令初始化 Google Cloud CLI:
gcloud init
如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
- Set a default region and zone.
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI。 安裝完成後,執行下列指令初始化 Google Cloud CLI:
gcloud init
如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。
必要的角色
如要取得查看 VM 詳細資料所需的權限,請要求管理員授予您 VM 或專案的 Compute 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1
) 身分與存取權管理角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。這個預先定義的角色具備
compute.instances.get
權限,可查看 VM 詳細資料。查看 VM 詳細資料
如要查看 VM 詳細資料,請選取下列任一選項:
主控台
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
在「VM instances」(VM 執行個體) 頁面中,您可以查看運算執行個體的下列資訊:
上一個清單包含「VM instances」(VM 執行個體) 頁面中顯示的預設欄。您可以按一下「資料欄顯示選項」
,變更每個 VM 顯示的資料欄。在「Name」(名稱) 欄中,按一下 VM 名稱,查看 VM 執行個體的其他詳細資料。
gcloud
如要查看 VM 的詳細資料,請使用
gcloud compute instances describe
指令。gcloud compute instances describe VM_NAME \ --zone=ZONE
更改下列內容:
VM_NAME
:VM 名稱。ZONE
:VM 所在的區域。
輸出結果會與下列內容相似:
canIpForward: false confidentialInstanceConfig: enableConfidentialCompute: false cpuPlatform: Intel Broadwell creationTimestamp: '2023-08-18T10:00:21.801-07:00' deletionProtection: false description: '' disks: - architecture: X86_64 autoDelete: true boot: true deviceName: example-vm diskSizeGb: '10' guestOsFeatures: - type: UEFI_COMPATIBLE - type: VIRTIO_SCSI_MULTIQUEUE - type: GVNIC - type: SEV_CAPABLE index: 0 interface: SCSI kind: compute#attachedDisk licenses: - https://www.googleapis.com/compute/v1/projects/debian-cloud/global/licenses/debian-11-bullseye mode: READ_WRITE source: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/disks/example-vm type: PERSISTENT displayDevice: enableDisplay: false fingerprint: CQp-QBEACqw= id: '6404261768674286922' keyRevocationActionType: NONE kind: compute#instance labelFingerprint: 42WmSpB8rSM= lastStartTimestamp: '2023-08-18T10:00:28.182-07:00' machineType: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/machineTypes/e2-medium metadata: fingerprint: lQ-dD2sMrMY= items: - key: enable-oslogin value: 'true' kind: compute#metadata name: example-vm networkInterfaces: - accessConfigs: - kind: compute#accessConfig name: External NAT natIP: 34.27.53.198 networkTier: PREMIUM type: ONE_TO_ONE_NAT fingerprint: QR3z6TgVFjg= kind: compute#networkInterface name: nic0 network: https://www.googleapis.com/compute/v1/projects/example-project/global/networks/default networkIP: 10.128.0.28 stackType: IPV4_ONLY subnetwork: https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/subnetworks/default reservationAffinity: consumeReservationType: ANY_RESERVATION scheduling: automaticRestart: true onHostMaintenance: MIGRATE preemptible: false provisioningModel: STANDARD selfLink: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances/example-vm serviceAccounts: - email: 790569220780-compute@developer.gserviceaccount.com scopes: - https://www.googleapis.com/auth/devstorage.read_only - https://www.googleapis.com/auth/logging.write - https://www.googleapis.com/auth/monitoring.write - https://www.googleapis.com/auth/servicecontrol - https://www.googleapis.com/auth/service.management.readonly - https://www.googleapis.com/auth/trace.append shieldedInstanceConfig: enableIntegrityMonitoring: true enableSecureBoot: false enableVtpm: true shieldedInstanceIntegrityPolicy: updateAutoLearnPolicy: true startRestricted: false status: RUNNING tags: fingerprint: 42WmSpB8rSM= zone: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a
REST
如要查看 VM 的詳細資料,請對
instances.get
方法發出GET
要求。GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME
更改下列內容:
PROJECT_ID
:VM 所在的專案 ID。ZONE
:VM 所在的區域。VM_NAME
:VM 名稱。
輸出結果會與下列內容相似:
{ "canIpForward": false, "confidentialInstanceConfig": { "enableConfidentialCompute": false }, "cpuPlatform": "Intel Broadwell", "creationTimestamp": "2023-08-18T10:00:21.801-07:00", "deletionProtection": false, "description": "", "disks": [ { "architecture": "X86_64", "autoDelete": true, "boot": true, "deviceName": "example-vm", "diskSizeGb": "10", "guestOsFeatures": [ { "type": "UEFI_COMPATIBLE" }, { "type": "VIRTIO_SCSI_MULTIQUEUE" }, { "type": "GVNIC" }, { "type": "SEV_CAPABLE" } ], "index": 0, "interface": "SCSI", "kind": "compute#attachedDisk", "licenses": [ "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/licenses/debian-11-bullseye" ], "mode": "READ_WRITE", "source": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/disks/example-vm", "type": "PERSISTENT" } ], "displayDevice": { "enableDisplay": false }, "fingerprint": "CQp-QBEACqw=", "id": "6404261768674286922", "keyRevocationActionType": "NONE", "kind": "compute#instance", "labelFingerprint": "42WmSpB8rSM=", "lastStartTimestamp": "2023-08-18T10:00:28.182-07:00", "machineType": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/machineTypes/e2-medium", "metadata": { "fingerprint": "lQ-dD2sMrMY=", "items": [ { "key": "enable-oslogin", "value": "true" } ], "kind": "compute#metadata" }, "name": "example-vm", "networkInterfaces": [ { "accessConfigs": [ { "kind": "compute#accessConfig", "name": "External NAT", "natIP": "34.27.53.198", "networkTier": "PREMIUM", "type": "ONE_TO_ONE_NAT" } ], "fingerprint": "QR3z6TgVFjg=", "kind": "compute#networkInterface", "name": "nic0", "network": "https://www.googleapis.com/compute/v1/projects/example-project/global/networks/default", "networkIP": "10.128.0.28", "stackType": "IPV4_ONLY", "subnetwork": "https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/subnetworks/default" } ], "reservationAffinity": { "consumeReservationType": "ANY_RESERVATION" }, "scheduling": { "automaticRestart": true, "onHostMaintenance": "MIGRATE", "preemptible": false, "provisioningModel": "STANDARD" }, "selfLink": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances/example-vm", "serviceAccounts": [ { "email": "790569220780-compute@developer.gserviceaccount.com", "scopes": [ "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring.write", "https://www.googleapis.com/auth/servicecontrol", "https://www.googleapis.com/auth/service.management.readonly", "https://www.googleapis.com/auth/trace.append" ] } ], "shieldedInstanceConfig": { "enableIntegrityMonitoring": true, "enableSecureBoot": false, "enableVtpm": true }, "shieldedInstanceIntegrityPolicy": { "updateAutoLearnPolicy": true }, "startRestricted": false, "status": "RUNNING", "tags": { "fingerprint": "42WmSpB8rSM=" }, "zone": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a" }
判斷執行個體的 CPU 和記憶體配置
分配給運算執行個體的 CPU 數量和記憶體大小,取決於執行個體使用的機器類型,例如:
c3-standard-22
:C3 是機器系列名稱,standard
是執行個體的記憶體配置類型,22
則是分配給執行個體的 vCPU 數量。一般而言,standard
機器類型會使用每個 vCPU 4 GB 記憶體的比例。因此,這個機器類型會有 88 GB 的 RAM。standard
、highmem
、highcpu
、ultamem
和megamem
機器類型的記憶體與 CPU 比率可能因各個機器系列而略有不同,因此請參閱機器系列頁面,瞭解各機器類型分配到的確切記憶體量。n2-custom-8-16384
:如果是自訂機器類型,機器類型的第一部分是機器系列,但 N1 機器類型除外,因為這類機器類型完全不包含機器系列。custom
後的第一個數字是 vCPU 數量,最後一個數字是分配給執行個體的記憶體容量 (以 MB 為單位)。
如要進一步瞭解機器類型,請參閱機器家族資源與比較指南。
後續步驟
瞭解如何重新命名 VM。
瞭解如何停止或啟動 VM。
瞭解如何暫停或繼續執行 VM。
進一步瞭解 VM 生命週期。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
-