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.
Related
I have a GCE ubuntu 18.04 system that overflowed the / partition. Consequently, I can't start a remote shell to fix it. I created a new system from a snapshot, and stopped the old system.
I want to attach the old system disk to the new system, mount it, and delete a bunch of stuff so I can restart it.
However, when I edit the new system disk in the cloud console, the old system disk does not show up as a possible disk to attach. What do I need to do to the old system disk to both preserve it as a system disk, and allow attaching it to the new system?
What do I need to do to the old system disk to both preserve it as a
system disk, and allow attaching it to the new system?
Either the disk is still attached or the new instance is located in a different zone. Follow the steps below.
STEP 1:
Shut down your instance with the disk space problem. Login into the Google Cloud Console. Go to Compute Engine -> VM instances. Click on your instance and make note of the “Boot disk” name. This will be the first disk under “Boot disk and local disks”.
STEP 2:
Create a snapshot of the boot disk before doing anything further. While still in Compute Engine -> Disk. Click on your boot disk. Click on “CREATE SNAPSHOT”.
STEP 3:
Create a new instance in the same zone. A micro instance will work.
STEP 4:
Open a Cloud Shell prompt (this also works from your desktop if gcloud is set up). Execute this command. Replace NAME with your instance name (broken system) and DISK with the boot disk name and ZONE with the zone that the system is in:
gcloud compute instances detach-disk NAME --disk=DISK --zone=ZONE
Make sure that the command did not report an error.
STEP 5:
Now we will attach this disk to the new instance that you created.
Make sure that the repair instance is running before attaching the second disk. Sometimes an instance can get confused on which disk to boot from if more than one disk is bootable.
Go to Compute Engine -> VM instances. Click on your instance. Click Edit. Under “Additional disks” click “Add item”. For name enter/select the disk that you detached from your broken instance. Click Save.
STEP 6:
SSH into your new instance with both disks attached.
STEP 7:
Mount the second disk to the root file system.
Become superuser. Execute sudo -s
Execute df. Make sure that /dev/sdb1 is not mounted.
Create a directory for the mount point: mkdir /mnt/repair
Mount the second disk: mount /dev/sdb1 /mnt/repair
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.
I created a snapshot of a VM instance via cloud console. I would like to know how I can restore an instance using a snapshot. The documentation for compute engine is not very helpful. The instance runs on Ubuntu. Thanks.
To restore an instance from a snapshot without deleting/re-creating the instance:
Shut down the instance and detach the boot disk: gcloud beta compute instances detach-disk INSTANCE_NAME --disk BOOT_DISK_NAME
Create a new disk from the snapshot: gcloud compute disks create DISK_NAME --source-snapshot SNAPSHOT_NAME
Attach the disk created from step 2 as the boot disk: gcloud beta compute instances attach-disk INSTANCE_NAME --disk DISK_NAME --boot
Restoring the instance without deleting/re-creating the instance means that after restore, the instance will keep its IP address and other properties like tags, labels, etc.
In Console, you can go to VM Instances from Compute Engine tab.
There you click on '+Create Instance'
and there in section of boot-disk, you can navigate to 'snapshots' tab and select the snapshot you took.
Like this from console, you can Restore your instance.
Let me know, if this doesn't work for you!
Try using:
gcloud compute disks \
create <NEW_INSTANCE_NAME> \
--source-snapshot <SNAPSHOT_NAME> \
--type pd-ssd \
--zone <ZONE>
You could find useful instruction here.
If you want to do it in the web interface, it's pretty easy. Edit your VM instance. Scroll down to your boot disk and click "x" next to the boot volume, then click create button. In the next window give your new volume a meaningful name, set up your snapshot schedule, and then under "source type" select "Snapshot". Choose your snapshot from the dropdown. If you have a customer managed/supplied key (not recommended) select it, otherwise leave it as google-managed key. Click create. Depending on disk size it might take a while. Be patient and let it finish the setup and then start your instance once it is al complete.
I decided to play around with Google Could SQL and I setup a test sql instance, loaded it with some data and then setup replication on it in the google dev console. I did my testing and found out it all works great, the master/slave setup works as it should and my little POC was a success. So now I want to delete the POC sql instances but that's not going so well.
I deleted the replica instance fine (aka the 'slave') but for some reason the master instance still thinks there is a slave and therefore will not let me delete it. For example I run the following command in the gclound shell:
gcloud sql instances delete MY-INSTANCE-NAME
I get the following message:
ERROR: (gcloud.sql.instances.delete) The requested operation is not valid for a replication master instance.
This screenshot also shows that in the google dev console it clearly thinks there are no replicas attached to this instance (because I deleted them) but when I run:
gcloud sql instances describe MY-INSTANCE-NAME
It shows that there is a replica name still attached to the instance.
Any ideas on how to delete this for good? Kinda lame to keep on paying for this when it was just a POC that I want to delete (glad I didn't pick a high memory machine!)
Issue was on Google's side and they fixed it. Here were the sequence of events that led to the issue happening:
1) Change master's tier
2) Promote replica to master while the master tier change is in progress
Just had the same problem using GCloud. Deleting the failover replica first and then the master instance worked for me.
My free trial period has been cancelled but I would like to continue using my existing engines.
The console says my instance is terminated and is no longer running.
Rebooting the instance gives "The resource .... is not ready' error.
How can I continue using my engines with exact same IP setting and other configurations?
Once an instance is in a 'TERMINATED' state it can no longer be booted. You will need to recreate an instance with the same configuration, IP address and boot disk as you indicate. See this FAQ for more information about the terminated state: https://cloud.google.com/compute/docs/troubleshooting#terminate
To retain your existing IP address you will need to promote it to a static IP address resource. You can then reassign this address resource to your new instance.
$ gcloud compute addresses create address-name --addresses IP_ADDRESS --region REGION
See this article for the exact steps:
https://cloud.google.com/compute/docs/instances-and-network#promote_ephemeral_ip
To migrate the existing data on your disk you could create a snapshot and then restore that snapshot when creating a new instance:
$ gcloud compute disks snapshot DISK
See this article for the detailed steps:
https://cloud.google.com/compute/docs/disks#creating_snapshots
Finally to migrate all the associated configuration and metadata you could use the describe subcommand in the Cloud SDK:
$ gcloud compute instances describe INSTANCE
This would print out the entire configuration for your existing instance which you can then use to recreate in your new instance.
The exact steps are quite similar to the process of migrating an instance from one zone to another. You could essentially follow the guide for that process but recreate your new instance in the same zone if you prefer not to move the location of your data. The steps for migrating an instance across zones can be found here:
https://cloud.google.com/compute/docs/instances#moving_an_instance_between_zones