Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Linux
Windows
Per spostare le VM single-tenant in un altro nodo o gruppo di nodi, puoi avviare manualmente una migrazione live. Puoi anche avviare manualmente una migrazione live per passare una VM multi-tenant alla modalità single-tenancy. Per informazioni su come rimuovere una VM dalla single-tenancy, consulta Rimuovere una VM dalla single-tenancy.
Prima di iniziare
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione è
il processo mediante il quale la tua identità viene verificata per l'accesso a servizi e API di Google Cloud .
Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su
Compute Engine selezionando una delle seguenti opzioni:
Select the tab for how you plan to use the samples on this page:
gcloud
Install the Google Cloud CLI.
After installation,
initialize the Google Cloud CLI by running the following command:
Esegui la migrazione live manuale delle VM trasferendole o mantenendole su nodi single-tenant
Per eseguire manualmente la migrazione live delle VM trasferendole o mantenendole su nodi single-tenant, utilizza gcloud CLI o REST.
Se la destinazione della VM è un gruppo di nodi, Compute Engine seleziona il nodo all'interno del gruppo che dispone di spazio sufficiente per la VM e della minore quantità di capacità di riserva.
Non puoi eseguire una migrazione live tra progetti mentre utilizzi gruppi di nodi condivisi single-tenant.
Autorizzazioni richieste per questa attività
Per eseguire questa attività, devi disporre delle seguenti autorizzazioni:
compute.instances.update sulla VM.
gcloud
Per eseguire manualmente la migrazione live delle VM trasferendole o mantenendole su nodi single-tenant, utilizza il seguente comando gcloud compute instances update:
VM_NAME: il nome della VM per cui aggiornare le etichette di affinità dei nodi.
Sostituisci esattamente uno dei seguenti elementi:
NODE: il nome del nodo a cui eseguire la migrazione live della VM.
NODE_GROUP: il nome del gruppo di nodi a cui eseguire la migrazione live della VM.
NODE_AFFINITY_FILE: il nome di un file JSON contenente una configurazione dei nodi su cui è possibile pianificare questa VM.
Per saperne di più, consulta Configura le etichette di affinità dei nodi.
REST
Per eseguire manualmente la migrazione live delle VM trasferendole o mantenendole su nodi single-tenant, utilizza il seguente metodo instances.update:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eManual live migration can move sole-tenant VMs to a different node or node group, and multi-tenant VMs into sole-tenancy.\u003c/p\u003e\n"],["\u003cp\u003ePerforming manual live migration requires \u003ccode\u003ecompute.instances.update\u003c/code\u003e permissions on the VM.\u003c/p\u003e\n"],["\u003cp\u003eThe gcloud CLI or REST can be used to manually live migrate VMs into or within sole-tenancy, using the \u003ccode\u003egcloud compute instances update\u003c/code\u003e command or the \u003ccode\u003einstances.update\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eWhen a node group is the destination, Compute Engine selects the node with sufficient space and the least spare capacity.\u003c/p\u003e\n"],["\u003cp\u003eLive migration between projects using shared sole-tenant node groups is not supported.\u003c/p\u003e\n"]]],[],null,["# Manually live migrate VMs\n\nLinux Windows\n\n*** ** * ** ***\n\nTo move sole-tenant VMs to a different node or node group, you can manually\ninitiate a live migration. You can also manually initiate a live migration to\nmove a multi-tenant VM into sole-tenancy. For information about how to move a VM\nout of sole-tenancy, see [Move a VM out of sole-tenancy](/compute/docs/nodes/updating-vm-tenancy#moving_a_vm_out_of_sole-tenancy).\n\nBefore you begin\n----------------\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 ### gcloud\n\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\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nAPI rate limits\n---------------\n\nManual live migration requests are categorized in the **Queries** [API rate\nlimit](/compute/docs/api-rate-limits).\n\nManually live migrate VMs into or within sole-tenancy\n-----------------------------------------------------\n\nTo manually live migrate VMs into or within sole-tenancy, use the\ngcloud CLI or REST.\n\nIf the destination of the VM is a node group, Compute Engine selects\nthe node within the group that has both enough space for the VM and the least\namount of spare capacity.\n\nYou cannot perform live migration between projects while using shared\nsole-tenant node groups.\n\n#### Permissions required for this task\n\nTo perform this task, you must have the following [permissions](/iam/docs/overview#permissions):\n\n- `compute.instances.update` permissions on the VM.\n\n### gcloud\n\nTo manually live migrate VMs into or within sole-tenancy, use the following\n[`gcloud compute instances update` command](/sdk/gcloud/reference/compute/instances/update): \n\n```\ngcloud compute instances update VM_NAME \\\n ( --node=NODE \\\n --node-group=NODE_GROUP \\\n --node-affinity-file=NODE_AFFINITY_FILE )\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the VM to update the node affinity labels for.\n\nReplace exactly one of the following:\n\n- \u003cvar translate=\"no\"\u003eNODE\u003c/var\u003e: the name of the node to live migrate the VM\n to.\n\n- \u003cvar translate=\"no\"\u003eNODE_GROUP\u003c/var\u003e: the name of the node group to live\n migrate the VM to.\n\n- \u003cvar translate=\"no\"\u003eNODE_AFFINITY_FILE\u003c/var\u003e: the name of a JSON file\n containing a configuration of nodes on which this VM could be scheduled.\n For more information, see [Configure node affinity\n labels](/compute/docs/nodes/provisioning-sole-tenant-vms#configure_node_affinity_labels).\n\n### REST\n\nTo manually live migrate VMs into or within sole-tenancy, use the following\n[`instances.update` method](/compute/docs/reference/rest/v1/instances/update): \n\n```\nPUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME\n\n{\n ...\n \"scheduling\": {\n \"nodeAffinities\": [\n {\n \"key\": \"NODE_AFFINITY_LABEL_KEY\",\n \"operator\": \"IN\",\n \"values\": [\n \"[NODE_AFFINITY_LABEL_VALUE]\"\n ]\n }\n ]\n }\n ...\n}\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of the project that has the VM\n to update the node affinity labels for.\n\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone of the VM to update the node\n affinity labels for.\n\n- \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the VM to update the node\n affinity labels for.\n\n- \u003cvar translate=\"no\"\u003eNODE_AFFINITY_LABEL_KEY\u003c/var\u003e: one of the following\n strings that specifies whether to live migrate the VM to a node group or\n node:\n\n- \u003cvar translate=\"no\"\u003eNODE_AFFINITY_LABEL_VALUE\u003c/var\u003e: the name of the node\n group or node to live migrate the VM to.\n\nWhat's next\n-----------\n\n- [Learn how to move a VM out of sole-tenancy](/compute/docs/nodes/updating-vm-tenancy#moving_a_vm_out_of_sole-tenancy)"]]