有关将 Google 计算 VM 映像正确保存到 Google 存储桶的建议?

Advice on properly saving Google Compute VM image to Google bucket?

我有一个使用 Google Compute 设置的 Ubuntu VM,因为它非常好,我正在尝试创建此映像的副本并将其存档,因此我可以使用它创建 VM 实例未来。但是,我遇到了随机的命令行错误,所以我将列出我执行的所有步骤,看看是否有明显错误。

首先,VM,我用它创建的映像,image-1,以及用来尝试存储它的 Google 存储桶都可以看到 here

我按照 step 1 in creating an image, step 2 in creating a storage area that Google can store large objects like VM images for me, step 3 in installing Google Cloud SDK on my local computer to run the necessary commands, and followed step 4 中的命令 运行。

宁运行后

gcloud compute images export --destination-uri gs://bucket_address --image image-1

我收到一条很长的日志,告诉我发生了错误。

日志:

Created [https://cloudbuild.googleapis.com/v1/projects/bayes-230019/builds/015e4129-5407-48cd-8fb5-0b0803406a0f].
Logs are available at [https://console.cloud.google.com/gcr/builds/015e4129-5407-48cd-8fb5-0b0803406a0f?project=297462970761].
[Daisy] Running workflow "image-export" (id=2d3br)
[image-export]: 2019-03-21T18:05:51Z Validating workflow
[image-export]: 2019-03-21T18:05:51Z Validating step "setup-disks"
[image-export]: 2019-03-21T18:05:51Z Validating step "image-export-export-disk"
[image-export.image-export-export-disk]: 2019-03-21T18:05:51Z Validating step "setup-disks"
[image-export.image-export-export-disk]: 2019-03-21T18:05:51Z Validating step "run-image-export-export-disk"
[image-export.image-export-export-disk]: 2019-03-21T18:05:52Z Validating step "wait-for-inst-image-export-export-disk"
[image-export.image-export-export-disk]: 2019-03-21T18:05:52Z Validating step "copy-image-object"
[image-export.image-export-export-disk]: 2019-03-21T18:05:52Z Validating step "delete-inst"
[image-export]: 2019-03-21T18:05:52Z Validation Complete
[image-export]: 2019-03-21T18:05:52Z Workflow Project: bayes-230019
[image-export]: 2019-03-21T18:05:52Z Workflow Zone: us-east4-c
[image-export]: 2019-03-21T18:05:52Z Workflow GCSPath: gs://bayes-230019-daisy-bkt/
[image-export]: 2019-03-21T18:05:52Z Daisy scratch path: https://console.cloud.google.com/storage/browser/bayes-230019-daisy-bkt/daisy-image-export-20190321-18:05:50-2d3br
[image-export]: 2019-03-21T18:05:52Z Uploading sources
[image-export]: 2019-03-21T18:05:52Z Running workflow
[image-export]: 2019-03-21T18:05:52Z Running step "setup-disks" (CreateDisks)
[image-export.setup-disks]: 2019-03-21T18:05:52Z CreateDisks: Creating disk "disk-image-export-image-export-2d3br".
[image-export]: 2019-03-21T18:06:37Z Step "setup-disks" (CreateDisks) successfully finished.
[image-export]: 2019-03-21T18:06:37Z Running step "image-export-export-disk" (IncludeWorkflow)
[image-export.image-export-export-disk]: 2019-03-21T18:06:37Z Running step "setup-disks" (CreateDisks)
[image-export.image-export-export-disk.setup-disks]: 2019-03-21T18:06:37Z CreateDisks: Creating disk "disk-image-export-export-disk-image-export-image-export--2d3br".
[image-export]: 2019-03-21T18:06:37Z Error running workflow: step "image-export-export-disk" run error: step "setup-disks" run error: googleapi: Error 403: Quota 'SSD_TOTAL_GB' exceeded. Limit: 100.0 in region us-east4., quotaExceeded
[image-export]: 2019-03-21T18:06:37Z Workflow "image-export" cleaning up (this may take up to 2 minutes).
[Daisy] Errors in one or more workflows:
  image-export: step "image-export-export-disk" run error: step "setup-disks" run error: googleapi: Error 403: Quota 'SSD_TOTAL_GB' exceeded. Limit: 100.0 in region us-east4., quotaExceeded
ERROR
ERROR: build step 0 "gcr.io/compute-image-tools/daisy:release" failed: exit status 1
ERROR: (gcloud.compute.images.export) build 015e4129-5407-48cd-8fb5-0b0803406a0f completed with status "FAILURE"

它提到了磁盘大小错误,但我的图像只有 31 Gb,它说我位于 us-east4 区域的存储桶超过了 100Gb 配额?我做错了什么?

编辑

按照建议升级我的帐户,我这样做了,现在代码继续进行,但最后我得到另一个奇怪的错误。

 image-export: step "image-export-export-disk" run error: step "copy-image-object" run error: error copying from gs://bayes-230019-daisy-bkt/daisy-image-export-20190321-20:14:58-mdxb2/outs/image-export-export-disk.tar.gz to gs://ml_vm_bucket: storage: object name is empty

新日志:

Created [https://cloudbuild.googleapis.com/v1/projects/bayes-230019/builds/02d7af72-12a4-4950-9bc6-153aabeef788].
Logs are available at [https://console.cloud.google.com/gcr/builds/02d7af72-12a4-4950-9bc6-153aabeef788?project=297462970761].
[Daisy] Running workflow "image-export" (id=mdxb2)
[image-export]: 2019-03-21T20:14:58Z Validating workflow
[image-export]: 2019-03-21T20:14:58Z Validating step "setup-disks"
[image-export]: 2019-03-21T20:14:58Z Validating step "image-export-export-disk"
[image-export.image-export-export-disk]: 2019-03-21T20:14:58Z Validating step "setup-disks"
[image-export.image-export-export-disk]: 2019-03-21T20:14:58Z Validating step "run-image-export-export-disk"
[image-export.image-export-export-disk]: 2019-03-21T20:14:59Z Validating step "wait-for-inst-image-export-export-disk"
[image-export.image-export-export-disk]: 2019-03-21T20:14:59Z Validating step "delete-inst"
[image-export.image-export-export-disk]: 2019-03-21T20:14:59Z Validating step "copy-image-object"
[image-export]: 2019-03-21T20:14:59Z Validation Complete
[image-export]: 2019-03-21T20:14:59Z Workflow Project: bayes-230019
[image-export]: 2019-03-21T20:14:59Z Workflow Zone: us-east4-c
[image-export]: 2019-03-21T20:14:59Z Workflow GCSPath: gs://bayes-230019-daisy-bkt/
[image-export]: 2019-03-21T20:14:59Z Daisy scratch path: https://console.cloud.google.com/storage/browser/bayes-230019-daisy-bkt/daisy-image-export-20190321-20:14:58-mdxb2
[image-export]: 2019-03-21T20:14:59Z Uploading sources
[image-export]: 2019-03-21T20:15:00Z Running workflow
[image-export]: 2019-03-21T20:15:00Z Running step "setup-disks" (CreateDisks)
[image-export.setup-disks]: 2019-03-21T20:15:00Z CreateDisks: Creating disk "disk-image-export-image-export-mdxb2".
[image-export]: 2019-03-21T20:15:43Z Step "setup-disks" (CreateDisks) successfully finished.
[image-export]: 2019-03-21T20:15:43Z Running step "image-export-export-disk" (IncludeWorkflow)
[image-export.image-export-export-disk]: 2019-03-21T20:15:43Z Running step "setup-disks" (CreateDisks)
[image-export.image-export-export-disk.setup-disks]: 2019-03-21T20:15:43Z CreateDisks: Creating disk "disk-image-export-export-disk-image-export-image-export--mdxb2".
[image-export.image-export-export-disk]: 2019-03-21T20:16:02Z Step "setup-disks" (CreateDisks) successfully finished.
[image-export.image-export-export-disk]: 2019-03-21T20:16:02Z Running step "run-image-export-export-disk" (CreateInstances)
[image-export.image-export-export-disk.run-image-export-export-disk]: 2019-03-21T20:16:02Z CreateInstances: Creating instance "inst-image-export-export-disk-image-export-image-export--mdxb2".
[image-export.image-export-export-disk]: 2019-03-21T20:16:11Z Step "run-image-export-export-disk" (CreateInstances) successfully finished.
[image-export.image-export-export-disk]: 2019-03-21T20:16:11Z Running step "wait-for-inst-image-export-export-disk" (WaitForInstancesSignal)
[image-export.image-export-export-disk.run-image-export-export-disk]: 2019-03-21T20:16:11Z CreateInstances: Streaming instance "inst-image-export-export-disk-image-export-image-export--mdxb2" serial port 1 output to https://storage.cloud.google.com/bayes-230019-daisy-bkt/daisy-image-export-20190321-20:14:58-mdxb2/logs/inst-image-export-export-disk-image-export-image-export--mdxb2-serial-port1.log
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:16:11Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": watching serial port 1, SuccessMatch: "ExportSuccess", FailureMatch: "ExportFailed:", StatusMatch: "GCEExport:".
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:16:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Running export tool."
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:16:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Disk /dev/sdb is 31 GiB, compressed size will most likely be much smaller."
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:16:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Exporting disk to gs://bayes-230019-daisy-bkt/daisy-image-export-20190321-20:14:58-mdxb2/outs/image-export-export-disk.tar.gz."
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:16:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Beginning copy..."
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:16:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 504 MiB of 31 GiB (101 MiB/sec), total uploaded size: 76 MiB (15 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:17:12Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 3.5 GiB of 31 GiB (68 MiB/sec), total uploaded size: 1.5 GiB (32 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:17:52Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 6.5 GiB of 31 GiB (69 MiB/sec), total uploaded size: 2.9 GiB (32 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:18:42Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 9.5 GiB of 31 GiB (68 MiB/sec), total uploaded size: 4.2 GiB (31 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:19:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 12 GiB of 31 GiB (54 MiB/sec), total uploaded size: 5.8 GiB (37 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:20:12Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 15 GiB of 31 GiB (65 MiB/sec), total uploaded size: 7.4 GiB (35 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:20:52Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 19 GiB of 31 GiB (102 MiB/sec), total uploaded size: 8.5 GiB (25 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:21:42Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 23 GiB of 31 GiB (93 MiB/sec), total uploaded size: 9.6 GiB (26 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:22:22Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Read 28 GiB of 31 GiB (95 MiB/sec), total uploaded size: 11 GiB (25 MiB/sec)"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:23:02Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": StatusMatch found: "GCEExport: Finished export in 6m43.907834062s"
[image-export.image-export-export-disk.wait-for-inst-image-export-export-disk]: 2019-03-21T20:23:02Z WaitForInstancesSignal: Instance "inst-image-export-export-disk-image-export-image-export--mdxb2": SuccessMatch found "ExportSuccess"
[image-export.image-export-export-disk]: 2019-03-21T20:23:02Z Step "wait-for-inst-image-export-export-disk" (WaitForInstancesSignal) successfully finished.
[image-export.image-export-export-disk]: 2019-03-21T20:23:02Z Running step "copy-image-object" (CopyGCSObjects)
[image-export.image-export-export-disk]: 2019-03-21T20:23:02Z Running step "delete-inst" (DeleteResources)
[image-export.image-export-export-disk.delete-inst]: 2019-03-21T20:23:02Z DeleteResources: Deleting instance "inst-image-export-export-disk".
[image-export]: 2019-03-21T20:23:02Z Error running workflow: step "image-export-export-disk" run error: step "copy-image-object" run error: error copying from gs://bayes-230019-daisy-bkt/daisy-image-export-20190321-20:14:58-mdxb2/outs/image-export-export-disk.tar.gz to gs://ml_vm_bucket: storage: object name is empty
[image-export]: 2019-03-21T20:23:02Z Workflow "image-export" cleaning up (this may take up to 2 minutes).
[Daisy] Errors in one or more workflows:
  image-export: step "image-export-export-disk" run error: step "copy-image-object" run error: error copying from gs://bayes-230019-daisy-bkt/daisy-image-export-20190321-20:14:58-mdxb2/outs/image-export-export-disk.tar.gz to gs://ml_vm_bucket: storage: object name is empty
ERROR
ERROR: build step 0 "gcr.io/compute-image-tools/daisy:release" failed: exit status 1
ERROR: (gcloud.compute.images.export) build 02d7af72-12a4-4950-9bc6-153aabeef788 completed with status "FAILURE"

您处于免费层级。要增加配额,您需要升级到付费帐户。

在幕后 Google 为工作流程分配 SSD 磁盘 space。此磁盘 space 是临时的,因此不会对您的帐单产生太大影响,但免费层帐户无法为工作流分配足够的 space。

如果您尝试将 vm 映像从一个 GCP 帐户导出到另一个 GCP 帐户,您可以使用以下步骤:

  1. 激活新帐户计算引擎API,创建(任何)VM,创建其映像,删除 VM,删除映像

  2. 转到新帐户的 IAM 并找到名为:@cloudservices.gserviceaccount.com

    的 SA
  3. auth with old org/project_id with gcloud and 运行 this:

    gcloud 项目 add-iam-policy-binding
    --member serviceAccount:@cloudservices.gserviceaccount.com --role roles/compute.imageUser

    gcloud 项目 add-iam-policy-binding
    --member user:your@new_user_email --role roles/compute.imageUser

    gcloud 计算项目 add-iam-policy-binding
    --member user:your@new_user_email
    --角色='roles/viewer'

现在您应该可以选择自定义图像和旧项目 ID 以从中启动实例