How to change machine type of GCE instance?

后端 未结 3 1719
遇见更好的自我
遇见更好的自我 2020-12-03 18:25

As there isn\'t any direct option to change machine type and i have to create a new instance. What are the steps to do so that the configuration/software that I had installe

相关标签:
3条回答
  • 2020-12-03 18:41

    You can't change the instance type of a VM on-the-fly. To upgrade or downgrade the VM type, you should do the following:

    1. VERY IMPORTANT: make sure to not delete VM's boot disk while shutting down the VM; see this answer for details

    2. shut down the VM cleanly while taking into account the information from step #1 if you're doing this via Google Developers Console or via gcloud on the CLI by using the --keep-disks option or by having already set those disks to not auto-delete as described in this answer:

      gcloud compute instances delete VM \
           --keep-disks=all \
           --project $PROJECT
           --zone $ZONE
      

      Note that --keep-disks accepts any of the following options: boot, data, or all. In your case, you want at least boot but if you've attached other disks, you want to specify all. See the docs for more info.

    3. create a new VM and choose a larger/smaller instance type: again, this can be done via Google Developers Console or via gcloud on the CLI and instead of creating a new boot disk, select the boot disk from the original VM, e.g.,

      gcloud compute instances create $VM \
           --disk name=${DISK_NAME},boot=yes \
           --machine-type ${MACHINE_TYPE} \
           --project $PROJECT
           --zone $ZONE
      

      See the docs for more info.

    0 讨论(0)
  • 2020-12-03 18:59

    1) Delete the instance that you want to upgrade by keeping its boot disk.

      gcloud compute instances delete <instance-name> --keep-disks boot
    

    2) Now create image from this boot disk

      gcloud compute images create <any-image-name> --source-disk <instance-name>
    

    3) Now Check Images list

     gcloud compute images list
    

    4) Now Create new instance from developer console or using gcloud compute

    and select your image as boot disk.

    5) Done.

    Here is the link.

    0 讨论(0)
  • 2020-12-03 19:01

    As of today, this ability can be seen on Google Compute Engine. You will need to stop the instance and then edit the instance.. which will give you a drop-down menu for the Machine Types

    https://cloud.google.com/sdk/gcloud/reference/alpha/compute/instances/set-machine-type?hl=en

    0 讨论(0)
提交回复
热议问题