Google Compute Engine: How to snapshot a VM's disk

為{幸葍}努か 提交于 2019-12-24 09:23:40

问题


I'm trying to follow these instructions: https://cloud.google.com/compute/docs/disks#creating_snapshots

It's not obvious to me if I'm supposed to run the "gcloud compute disks snapshot DISK" command from my personal machine, or on the VM over SSH. I tried the former and I couldn't figure out an argument for DISK that worked. So I SSH'ed into the machine and ran

$ gcloud compute disks snapshot /

I left that running for several hours, without seeing any indication of progress. Now when I try to SSH into the machine, I can't:

$ gcloud compute ssh foo
Timeout, server foo not responding.
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

So I assume I've done something wrong, but I don't know what or how to fix it. Thanks


回答1:


You can run the command on either machine. Running it from the outside gives you more flexibility, while running from within the machine allows you to trigger snapshots based on machine events more easily. 'DISK' must be replaced with the disk name in Google Compute Engine. This is the same name you used to create the disk or, in case of root disks, it's the same as instance name. You can find the list of disks in your project with:

gcloud compute disks list

Alternatively, you can find disk names in '/dev/disk/by-id/google-*'.




回答2:


Timeout, server is not responding.

This is related to your SSH connection timeout issues. You need to enable and increase your server alive interval value in your ~/.ssh/config (or /etc/ssh/ssh_config), e.g.

Host *
  ServerAliveInterval 30
  ServerAliveCountMax 6

See: What the options ServerAliveInterval and ClientAliveInterval mean?



来源:https://stackoverflow.com/questions/27345534/google-compute-engine-how-to-snapshot-a-vms-disk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!