The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Workarounds and Optimization' started by postcd, Oct 20, 2015.

  1. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    624
    Likes Received:
    6
    Trophy Points:
    18
    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
     
    #1 postcd, Oct 20, 2015
    Last edited: Oct 20, 2015
  2. mageshm

    mageshm Well-Known Member

    Joined:
    Apr 17, 2014
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    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.

    root@xxx [~]# watch -n1 mysqladmin proc stat
    or
    root@xxx [~]# watch -n 1 mysqladmin processlist
     
  3. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    624
    Likes Received:
    6
    Trophy Points:
    18
    @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 |
    +--------+---------------+-----------+---------------+---------+-------+-------+------------------+
     
  4. mageshm

    mageshm Well-Known Member

    Joined:
    Apr 17, 2014
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Chennai, INDIA
    cPanel Access Level:
    DataCenter Provider
    I'm not getting anything from top-c output, can you please take a screenshot and share with me if its possible. Also have a look into MySQL error log file which will help you to get some details.
     
  5. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    624
    Likes Received:
    6
    Trophy Points:
    18
    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
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page