Posts

Showing posts from February, 2016

How to solve: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I'm going to discuss a problem I've had recently and it has taken me longer than expected to know what was happening. For a few days, randomly my server has been displaying the message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' The Apache server was working normally, but Drupal could not access the database because the Mysql process had died. I started looking at the trace of mysql to see may have happened. It did not show any error message. When looking at the trace of S.O. (using dmesg) saw a memory overflow error. After doing a little research on Google, I found that Apache, when there are a greater number of connections, use all available memory on the server, causing the mysql closes before he could write anything in your log file. The solution has been to adjust the apache settings to reduce the amount of memory consumed and leave enough room to other processes running (like MySQL).

How to create swap file for amazon EC2 EBS instance

Amazon instances do not create a swap partition by default. If you want an easy solution to create it, we can do the following: sudo dd if = /dev/zero of = /var/swapfile bs = 1M count = 2048 sudo chmod 600 /var/swapfile sudo mkswap /var/swapfile echo /var/swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab sudo swapon -a These instructions will create a 2Gb swap file. If you want to increase or reduce, just change the value of count=2048 in the first instruction

How access a remote machine via SSH behind a proxy?

If we want to access external server via SSH, it is possible that if we are behind a proxy we will not have access to port 22 used by SSH. As root, edit the file sshd_config: sudo nano /etc/ssh/sshd_config Edit the line which states 'Port 22' and changed it by 'Port 443'. This port is used by 'https' so it will not be closed in the proxy. Switch over to the new port by restarting SSH. sudo /etc/init.d/ssh restart