Google-Cloud-Platform

GCP 控制台腳本自動將 VPS 遷移到更高層?

  • November 21, 2021

是否有gccloud將機器遷移到general-purpose的範例腳本compute-optimised?它是一個網路伺服器,所以我寧願新機器也保留 IP。停機 10-20 分鐘即可。

更改 VM 類型gcloud需要為項目設置預設區域和區域,停止 VM,更改類型:

# set defaults
gcloud compute project-info add-metadata \
 --metadata google-compute-default-region=us-east4,google-compute-default-zone=us-east4-c

# check it was set (see commonInstanceMetadata section)
gcloud compute project-info describe --project YOURPROJECTNAME

# reinit gcloud to enable new defaults
gcloud init

# change machine type
gcloud compute instances stop VMNAME

gcloud compute instances set-machine-type VMNAME --machine-type e2-highcpu-4

gcloud compute instances start VMNAME

注意:您需要靜態 IP 才能 100% 確定 IP 之後不會更改

引用自:https://serverfault.com/questions/1082212