[英]Google Compute Engine: increase memory/CPU of the instance
I would like to know if its possible to increase the CPU/memory of the instance on Google Compute Engine?我想知道是否可以在 Google Compute Engine 上增加实例的 CPU/内存? I am currently running a small instance (g1-small) and I would like to move to n1-highmem-2.
我目前正在运行一个小实例 (g1-small),我想转移到 n1-highmem-2。
Now it's possible: https://cloud.google.com/compute/docs/instances/changing-machine-type-of-stopped-instance现在有可能: https : //cloud.google.com/compute/docs/instances/changed-machine-type-of-stopped-instance
- Go to the VM Instances page .
转至VM 实例页面。
- In the Name column, click the name of the instance that you want to change the machine type for.
在名称列中,单击要为其更改机器类型的实例的名称。
- Click the Stop button to stop the instance, if you have not stopped it yet.
如果您尚未停止实例,请单击停止按钮以停止该实例。
- After the instance stops (this may take couple minutes), click the Edit button at the top of the page.
实例停止后(这可能需要几分钟),单击页面顶部的编辑按钮。
This is not currently possible on Google Cloud Platform.这在 Google Cloud Platform 上目前是不可能的。 For now, you can shut down your instance, and create a new instance with the persistent disk of the older instance attached as described in this StackOverflow answer .
现在,您可以关闭您的实例,然后创建一个新实例,并按照StackOverflow answer 中的描述附加旧实例的永久性磁盘。
Update- AS of the time of writing:更新-撰写本文时的AS:
Call this Python function:调用这个 Python 函数:
gcpChangeMachineType('project-id', 'us-west1-b', 'youInsanceName', 'custom-96-638976')
Put this in the same Python File:把它放在同一个 Python 文件中:
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())
Other possibles machines:其他可能的机器:
- 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.