本文說明如何在現有的 Compute Engine 執行個體中停用正常關機。如要進一步瞭解正常關機,包括如何略過個別停止或刪除作業的正常關機程序,請參閱「正常關機總覽」。
如果您已在執行個體中啟用安全關機,可以停用這項功能,以便執行下列操作:
加快停止或刪除作業的速度,避免產生不必要的費用。
更新需要重新啟動的執行個體屬性。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 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」。
必要的角色
如要取得在 Compute 執行個體中停用正常關機所需的權限,請要求管理員授予您專案的 Compute 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。這個預先定義的角色具備
compute.instances.update
on the instance在執行個體中停用安全關機
您可以在不重新啟動執行個體的情況下,停用運算執行個體中的安全關機功能。不過,執行個體正在安全關機 (
PENDING_STOP
) 時,您無法停用安全關機。如要在執行個體中停用正常關機程序,請選取下列其中一個選項:
主控台
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
在「名稱」欄中,按一下執行個體名稱即可查看詳細資料。
執行個體的詳細資料頁面隨即開啟,並選取「詳細資料」分頁標籤。
按一下「Edit」(編輯)
。在「管理」部分,取消勾選「按適當流程關閉 VM」核取方塊。
按一下 [儲存]。
gcloud
如要在執行個體中停用正常關機,請使用
gcloud beta compute instances update
指令搭配--no-graceful-shutdown
旗標:gcloud beta compute instances update INSTANCE_NAME \ --no-graceful-shutdown \ --zone=ZONE
更改下列內容:
INSTANCE_NAME
:執行個體的名稱。ZONE
:執行個體所在的區域。
REST
建立空白的 JSON 檔案。
如要查看現有執行個體的屬性,請對 beta
instances.get
方法發出GET
要求:GET https://compute.s3nsapis.fr/compute/beta/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME
更改下列內容:
PROJECT_ID
:執行個體所在專案的 ID。ZONE
:執行個體所在的區域。INSTANCE_NAME
:現有執行個體的名稱。
在您於上一個步驟中建立的空白 JSON 檔案中,執行下列操作:
輸入
GET
要求輸出內容中的執行個體屬性。找出
gracefulShutdown.enabled
欄位,然後將其值變更為false
:{ ... "scheduling": { ... "gracefulShutdown": { "enabled": false } }, ... }
如要更新執行個體,請對 Beta 版
instances.update
方法發出PUT
要求。包含下列項目:在要求網址中加入
mostDisruptiveAllowedAction
查詢參數。在要求主體中,納入您在先前步驟中建立及更新的 JSON 檔案中的執行個體屬性。
更新執行個體的
PUT
要求類似於下列要求:PUT https://compute.s3nsapis.fr/compute/beta/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME?mostDisruptiveAllowedAction=ALLOWED_ACTION { ... "scheduling": { ... "gracefulShutdown": { "enabled": false } }, ... }
將
ALLOWED_ACTION
替換為下列其中一個值:NO_EFFECT
:這項要求會檢查更新要求是否有效,以及資源是否可用,但不會更新執行個體。REFRESH
:如果修改後的執行個體屬性不需要重新啟動執行個體,Compute Engine 就會更新執行個體。
如要進一步瞭解如何更新執行個體的屬性,請參閱「更新執行個體屬性」。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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"]],["上次更新時間:2025-08-19 (世界標準時間)。"],[[["This document provides instructions on how to disable graceful shutdown for Compute Engine instances, which is a feature that delays the stop or delete process."],["Disabling graceful shutdown can speed up stop or delete operations and is required before updating certain instance properties that require a restart."],["The process of disabling graceful shutdown can be done without needing to restart the instance, and can be accomplished through the Google Cloud console, `gcloud` command-line tool, or REST API."],["To disable graceful shutdown, users need the `compute.instances.update` permission, which is typically granted through the Compute Instance Admin (v1) IAM role."],["Pre-GA products or features, like the ones discussed within, are \"as is\" and may feature limited support, along with terms specified within the \"Pre-GA Offerings Terms\"."]]],[]] -