Server hard disk full is quite common matter, especially on the cloud servers. Usual disk space allocated on common RAM size cloud server instance is 30-40GB. Bigger websites easily eat up 10GB space for the media files. System files including running applications take more than 10GB. And for WordPress, full hard disk will result showing up the infamous “Error Establishing a Database Connection” page. If your disk at 100% of usage then tries to free some space quickly by running (for Debian based distro) :
That should be enough to start MySQL :
service mysql restart
It is quite important to keep the head cool during downtime. Within 2-6 hours downtime, you are not going to miss huge traffic. Downtime is obvious for any website using a dynamic programming language with MySQL. Even with several humans, Quora-like websites face downtime. These are the reasons behind thinking of serverless computing. These days, most of the webmasters have an Android smartphone. Even We have a list of SSH client apps for Android. We suggest the webmasters of WordPress installations running on unmanaged servers to login every 6 hourly, or at least monitor the site by loading the webpage. Facing MySQL database connection error, just SSH, try to restart MySQL. If you can everyday restart MySQL from SSH, it probably will not disturb. Various MySQL errors are common out of minor wrong configuration, badly coded plugins etc. Our present topic is hard disk full issue. However, these tips definitely help someone. With a full hard disk, a full reboot may result in failure of Apache to restart. Various odd errors will be reported which will deduct erroneous conclusions. The easiest way to detect hard disk full is by checking the web host’s control panel. When you know that hard disk has 1-2GB left, you must be careful. If the hard disk is not full and MySQL, Apache failing to start that needs Analyzing Unexpected Shutdown of the Cloud Server Instance and opening a ticket towards the web host informing the situation. MySQL can be configured to auto-restart but not always that fix works.
Check these locations for old log files eating up disk space :
MySQL error log file often eats up few GB of space. You can easily empty one file with echo command by running command like this :
echo " " > mysql-error.log
You can check disk space used by a directory and it’s contented by running a command like :
du -shc /var/*
-s = summary
-h = human readable
-c = prints the total at the end
Files which ends with `.log` and tarballs. If you run `mysql --verbose --help | less` it will tell you about line 11 which `.cnf` file it will look for. You can also do `mysql --print-defaults` to show you how the configuration values it will use. This can also be useful in identifying just which config file it is loading. Running `mysqld --help --verbose` is dangerous. You can overwrite pidfile for the running instance! It is recommended to use with `--pid-file=XYZ`. So much said to add the below to `my.cnf` file :
You must not manually delete the mysql-bin files. Deletion of mysql-bin files depends on the backup strategy. The reason to keep the binary logs is to restore the database. If your database requires restoration, those files will help. If you perform a full backup every day and have 7 days binary logs, you can delete the past 4-6 days binary logs. It is not exactly easy to a complete newbie to decide. You need to ask
mysqld to do that for you.
mysql-bin.[index] keeps a list of all binary logs
mysqld has generated. If you run (on MySQL command line after login) :
PURGE BINARY LOGS TO `mysql-bin.000014`;
That will erase all binary logs before
If you run :
PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 4 DAY) + INTERVAL 0 SECOND;
that will erase all binary logs before midnight 4 days ago.
Apache2 log files can go huge size. Always check
/var/log/apache2 directory. Logs of this two software are commonly found to eat up 10GB or more space with time. Apache2 modules to Log HTTP POST Method will consume space. More security-related modules you’ll add, faster disk space likely to get consumed.