how to restore vm instance from terminated state ? - google-compute-engine

I halted the linux vm instances for couple of days. I dont see any options to turn it back on. I hit reboot and it pops the error here is detailed log
"RESOURCE_NOT_READY: The resource 'projects/myproject/zones/us-central1-a/instances/myinstance' is not ready"
I still see the disk for instance there and it marks active. Is there any way to reactivate the instance ?
thanks

Instances in a "TERMINATED" state cannot be restarted. If your instance is in this state, the only option is to delete the instance. Any data on scratch disks is gone.
Persistent Disks are independent of instances. If your disk is a Persistent Disk, you can create a new instance with the disk attached and continue using the disk.

This is now possible!
Please have a look at the instances.start API call https://developers.google.com/apis-explorer/#p/compute/v1/compute.instances.start

as of 2019-03-22, a machine in the state of "terminated", use can choose to either "start" or "delete" it.
https://cloud.google.com/compute/docs/instances/instance-life-cycle

Related

Google compute engine, instance dead? How to reach?

I have a small instance running in GCE, had some troubles with the MongoDb so after some tries decided to reset the instance. But... it didn't seem to come back online. So i stopped the instance and restarted it.
It is an Bitnami MEAN stack which starts apache and stuff at startup.
But... i can't reach the instance! No SCP, no SSH, no webservice running. When i try to connect via SSH (in GCE) it times out, cant make connection on port 22. In the information it says 'The instance is booting up and sshd is not running yet', which is possible of course.... But i cant reach the instance in no possible manner not even after an hour wait :) Not sure what's happening if i cant connect to it somehow :(
There is some activity in the console... some CPU usage, mostly 0%, some incomming traffic but no outgoing...
I hope someone can give me a hint here!
Update 1
After the helpfull tip form Serhii... if found this in the logs...
Booting from Hard Disk 0...
[ 0.872447] piix4_smbus 0000:00:01.3: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr
/dev/sda1 contains a file system with errors, check forced.
/dev/sda1: Inodes that were part of a corrupted orphan linked list found.
/dev/sda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
fsck exited with status code 4
The root filesystem on /dev/sda1 requires a manual fsck
Update 2...
So, i need to fsck the drive...
Created a snapshot, made a new disk from that snapshot, added the new disk as an extra disk to another instance. Now that instance wont boot with the same problem... removing the extra disk fixed it again. So adding the disk makes it crash even though it isn't the boot-disk?
First, have a look at the Compute Engine -> VM instances -> NAME_OF_YOUR_VM -> Logs -> Serial port 1 (console) and try to find errors and warnings that could be connected to lack of free space or SSH. It'll be helpful if you updated your post by providing this information. In case if your instance run out of free space follow this instructions.
You can try to connect to your VM via Serial console by following this guide, but keep in mind that:
The interactive serial console does not support IP-based access
restrictions such as IP whitelists. If you enable the interactive
serial console on an instance, clients can attempt to connect to that
instance from any IP address.
more details you can find in the documentation.
Have a look at the Troubleshooting SSH guide and Known issues for SSH in browser. In addition, Google provides a troubleshooting script for Compute Engine to identify issues with SSH login/accessibility of your Linux based instance.
If you still have a problem try to use your disk on a new instance.
EDIT It looks like your test VM is trying to boot from the disk that you created from the snapshot. Try to follow this guide.
If you still have a problem, you can try to recreate the boot disk from a snapshot to resize it.

Creat an image from Google Compute Engine instance

I am trying to replicate a new instance from my current instance in Google Compute Engine (following Google instruction: https://cloud.google.com/compute/docs/images#create_an_image_from_a_root_persistent_disk).
In step 3 (Terminate your instance), I am following the instruction ($ gcloud compute instances delete example-instance --keep-disks boot). However, it still asks me whether I want to completely delete the instance:
The following instances will be deleted. Attached disks configured to
be auto-deleted will be deleted unless they are attached to any other
instances. Deleting a disk is irreversible and any data on the disk
will be lost. Do you want to continue (Y/n)? n
Am I still able to recover the instance or continue to create the image of my current instance as Google's instruction? If any body has try to replicate Google Compute Engine, please let me know. Thank you!
I just tested this command on my account and deleted my instance using " --keep-disks boot ". This option keeps the boot disk despite the warning message which says "Attached disks configured to be auto-deleted will be deleted....."
You can also use Developers Console, uncheck "Delete boot disk when instance is deleted" under your instance properties and then delete the instance from there.

Google Compute Engine disk snapshot stuck at creating

I took a snapshot of a 50GB volume (non-boot) which is attached to an instance. The snapshot was successful.
I shut the instance and tried taking another snapshot of the same volume. This time the command hung. gcloud status reflects "CREATING" for this attempt. It is hours since I started the snapshot command. I tried the same using google developers console. The behaviour remains the same.
I restarted the instance and the status of the snapshot changes to "READY" within seconds.
It seems that snapshots should be taken if the volume is attached to a running instance. Otherwise the command is queued and executed when the volume/instance is live. Is this expected behaviour?
I replicated your issue and indeed the snapshot process halts when the instance is shut down. You may have also noticed that now the Shutdown/Start feature has been introduced - it was not available before.
I believe this is due to how snapshots are being handled on the platform. Your first snapshot creates a full copy of the disk, while the second one is differential - the differential one will fail or stay in pending as it cannot query the source disk while the instance is down to check what has been changed . You can check this for further info.
Dettaching the disk from the instance and then creating a snapshot works, so that could be a workaround for you.
Hope this helps

Google Cloud SQL stuck at restart

My cloud sql instance is stuck in Restart sate for a very long time.
In the operations pane, the status of the Restart is showing as pending, and there was also an export happening whose state is still Running .
Is there an way i can force the restart or cancel the restart or recover the data from the regular backup ?
No, there is no way. If you pay Google for a premier account, you will be able to log a support ticket and they'll look into it and probably fix it.
There's not many options you have, maybe try restarting again?

Compute Engine Instance

I have created a Google Compute Engine instance with CentOS and added some stuff there, such as Apache, Webmin, ActiveCollab, Gitolite etc.. etc.
The problem is that the VM is always running out of memory because the RAM is too low.
How do I change the assigned RAM in Google Compute Engine?
Should I have to copy the VM to another with bigger RAM? If so will it copy all the contents from my CentOS installation?
Can anyone give me some advises on how to get more RAM without having to reinstall everything.
Thanks
The recommended approach for manually managed instances is to boot from a Persistent root Disk. When your instance has been booted from Persistent Disk, you can delete the instance and immediately create a new instance from the same disk with a larger machine type. This is similar to shutting down a physical machine, installing faster processors and more RAM, and starting it back up again. This doesn't work with scratch disks because they come and go with the instance.
Using Persistent Disks also enables snapshots, which allow you to take a point-in-time snapshot of the exact state of the disk and create new disks from it. You can use them as backups. Snapshots are also global resources, so you can use them to create Persistent Disks in any zone. This makes it easy to migrate your instance between zones (to prepare for a maintenance window in your current zone, for example).
Never store state on scratch disks. If the instance stops for any reason, you've lost that data. For manually configured instances, boot them from a Persistent Disk. For application data, store it on Persistent Disk, or consider using a managed service for state, like Google Cloud SQL or Google Cloud Datastore.