简体   繁体   English

Google Compute Engine:增加实例的内存/CPU

[英]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

  1. Go to the VM Instances page .转至VM 实例页面
  2. In the Name column, click the name of the instance that you want to change the machine type for.名称列中,单击要为其更改机器类型的实例的名称。
  3. Click the Stop button to stop the instance, if you have not stopped it yet.如果您尚未停止实例,请单击停止按钮以停止该实例。
  4. 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:

  • One way is to stop the instance, get to edit mode and configure machine to new configuration.一种方法是停止实例,进入编辑模式并将机器配置为新配置。 Once done, you would need to start and it will come back up with latest config.完成后,您需要启动,它将以最新的配置返回。
  • The easiest way is to go to VM instances section and you should be able to see "increase perf" in recommendation section of the VM listings.最简单的方法是转到 VM 实例部分,您应该能够在 VM 列表的推荐部分看到“提高性能”。 You can select from there itself with one click and it will be restarted with the selected config.您可以一键从那里进行选择,它将使用选定的配置重新启动。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM