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


In recent days, I am facing a problem of high load on the server. Due to overload spikes, the use of SWAP is high and MySQL (5.5.58-cll) is the process that takes the most SWAP:

$ ps -e -o vsz, rss, comm | {lu x; echo "$ x"; sort -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 (markup):

The problem is that once SWAP is filled, it does not empty until I restart MySQL.

$ free -mht
total used cached free shared buffers
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 (markup):

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

# df -h | grep -v virtfs
Size of file system used Usage used% Mounted
/ 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 (markup):

(I still have that / dev / shm was in memory (tmpfs), now I see the file system "none" above, should i move mysql tmpdir to tmpfs like / tmp or to another location with no more disk quota?)

By the way, regarding the MySQL parameters, the script says:

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

Code (markup):

I do not want to waste your time, but if you're interested, full release of the script:
I have 1-2 low visit sites whose mysql table is close to 1 GB, I am not a programmer to change its structure to use indexes, it is known CMS (PHPBB, vBulletin).

My settings mysql: /etc/my.cnf (
(I do not think it is necessary to increase the buffers according to the tuner's advice, but if you see one or two values ​​too low or too high, thank you for letting me know)

my question is, as mentioned above, what to do with mysql tmpdir and secondly, if you see something wrong in my configuration and thirdly, what are the possible causes of the saturation of MySQL data by SWAP and that these data are not deleted and that SWAP stays full and fourth, how to prevent this (except dramatically increase the RAM)? Thank you