如要將單一用戶群 VM 移至其他節點或節點群組,可以手動啟動即時遷移。您也可以手動啟動即時遷移,將多租戶 VM 移至單一租戶。如要瞭解如何將 VM 移出單一用戶群,請參閱將 VM 移出單一用戶群。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Trusted Cloud by S3NS 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
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」。
API 頻率限制
手動即時遷移要求會歸類在「查詢」API 速率限制。
手動即時遷移 VM 至單一用戶群或單一用戶群內
如要手動將 VM 即時遷移至單一用戶群或單一用戶群內,請使用 gcloud CLI 或 REST。
如果 VM 的目的地是節點群組,Compute Engine 會選取群組中具有足夠 VM 空間,且備用容量最少的節點。
使用共用的單一用戶群節點群組時,無法在專案之間執行即時遷移。
這項工作需要的權限
如要執行這項工作,您必須具備以下權限:
-
VM 的
compute.instances.update
權限。
gcloud
如要手動將 VM 即時遷移至單一用戶群或單一用戶群內,請使用下列
gcloud compute instances update
指令:gcloud compute instances update VM_NAME \ ( --node=NODE \ --node-group=NODE_GROUP \ --node-affinity-file=NODE_AFFINITY_FILE )
更改下列內容:
VM_NAME
:要更新節點相依性標籤的 VM 名稱。
請替換下列其中一項:
NODE
:要將 VM 即時遷移至的節點名稱。NODE_GROUP
:要將 VM 即時遷移至的節點群組名稱。NODE_AFFINITY_FILE
:JSON 檔案的名稱,其中包含可排定此 VM 的節點設定。詳情請參閱「設定節點親和性標籤」。
REST
如要手動將 VM 即時遷移至單一用戶群或單一用戶群內,請使用下列
instances.update
方法:PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME { ... "scheduling": { "nodeAffinities": [ { "key": "NODE_AFFINITY_LABEL_KEY", "operator": "IN", "values": [ "[NODE_AFFINITY_LABEL_VALUE]" ] } ] } ... }
更改下列內容:
PROJECT_ID
:要更新節點相依性標籤的 VM 所在專案 ID。ZONE
:要更新節點親和性標籤的 VM 所在區域。VM_NAME
:要更新節點相依性標籤的 VM 名稱。NODE_AFFINITY_LABEL_KEY
:下列其中一個字串,用於指定是否要將 VM 即時遷移至節點群組或節點:VM 目的地 要指定的金鑰 節點群組 compute.googleapis.com/node-group-name
節點 compute.googleapis.com/node-name
NODE_AFFINITY_LABEL_VALUE
:要將 VM 即時遷移至的節點群組或節點名稱。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 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 (世界標準時間)。"],[[["Manual live migration can move sole-tenant VMs to a different node or node group, and multi-tenant VMs into sole-tenancy."],["Performing manual live migration requires `compute.instances.update` permissions on the VM."],["The gcloud CLI or REST can be used to manually live migrate VMs into or within sole-tenancy, using the `gcloud compute instances update` command or the `instances.update` method."],["When a node group is the destination, Compute Engine selects the node with sufficient space and the least spare capacity."],["Live migration between projects using shared sole-tenant node groups is not supported."]]],[]] -