我想知道是否可以增加Google Compute Engine实例的CPU/内存?我目前正在运行一个小型实例(g1-small),我想要迁移到n1-highmem-2。
我想知道是否可以增加Google Compute Engine实例的CPU/内存?我目前正在运行一个小型实例(g1-small),我想要迁移到n1-highmem-2。
现在可以实现: https://cloud.google.com/compute/docs/instances/changing-machine-type-of-stopped-instance
- 进入VM实例页面。
- 在名称列中,单击要更改机器类型的实例的名称。
- 如果您尚未停止实例,请单击停止按钮停止它。
- 实例停止后(可能需要几分钟),请单击页面顶部的编辑按钮。
目前在Google Cloud Platform上还无法实现此功能。您可以关闭实例,并按照此StackOverflow答案所述,创建一个附加旧实例持久磁盘的新实例。
更新-截至撰写本文时:
调用这个Python函数:
gcpChangeMachineType('project-id', 'us-west1-b', 'youInsanceName', 'custom-96-638976')
def gcpChangeMachineType(project, zone, instance_name, newType):
import googleapiclient.discovery
compute = googleapiclient.discovery.build('compute', 'v1')
instances = compute.instances()
instances.stop(project=project, zone=zone, instance=instance_name).execute()
instances.setMachineType(project=project, zone=zone, instance=instance_name, body={'machineType':'zones/{zone}/machineTypes/{newType}'.format(zone=zone, newType=newType)}).execute()
instances.start(project=project ,zone=zone, instance=instance_name).execute()
return(instances.get(project=project ,zone=zone, instance=instance_name).execute())
其他可能的机器:
- f1-micro # 1cpu 640MB
- n1-standard-1
- custom-1-6656
- custom-2-13312
- custom-4-26624
- custom-10-66560
- custom-12-79872
- custom-96-638976