AWS EC2 instance created from AMI don't works (Error 504) - WEBb don't run - mysql

I'm new on AWS but I read a lot of documentation to create, launch and image instances. Now I have a client that use AWS and have 2 instances EC2 runing commercial web sites (using Nginx and MySQL in Amazon RDS and Wordpress).
I need to create clones of this websites to have a Q.A. ambient. I try creating images from these instances and launching new instances with this, but this don't work. When I Try to visit the website clone using the IP of the instance, that shows a 504 error. (The idea is to have two instances ready to use with the same website. One for visitors use and another to do testes, updates, changes or to use when the another instance crash)
The on-air website domain is ibser.org, and the new instance domain (runing now) is link to instance
Somebody may give me info that what can I do?

#Wilmar Sometimes it do happen as you have created the image successfully but due to manual setup you have to start the services inside the Instance manually.
As per the link provided, its showing 504 Gateway time out, so please check with the Security group of your newly created Instance and sometimes A corrupt WordPress database may also trigger a 504 gateway timeout error. This means may be your mysql service is not running.
So my suggestion is SHH into your New instances and check with all the required services which all need to be in running state and do check with the database.

Related

Creating a Staging VM in Google Compute Engine

I'm trying to set up a Staging VM for a site that's in production that I have just inherited. The site is running Wordpress/Woocommerce and has not been updated in a while. The VM it's hosted on is running an old version of PHP. Obviously, this all needs to be fixed up but I'm unfamiliar with GCP Compute Engine. Also any attempt to run backup/clone plugins crashes the site and requires a restore from the daily snapshot which is very annoying.
Is it possible to clone the VM/disk to a new instance, point that at a temporary domain, and test/update the site? I have been trying to do this for a while now without much luck any suggestions would be much appreciated. Thanks.
Creating a clone of an existing VM is possible and quite easy.
Create a snapshot of the VM. If possible stop the VM before doing this to ensure 100% accuracy - this way you will have exact snapshot of the drive without any errors. You can do it while the VM is running too if stopping it is out of the question.
Create a VM from the shapshot - select as a boot disk a snapshot that you've just created. Remember to assign a static public IP to this VM (unless you want it changed after VM restart and since you're going to do some configuration this would likely happen). You can change the VM's specs at this time too - nothing stops you from adding/removing CPU's, RAM etc. It may well be that your VM is underutilised and you can use something smaller to save costs. Or the opposite.
Start the machine. Now you can modify your WP configuration to point to a new domain. Depending on the SSL certificate - you can either use external one or the one provided by GCP (most convinient solution).
If you already own a domain you want to use for staging you can host it in Cloud DNS or at some other provider - just point it to the external IP you just reserved.
If you will be hosting your domain in the Cloud DNS then you will find necessary infomration in the documentation about managed zones (domains).
You can also consider creating a new VM and setting it as a template for creating a group of VM's (managed autoscaled group) and creating an external HTTPS load balancer in front of it. But this adds a little to the complexity so it's just my idea if you needed to handle a lot more traffic.

ERROR 2003 (HY000): Can't connect to MySQL server on 'x.x.x.x' (110)

I'm trying to establish a basic mysql connection from a google compute engine instance in one project to a google cloud sql instance (2nd generation) in a different project.
I've done this many times before without any problem. You simply add the ip address of the google compute instance to the list of authorized networks for the google cloud sql instance. This has always worked in the past but it is not working now.
The only thing that I can think of which is different about this situation is that I've recently been experimenting with using the cloudsql-proxy to establish a connection from a different gce instance to the same google cloud sql instance. Could this be the problem? Perhaps the google cloud sql instance is getting confused by having to support both connection mechanisms?
I just need the connection to work. Is there a work-around?
There isn't a problem using both modes of connectivity simultaneously.
The only thing I can think of is that you are accidentally using an ephemeral IP addresses for your VMs instead of static, which means the VM may have a different IP address than you expect (after a restart, for example).
If that's not the case, please send a mail to cloud-sql#google.com with a little bit more information (project and database name, project/name/ip of your VM) so that we can figure out what's going on in the backend.

How to connect from Flexible Environment to Second Generation Cloud SQL instance?

I have deployed my web server which requires a MySQL database for storage. I've created a Second Generation MySQL instance with one failover replica but I am not sure how I can connect to those.
I am not sure how to configure these instances and what I have to consider here e.g. region/zone. Flexible Environment appears to be unavailable in Europe unfortunately - at the moment at least - so I guess I'll have to place the SQL instances in the US too.
Will those instances have to be in the same local network or can they communicate over regions? Will I even be able to control this or will all this be decided by Google Cloud?
Could anybody who has done this before give me a few details about what to do here?
For best performance, you should place your App Engine instances in the same region.
For information on how to connect from your application to the Cloud SQL MySQL instance see the following documentation: https://cloud.google.com/sql/docs/dev-access#gaev2-csqlv2
The short summary is that you have to modify your app.yaml file to list the Cloud SQL instances you will be connecting to. Once that's done, a local socket will appear inside the App Engine VM that will allow you to connect to your Cloud SQL instance.

Compute Engine VM instance group got wiped out?

I'm new to GCE and want to migrate my web site there. I created a VM instance group hoping. I installed all the packages and set it up a couple days ago. But today I noticed my VM instance group has a different name (postfix, to be exact), and the disk is flushed empty. Is it possible to restore its status, or at least make sure it won't get wiped out again? I'm so surprised that GCE wiped out everything and I wonder if I'm missing something during setup.
A few details in case they are related:
I'm using a trusty image for the VM.
The cloud storage is chosen to be a regular persistent disk.
It was working with emphemeral IP, and yesterday I started to use Cloud DNS to host my domain. I should have used a static IP, but that mistake shouldn't cause the VM instance group to be flushed...
I'm using cloud sql as the database service.
Maybe I should just use VM instance, given I don't have much traffic now?
Any help will be greatly appreciated~

Google cloud VM Instance DNS error

I am having a bit of an issue with the VM Instances on google cloud. I installed and set up apache and a website with it but now I am trying to configure a custom domain and when I try to add it in SSH I get the following error:
ERROR: (gcloud.dns.managed-zone.create) ResponseError: status=403, code=Forbidden, reason(s)=insufficientPermissions
message=Insufficient Permission
I have also tried the directions at the following https://cloud.google.com/appengine/docs/domain and am getting a 404 not found error on my domain. Any help would be greatly appreciated.
You say you are having an issue with a VM instance and are trying to set up a custom domain. Those two are in very different realms. VM instances are under Compute Engine (except for Managed VMs, which live under App Engine, but that is beside the point). Custom Domains are features just of App Engine.
What do you mean that you are trying to "add it in SSH"? Did you mean DNS? If so, see my answer below.
What command are you running to get ERROR: (gcloud.dns.managed-zone.create) ResponseError: status=403, code=Forbidden, reason(s)=insufficientPermissions message=Insufficient Permission?
The docs apply to App Engine, not Compute Engine. That you are getting a 404 error is no surprise if you don't also have a corresponding app running in App Engine.
If you are trying to create a DNS hostname for a web site hosted on a VM instance on Compute Engine, I recommend that you either (a) use a static IP address and a static A record pointing to it, or (b) use an ephemeral IP address and set up a dynamic DNS A records pointing to it. (I use freedns.afraid.org for my DDNS.)