I have a problem with an EC2 instance. In the past the instance suddenly lost the connections via SSH and Web (Apache dead and the other servers), and I could not even make ping. However, when I went to my account in AWS console the status showed that the instance was running without any problems and was connected to the Web. I never could really know why that was happening and the only solution I found was to stop the instance for a few minutes from my AWS account's console and then start it again after a few minutes. After that if I tried to connect to the instance worked like it never happened.
To avoid all of these problems, I created a new instance from scratch and migrated all my projects to the new instance. At first everything worked fine, then I had MySQL errors and looking for information I found it was because there was no swap memory. To solve the problem I manually configured the swap memory and it solved my problem with MySQL, but this morning this new instance generated the same error I had in the original instance, was totally cut off and the AWS console was showing the status that the instance had not problems. I turned it off for a few minutes and turned it back on, and it solved the problem.
The command that I executed for configuring the swap was this one:
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
after add this line to file /etc/fstab
/swapfile swap swap defaults 0 0
finally run these commands
$ swapon -s
$ free -m
$ swapoff -a
$ swapon -a
Was this problem originated from the changes with the swap memory? This problem was never shown in this new instance. What should I do to solve these problems?