将Google实例移至不同的区域

时间:2017-10-27 18:45:58

标签: google-cloud-platform gcloud google-compute-engine

简单实例的问题在GCE中移动。

在gcloud中使用以下命令。

 gcloud compute instances move MY-VM \ --zone europe-west1 --destination-zone europe-west2

gcloud compute instances move MY-VM --zone europe-west1-b --destination-zone europe-west2-b

gcloud compute instances move MY-VM \ --destination-zone europe-west2-b

gcloud compute instances move MY-VM \ europe-west1-b --destination-zone europe-west2-b

Gcloud抛出了以上的后续错误;

ERROR: (gcloud.compute.instances.move) unrecognized arguments:
   --zone
  europe-west1-b

Google - 帮助文档:

NAME
    gcloud compute instances move - move an instance and its attached
        persistent disks between zones



SYNOPSIS
    gcloud compute instances move INSTANCE_NAME
        --destination-zone=DESTINATION_ZONE [--async] [--zone=ZONE]
        [GCLOUD_WIDE_FLAG ...]


DESCRIPTION
    gcloud compute instances move facilitates moving a Google Compute Engine
    virtual machine from one zone to another. Moving a virtual machine may
    incur downtime if the guest OS must be shutdown in order to quiesce disk
    volumes prior to snapshotting.

    For example, running:
        $ gcloud compute instances move example-instance-1 \ --zone us-central1-b --destination-zone us-central1-f



    will move the instance called example-instance-1 with its all attached
    persistent disks, currently running in us-central1-b, to us-central1-f. 

是我还是我失去了理智。

4 个答案:

答案 0 :(得分:0)

如果要在同一区域内移动实例,只需键入以下命令

即可

gcloud计算实例移动your_vm --destination-zone = zone_name

如果有帮助,请告诉我

答案 1 :(得分:0)

字符串'\ --zone'被解析为参数'--zone',带前导空格。命令没有这样的参数,只有'--zone'没有前导空格。这就是命令无法识别参数的原因。

答案 2 :(得分:0)

一些事情:

一个。语法在这里非常细致。我能够复制你得到的错误,错误与区域名称的有效性无关。

B中。似乎帮助页面中的示例中存在拼写错误。当我在区域之间来回移动VM时,这些变体对我有用。我使用自己的区域,因为我不想支付欧洲费率:

1:用一个反斜杠输入一行,就像文档说的那样(失败):

ingernet@merp:~> gcloud compute instances move MY-VM \ --zone us-west1-b --destination-zone us-west1-a
ERROR: (gcloud.compute.instances.move) unrecognized arguments:
   --zone
  us-west1-b

2:在一行中输入所有内容,没有反斜杠(成功):

ingernet@merp:~> gcloud compute instances move MY-VM --destination-zone us-west1-a --zone us-west1-b
Moving gce instance MY-VM...done. 

3:在单独的行上输入标志(成功,无论标志顺序如何):

ingernet@merp:~> gcloud compute instances move MY-VM \
> --zone us-west1-a --destination-zone us-west1-b
Moving gce instance MY-VM...done. 

注意第二个示例如何使用\字符来转义返回键,以便您可以将代码包装到另一行,以便易读。

无论输入命令的行数是多少,标志的顺序都无关紧要:

ingernet@merp:~> gcloud compute instances move MY-VM \
> --destination-zone us-west1-a --zone us-west1-b
Moving gce instance MY-VM...done.

我希望这会有所帮助。 GCP在很多方面都有所不同,但并非没有它的问题。

答案 3 :(得分:0)

更新:

问题是我试图改变实际的国家,所以这就是问题所在。试图从比利时搬到伦敦,唯一的办法就是使用我想移动的快照创建一个新实例。

你只能移动实例,即

europe-west1-b to europe-west1-c or west1-a etc 

希望这有帮助。