Google Compute Engine:增加 memory/CPU 个实例

Google Compute Engine: increase memory/CPU of the instance

我想知道是否可以在 Google Compute Engine 上增加实例的 CPU/memory?我目前 运行 是一个小型实例 (g1-small),我想转移到 n1-highmem-2。

目前在 Google 云平台上无法实现。现在,您可以关闭您的实例,并创建一个新实例,并按照 .

中所述附加旧实例的永久磁盘。

更新 - 撰写本文时的 AS:

  • 一种方法是停止实例,进入编辑模式并将计算机配置为新配置。完成后,您需要开始,它将以最新配置恢复。
  • 最简单的方法是转到 VM 实例部分,您应该能够在 VM 列表的推荐部分看到 "increase perf"。您可以从那里 select 一键点击,它将使用 selected 配置重新启动。

现在有可能了:https://cloud.google.com/compute/docs/instances/changing-machine-type-of-stopped-instance

  1. Go to the VM Instances page.
  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.

调用此 Python 函数:

gcpChangeMachineType('project-id', 'us-west1-b', 'youInsanceName', 'custom-96-638976')

将其放入同一个 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())

其他可能的机器:

 - 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