本文档介绍如何查看虚拟机 (VM) 实例的可见 CPU 核心数。
查看虚拟机的详细信息时,您可以验证该虚拟机是否具有默认的可见 CPU 核心数,或者是否自定义了此数量。减少虚拟机的可见 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
-
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
- Set a default region and zone.
在 Trusted Cloud 控制台中,前往虚拟机实例页面。
在名称列中,点击虚拟机的名称。
系统会打开虚拟机的详情页面,并且详细信息标签页处于选中状态。
在机器配置部分中,检查自定义可见核心数的值。如果未显示任何值,则表示虚拟机具有默认的可见 CPU 核心数。
VM_NAME
:虚拟机的名称。ZONE
:该虚拟机所在的可用区。PROJECT_ID
:虚拟机所在项目的 ID。ZONE
:该虚拟机所在的可用区。VM_NAME
:虚拟机的名称。
REST
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭据。
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
如需了解详情,请参阅 Trusted Cloud 身份验证文档中的使用 REST 时进行身份验证。
所需的角色
如需获得查看虚拟机详细信息的权限,请让管理员向您授予虚拟机或项目的 Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1
) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。此预定义角色可提供查看虚拟机的详细信息所需的
compute.instances.get
权限。查看虚拟机的可见 CPU 核心数
如需确定是否为虚拟机自定义了可见 CPU 核心数,请选择以下选项之一:
控制台
gcloud
如需查看虚拟机的详细信息,请使用
gcloud compute instances describe
命令。gcloud compute instances describe VM_NAME \ --zone=ZONE
替换以下内容:
如果自定义了虚拟机的可见 CPU 核心数,则输出包含
visibleCoreCount
字段,如下所示:advancedMachineFeatures: visibleCoreCount: VISIBLE_CORE_COUNT ...
如果输出不包含
visibleCoreCount
字段,则虚拟机具有默认的可见 CPU 核心数。REST
如需查看虚拟机的详细信息,请向
instances.get
方法发出GET
请求。GET https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME
替换以下内容:
如果自定义了虚拟机的可见 CPU 核心数,则输出包含
visibleCoreCount
字段,如下所示:{ ... "advancedMachineFeatures": { visibleCoreCount: VISIBLE_CORE_COUNT }, ... }
如果输出不包含
visibleCoreCount
字段,则虚拟机具有默认的可见 CPU 核心数。后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-06-18。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-06-18。"],[[["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."]]],[]] -