WordPress on EC2 crashes and becomes inaccessible - wordpress

I have a WordPress instance running on an EC2 (t2.micro). MySQL and WordPress are both hosted on this EC2 instance and an EBS is attached to it.
The EC2 instance occasionally crashes and becomes inaccessible (accessing it on a browser times out) and sometimes I get the following error, which means the database is somehow not working:
Error establishing a database connection
If you look at the logs you can see that there are a number of peaks on EC2 "CPU Utilization" and also peaks on EBS "Read Bytes" at the same time. These are examples of occasions that it became inaccessible.
What can be the cause of this issue?
Should I increase the memory of the EC2 instance or add more storage on EBS (it has 35G at the moment, I've already increased it)?

Related

Plone 4 site is up, but it’s not responding

I have a Plone 4 site at http://tinakellyrussell.com/ However, when you go to the site, it stalls for a while and then times out. (This even happens when connecting via IP address, so it’s not a DNS issue.) It’s hosted on an Amazon EC2 instance, and if I connect via SSH and use “plonectl status” the result is:
instance: program running; pid=788
Restarting Plone (or the EC2 instance itself) doesn’t seem to help. It’s been running fine for years, I didn’t make any changes or updates when it started failing. I don’t know what the problem is :(

Can't connect to local server

Currently we have a system in place where multiple server backup to a server in house. There are a total of 11 different servers backing up to this one storage server. Without any change(any that we are aware of) one of the servers stopped being able to connect to the storage server. It's weird too because the one that can't connect is actually our DNS server. It can ping the storage server and nslookup returns the appropriate value. However when I tried to browse to the server in windows explore via network I get the following message:
"Check the spelling of the name. Otherwise, there might be a problem with your network. To try to identify and resolve network problems, click Diagnose." - Error Code: 0x800004005 Unspecified error.
If at all possible I would like the solution to not have to restart the server(obviously that's a big request) but we run 24/7 and can't have the DNS server down for the next few weeks.
Thanks in advance!
I am completely guessing here however lets start with this, does it work if you try and connect to the share using IP?
A few things to consider in the mean time? What O.S is it?
-> Is network discovery off?
-> Have any firewalls been accidentally turned on
-> We had a similar sort of problem when the server lost it's trust relationship with AD (required a reboot I am afraid).
Unfortunately this error can relate to a range of problems including network devices, anti-virus, firewalls, shares, user accounts etc etc.

Hosting wordpress blog on AWS

I have hosted a wordpress blog on AWS using EC2 instance t1.micro (Ubuntu).
I am not an expert on linux administration. However, after going through few tutorials, I was able to manage to have wordpress successfully running.
I noticed a warning on AWS console that "In case if your EC2 instance terminates, you will lose your data including wordpress files and data stored by MySql service."
Does that mean I should use S3 service for storing data to avoid any accidental data loss? Or my data will remain safe in an EBS volume even if my EC2 instance terminates?
By default, the root volume of an EC2 instance will be deleted if the instance is terminated. It can only be terminated automatically if its running as a spot instance. Otherwise it can only be terminated if you do it.
Now with that in mind, EBS volumes are not failure proof. They have a small chance of failing. To recover from this, you should either create regular snapshots of your EBS volume, or back up the contents of your instance to s3 or other storage service.
You can setup snspshot lifecycle policy to create scheduled volume snapshots.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/snapshot-lifecycle.html

How to setup a wordpress site in multiple amazon ec2 micro instances

I'm new to AWS and cloud computing in general. For a personal project I've created a micro instance on amazon ec2 and installed and configured a wordpress multisite site. For the database, I use an RDS instance.
My question is, how can I create a second micro instance that serve the same content and use a load balancer to spread the traffic to these two instances? I want to do this so that so if the first EC2 instance crashes then it will get served from second instance and the site doesn't go down.
Thanks for your help and sorry for any english related error.
As far as the wordpress installation is concerned, there are 2 main components.
Wordpress Database
Wordpress Files (Application Files including plugins,themes etc.)
The Database
For enabling auto scaling setup and to ensure consistency, you will
need to have the database outside the auto-scaling EC2 instance. As mentioned
in your question, this is in RDS and hence it wont be a problem
The second EC2 instance
Step 1: First create an AMI of your Wordpress Instance from the existing one.
Step 2: Launch a new EC2 instance from this AMI which you created from the first one. This will result in 2 EC2 instances. Instance 1 (the original one with Database) and Instance 2 (The copy of Instance 1)
However, any changes that you do in Instance 1 wont reflect in Instance 2.
If you want to get rid of this problem, consider using EFS service to create a shared volume across 2 EC2 instances and configure the wordpress installation to work from that EFS volume. This way, your installation files and other content will be in shared EFS volume commonly accessed by both EC2 instances.
You will have to move your database out of your localhost (I guess that you have it on the same micro instance), either to another ec2 instance or preferably to an RDS instance.
Afterwards you need to create a copy of your ec2 instance to another ec2 micro instance and put the both behind a load balancer.
First create the image of your existing micro ec2 instance on which you have configured word press
Second, create a classic load balancer
Third, create a launch configuration (LC) with above AMI you created.
Fourth, create auto scaling group with above LC, ELB and keep the group size count to 2.
This will make sure you have 2 instances running all time and if at all any instance goes down, ASG will create another new instance from AMI and terminate failed instance. REF-
https://docs.aws.amazon.com/autoscaling/latest/userguide/as-register-lbs-with-asg.html
Or
If you want you can use elastic bean stalk also-
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-hawordpress-tutorial.html
Thanks

Why is this error happening a lot "asp.net, sql server"?

I have this error which happen many times on my site:
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.)"
My site files are on a server and the database on another server, but on the same network.
Anyone know what may cause this problem and how to solve?
Notes:
- When i restart the website server the problem solve and everything work fine.
- Sure my sql server allow remote connections from this website server
It's a pretty generic error when the application can't get to the database. Perhaps you are leaving connections open after using them? There could be a limit on the amount of concurrent connections by user or server.
It's a networking error of some kind, or you're specifying the instance name incorrectly. I've recently seen both cases. In one case, I had moved a connection string from one system, to another system that had a different instance name installed. In another case, I had a server running in a Virtual Machine - about ten minutes after the machine was resumed from suspension, the machine would lose its DHCP lease (and therefore its connectivity).
It could be just about anything, and you'll have to go find out, perhaps by using a network monitor program like Microsoft Network Monitor 3.2.
I found a good article talking about this error, i think it shows the real reason
Understanding the error “An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.”

Resources