Is the use of SWAP caused by insufficient space in mysql tmpdir?


recent days I have problems with the high load on the server, as a result of overload peaks is a high use of SWAP and MySQL (5.5.58-cll) is the process that takes most of the SWAP:

$ ps -e -o vsz, rss, comm | {read x; echo "$ x"; order -k2n | tail; }
348704 265096 httpd
348828 265120 httpd
349132 265140 httpd
349088 265288 httpd
349280 265468 httpd
349156 265520 httpd
349208 265548 httpd
917556 534052 clamd
3485196 2773796 grep
13168468 2827400 mysqld

Code (marked):

The problem is that once SWAP is full, it is not empty until you restart MySQL.

$ free -mht
total of free shared buffers used in cache
Mem: 13G 12G 504M 592K 0B 8.5G
- / + buffers / cache: 4.0G 9.0G
Swap: 2.0G 2.0G 17M
Total: 15G 14G 521M

Code (marked):

My MySQL tmpdir is / dev / shm (it has a size of 9GB), but recently I decreased the RAM in my VPS to around 13GB since I needed more RAM for another VPS. The server has a slow hard drive that usually becomes a bottleneck.

# df -h | grep -v virtfs
File system size used Avail Use% Assembled in
/ dev / simfs 342G 92G 251G 27% /
none 9.0G 4.0K 9.0G 1% / dev
none 9.0G 8.0K 9.0G 1% / dev / shm
tmpfs 9.0G 376K 9.0G 1% / tmp
tmpfs 9.0G 0 9.0G 0% / var / tmp

Code (marked):

(I always thought that / dev / shm was in memory (tmpfs), now I see the file system "none" above, should I move mysql tmpdir to tmpfs as / tmp or to another non-memory location with more disk quota? ?)

By the way regarding the configuration of MySQL, the script says:

[--]    Physical memory: 13.0G
[--] Maximum MySQL memory: 2.6G
[--] Other process memory: 4.3G
[--] Total buffers: 2.3G global + 1.1M per thread (230 maximum threads)
[--] P_S Maximum memory usage: 0B
[--] Use of Galera memory GCache Max: 0B
[OK] Maximum memory usage reached: 2.5G (19.07% of installed RAM)
[OK] Maximum possible memory usage: 2.6G (19.67% of installed RAM)
[OK] The possible use of memory in general with another process is compatible with the available memory

Code (marked):

I do not want to waste your time, but if someone is interested, exit full script:
I have 1-2 low visit sites whose mysql table is about 1 GB, I am not a programmer to change its structure to use indexes, CMS is known (PHPBB, vBulletin).

My mysql settings: /etc/my.cnf (
(I do not believe in increasing the buffers according to the tips of the tuner, but if you see one or two values ​​too low or high, let me know)

My Question is, as mentioned above, what to do with mysql tmpdir and second, if you see something wrong in my configuration and third, what are the possible causes that SWAP is full of MySQL data and that this data is not deleted and SWAP remains full and fourth? How to prevent that (except increase RAM significantly)? Thank you