Let’s assume you planned to move to Google Cloud Platform or give a try in the GCP and migrated your website or created a new VM Instance in Compute Engine and developed your website. Now you are happy with the performance and speed of your website. Now what are the issues you may face and how will you recover your website if you encounter any such problems.
This guide will help you to secure your website from various issues by preserving your data and keep your website live without any downtime.
|Alibaba Cloud||512 MB||20 GB||$2.50/mo|
|Cloudways – Managed Cloud||1 GB||25 GB||$10/mo|
|Kinsta – Google Cloud Managed WP||1 Website||10 GB||$30/mo|
What are the issues you can face in Compute Engine
- Accidentally deleted your VM Instance
- IP address changes often
- Compute Engine Instance cannot restart
- Cannot access SSH
- Website is down
Below are some must do things on Google Cloud to secure your website from the above-mentioned problems
Accidentally deleted VM Instance
This happens to everyone in many different situations like
- You try to delete some other instance and check the checkbox of your instance and didn’t notice that you also checked the main instance and clicked the delete button.
- Trying to stop the instance but mistakenly clicked the delete button
These are some accidents that happen by human error
So, to prevent these errors there are some must do things while setting up a Compute Engine Instance.
When creating a VM instance below the Firewall settings click the Management to expand additional settings. Now enable the Delete protection. When this is enabled you cannot delete the instance accidentally.
If you already have an instance running, you can just edit the instance and enable the Delete protection.
If you want to delete the instance you can disable the delete protection whenever you need.
This will help you from accidentally deleting the VM instance
IP address changes often
This is the normal behavior of every instance that is assigned an External IP address.
Whenever the instance restarts the IP address changes. So to prevent the change of IP address, it should be reserved as static. So your IP address will never change and stays as static
Compute Engine Instance cannot restart
Restart is necessary when you try to change the zone of your instance or change machine type of your instance or increasing disk size. Changing zone or machine type needs the instance to be stopped and started again. Increasing disk size requires a restart.
Also if there are no available resources in the zone the instance will fail to restart
So to prevent the restart problem first you need to create a backup of your instance. Backups in Compute Engine are creating an image of your instance or creating a snapshot.
So while upgrading your instance to higher or lower machine you need to create a backup and create a new instance from the backup with your machine type and finally switch the IP address to the new instance. Now you can delete the other instance.
This will prevent the restart problem and recover you from the instance restart failure.
Cannot access SSH
This happens if your disk is full or any server misconfiguration. If this happens you cannot access your instance and recover the data. But there is a way to access your instance by the Serial port console.
If you are trying to connect your instance via Serial port Console you need login using the username root and the password. So you need to set the root password when the VM is healthy. The VM’s in Compute engine doesn’t come with a root password set up by default so you’ll first need to change the password by running the following command in your SSH
Save the password in a safe place. This will help you to access your instance by the Serial port console.
Website is down
Let’s assume you are running WordPress with (LEMP) Nginx, PHP, MySQL in a VM with 600MB RAM (Micro). You can encounter this problem because the MySQL server crashes and cannot restart by itself. So how to handle this kind of issue.
Here comes the Cloud SQL which is a fully managed database service which is easy to maintain, manage and administer your database on GCP
Using Cloud SQL for your database is recommended for a perfect website in Google Cloud. Learn how to setup Cloud SQL for your website.
These are some best practices to be followed when you are using Compute Engine