/tmp Problem

vahid07

Verified User
Joined
Apr 16, 2018
Messages
22
Hi,

i have latest version of directadmin (1.53.0) on centos 7.x with apache (2.4.33), mariadb (10.2.15) and php (5.6.36 & 7.0.30) with this partition map:

Code:
[root@da ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        76G   41G   32G  56% /
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.8G     0  3.8G   0% /dev/shm
tmpfs           3.8G   25M  3.8G   1% /run
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/loop0      3.9G  177M  3.5G   5% /tmp
tmpfs           764M     0  764M   0% /run/user/1012

as you see my /tmp partition size is 4 GB which can enough for mostly server, but my problem is : recently it go full every day Suddenly (between morning and noon)

sometimes time i see it full with many files with this name sample : #sql_470_*.MAD

Image%202018-06-01%20at%2010.27.15%20PM.png


and sometimes i dont see any files and there is only a folder with size 3.7GB which have name sample: systemd-private-***-mysql.service-***

i have tmpwatch cron too. i decreased value of it (as you see in attached screenshot) but it cant usefull on this issue too!

Image%202018-06-01%20at%2010.30.03%20PM.png


also its sceenshot of service monitor when /tmp go full:

Image%202018-06-01%20at%2010.32.04%20PM.png


can you please guide me whats reason of this issue and how can i solve it?

Thank you
 
Hello,

That's MySQL temp tables created on disk, check MySQL process list and apache server status page, server logs for more clues.
 
Meh, don't just use tmpwatch to clean out your /tmp/ dir. It's not useful with '#' files anyway because they're temporary results from mysql/mariadb (order by, subselects) and usually only exist for a few seconds until the query is done. Simply deleting the files will kill the database connection and its process, resulting in failures on the websites.

You need to figure out what queries are causing this and improve them (better and usable indexes, smaller resultsets, better caching options in my.cnf... etc), or use faster disks, or increase the /tmp/ dir size.

Using tmp with a loop device is also not recommended as you'll be writing on 2 filesystems. It's hard to get a usable speed (for db's) using this, unless you configure everything very well and have enough ram to spare for linux to cache the 4gb tmpfs file. Which would be a waste of resources because it would be better to use a tmpfs for /var/tmp (rambased makes it very fast so you probable would need 4gb) or just drop the loopback device all together as it's still a file on your disk. Dropping it wouldn't cost you any space but would give you more performance (and therefore less temp files).
 
tmpfs/ramdisk upload size or optimize the queries.

More than 2GB in the /tmp something is malfunctioning.

My recomendation:

/boot = 1GB
swap = For < 2GB of RAM: 2 x RAM, for 2GB - 8GB of RAM: equal to the amount of RAM, for > 8GB of RAM: at least 4GB
/tmp = 2GB
/ = 10GB
/var = 20GB
/usr = 12GB or 16GB
/home = Rest of drive!

Tutorial: http://john.cuppi.net/move-mysql-mariadb-tmpdir-to-tmpfs-ramdisk/

Optimize queries.

https://www.youtube.com/watch?v=cYnT_-jy_Y8

https://www.youtube.com/watch?v=ojyEcNMAj8k

https://www.youtube.com/watch?v=mCbyb14PoLk
 
Last edited:
A simple partitioning is what I'd recommend to use with /tmp mounted as tmpfs (as mentioned earlier)

Directadmin recommends simple partitioning too: https://directadmin.com/install.html

And never use tmpwatch to clean temp tables in /tmp (as mentioned earlier already)
 
So!

/boot = 1GB: Today the RedHat 7 documentation itself recommends this in /boot. DirectAdmin would have to modify that in the documentation.
swap = For < 2GB of RAM: 2 x RAM, for 2GB - 8GB of RAM: equal to the amount of RAM, for > 8GB of RAM: at least 4GB.
/tmp = 2GB: More than 2GB means there are problems!
/ Rest of de disc!

https://access.redhat.com/documenta...lation_guide/sect-disk-partitioning-setup-x86

/boot partition - recommended size at least 1 GiB
The partition mounted on /boot contains the operating system kernel, which allows your system to boot Red Hat Enterprise Linux, along with files used during the bootstrap process. Due to the limitations of most firmwares, creating a small partition to hold these is recommended. In most scenarios, a 1 GiB boot partition is adequate. Unlike other mount points, using an LVM volume for /boot is not possible - /boot must be located on a separate disk partition.

¿Correct scheme?
 
Last edited:
Back
Top