您可以通过替换许可参考或代码,在按需付费 (PAYG) 和自带订阅 (BYOS) 结算模式之间切换。如需详细了解许可代码以及如何确定允许的许可修改,请参阅许可变更和限制。
准备工作
-
如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 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.
将 PAYG 许可更改为 BYOS 许可
如需将按需付费许可替换为自带许可 (BYOS),请使用 Google Cloud CLI 或 Compute Engine API。
gcloud
如需将磁盘的许可替换为许可引用或代码,请使用
gcloud compute disks update
命令:gcloud compute disks update DISK_NAME \ --replace-license=PREVIOUS_LICENSE,NEW_LICENSE
替换以下内容:
REST
如需替换磁盘的许可,请将新许可添加到请求正文中,并省略之前的许可。调用以下
disks.update
v1 方法:PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{"name":"DISK_NAME", "licenses":["https://www.googleapis.com/compute/v1/NEW_LICENSE"]}'
替换以下内容:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-19。
[[["易于理解","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-08-19。"],[],[],null,["Linux\n\n*** ** * ** ***\n\nYou can switch between pay-as-you-go (PAYG) and bring your own subscription (BYOS)\nbilling models by replacing one license reference or code with another. Changing between BYOS and PAYG is supported for Red Hat Enterprise Linux (RHEL), RHEL for SAP, SUSE Linux Enterprise Server (SLES), and SLES for SAP.\nFor details on license codes and how to determine allowed license\nmodifications, see [License changes and restrictions](/compute/docs/licenses/license-changes-and-restrictions).\n\n\nBefore you begin\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n gcloud\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\nChange a BYOS license to a PAYG license\n\nTo replace a BYOS license with a PAYG license, use the Google Cloud CLI or the\nCompute Engine API. \n\ngcloud\n\nTo replace a disk's license with a license reference or code, use the\n[`gcloud compute disks update` command](/sdk/gcloud/reference/compute/disks/update): \n\n```\ngcloud compute disks update DISK_NAME \\\n --replace-license=PREVIOUS_LICENSE,NEW_LICENSE\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eDISK_NAME\u003c/var\u003e: the name of the disk to replace.\n- \u003cvar translate=\"no\"\u003ePREVIOUS_LICENSE\u003c/var\u003e: the previous [license reference](/compute/docs/images/os-details#license-references) being replaced, for example, `\"rhel-7-byos\"`, `\"rhel-8-byos\"`.\n- \u003cvar translate=\"no\"\u003eNEW_LICENSE\u003c/var\u003e: the new [license reference](/compute/docs/images/os-details#license-references), for example, `\"rhel-7-server\"`, `\"rhel-8-server\"`.\n\nREST\n\nTo replace a disk's license, add the new license to the request body and\nomit the previous license. Call the following\n[`disks.update` v1 method](/compute/docs/reference/rest/v1/disks/update): \n\n```\nPATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{\"name\":\"DISK_NAME\", \"licenses\":[\"https://www.googleapis.com/compute/v1/NEW_LICENSE\"]}'\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e: the name of the project\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone containing the VM\n- \u003cvar translate=\"no\"\u003eDISK_NAME\u003c/var\u003e: the name of the disk\n- \u003cvar translate=\"no\"\u003eNEW_LICENSE\u003c/var\u003e: the new [license reference](/compute/docs/images/os-details#license-references), for example, `\"rhel-6-byos\"`, `\"rhel-7-byos\"`, or [license code](/compute/docs/images/os-details#license-codes), for example, `\"4720191914037931587\"`, `\"1492188837615955530\"`."]] -