100% of SWAP used, MySQL is cause, what to do?

postcd

Well-Known Member
Oct 22, 2010
720
20
68
Hello dear cPanel users,

on WHM server i found im using 100% of swap.

# free -m
total used free shared buffers cached
Mem: 17500 10805 6694 0 0 5934
-/+ buffers/cache: 4871 12628
Swap: 1024 1024 0

i read that someone adviced restarting mysql, httpd and i instantly i thought mysql is cause in my case. after restart, i see:

# free -m
total used free shared buffers cached
Mem: 17500 7366 10133 0 0 5991
-/+ buffers/cache: 1374 16125
Swap: 1024 11 1012

So it is back almost empty..

one can sort processes by ram usage by doing:
1) top -c
2) F key
3) o key
4) enter key

please what steps do you suggest to prevent swap being filled by mysql?
i have centos, mysql, i already ran mysqltunning scripts, here is my.cnf file

thank you
 
Last edited:

mageshm

Well-Known Member
Apr 17, 2014
90
1
6
Chennai, INDIA
cPanel Access Level
DataCenter Provider
Hi,
I need few details from you to understand the root causes of issue.
1) From top -c command, what is your output and which process is consuming more RAM & CPU utilization (like any particular DB or entire MySQL or anyother services)
2) Use the below command to check MySQL activity, some time you will face this kind of issues, if the DB using JOIN or COPY query. Also verify how long the query is running.

[email protected] [~]# watch -n1 mysqladmin proc stat
or
[email protected] [~]# watch -n 1 mysqladmin processlist
 

postcd

Well-Known Member
Oct 22, 2010
720
20
68
@mageshm
1) top -c
most processes are in maximum several hundreds of megabytes VIRT memory. Following process using around 5,6GB VIRT
mysql 901 8.7 23.3 5755996 4187488 ? Sl 09:15 45:04 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/my.fqdn.hostname.err --open-files-limit=43762 --pid-file=/var/lib/mysql/my.fqdn.hostname.pid
2)
there do not seems to be much slow queries, these are processes that are sitting there some seconds:
| 162 | eximstats | localhost | eximstats | Sleep | 164 | | |
| 2737 | root | localhost | | Sleep | 108 | | |
| 34727 | modsec | localhost | modsec | Sleep | 1192 | | |
| 120004 | leechprotect | localhost | leechprotect | Sleep | 13129 | | |
| 206390 | root | localhost | | Query | 0 | | show processlist |
+--------+---------------+-----------+---------------+---------+-------+-------+------------------+
 

postcd

Well-Known Member
Oct 22, 2010
720
20
68
i will not share my top -c output. i dont have mysql error log in /var/log, only slow_log and nothing strange in it.

Anyone else please can help with some ideas on how to debug this please? Thank you
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello :)

You may need to consult with a qualified system administrator if the existing changes you have made based on a MySQL tuner have not helped.

Thank you.