None
None

Reputation: 302

Mysql is taking more & more RAM on my linux/Centos server

I'm running a dedicated server with 16Go or RAM and 1Go of SWAP. My real time statistics on the server show that more than half of my ram and 99% of my SWAP is used my :

/usr/libexec/mysqld --basedir?/usr --datadir?/home/mysql --user?mysql --log-error?/var/log/mysqld.log --pid-file?/var/run/mysqld/mysqld.pid --socket?/

It keeps increasing with time and even restarting mysql won't change it

enter image description here

When I do a

 mysql> SHOW PROCESSLIST

I get as result

+------+-----------+-----------------+-------+---------+------+-------+------------------+
| Id   | User      | Host            | db    | Command | Time | State | Info             |
+------+-----------+-----------------+-------+---------+------+-------+------------------+
|    7 | root      | localhost:51312 | mysql | Sleep   |    5 |       | NULL             |
| 7156 | mailadmin | localhost:58878 | mail  | Sleep   | 3406 |       | NULL             |
| 9302 | mailadmin | localhost:32868 | mail  | Sleep   |  749 |       | NULL             |
| 9305 | mailadmin | localhost       | mail  | Sleep   |  747 |       | NULL             |
| 9802 | mailadmin | localhost       | mail  | Sleep   |    9 |       | NULL             |
| 9803 | mailadmin | localhost       | mail  | Sleep   |    9 |       | NULL             |
| 9807 | mailadmin | localhost       | mail  | Sleep   |    9 |       | NULL             |
| 9808 | mailadmin | localhost       | mail  | Sleep   |    9 |       | NULL             |
| 9825 | root      | localhost       | NULL  | Query   |    0 | NULL  | SHOW PROCESSLIST |
+------+-----------+-----------------+-------+---------+------+-------+------------------+
9 rows in set (0.00 sec)

and a

free -m -l

shows me :

  total       used       free     shared    buffers     cached
Mem:         16094      14431       1663          0       1318       5404
Low:         16094      14431       1663
High:            0          0          0
-/+ buffers/cache:       7708       8385
Swap:         1021        996         25

I have no idea on how to deal with this. It seems like I will reach the RAM limit of the server and it will probably cause slowness.

Thank you in advance, I stay here, ready to provide you with more informations.

Upvotes: 0

Views: 1769

Answers (2)

spencer7593
spencer7593

Reputation: 108380

Your statement that "restarting mysql won't change it" seems to imply that it's not mysqld that's using all the memory.

A rudimentary way to find processes that are using the most memory, you could run htop and sort by one of the memory columns, like VIRT. It may not be just one process, it could be whole slew of processes each using memory. (Some of the memory reported is shared, you can't just add up the memory for all the mysql processes... in htop, use keypresses F5 and H to get a "tree view".

In this example, mysql is using 11G, 73% of available memory. That's expected, because that's what we allocated, the bulk of that is allocated to the InnoDB buffer pool. (dedicated MySQL server)

  PID USER     PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
19510 mysql     20   0 11.0G 5849M  3808 S 16.0 73.1 81h33:04 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/opt/mysql_data --user=mysql --log-error=/
 1016 syslog    20   0  220M   940   580 S  0.0  0.0  5:28.12 rsyslogd -c4
 1651 root      20   0  145M  1100   784 S  0.0  0.0  8:26.81 /usr/sbin/automount
 1243 root      20   0 98496  1348  1036 S  0.0  0.0  3h19:31 /usr/sbin/vmtoolsd
13816 root      20   0 90868  1340   404 S  0.0  0.0  0:00.02 sshd: xxxxxx [priv]
13905 mysql     20   0 81548  1120   428 S  0.0  0.0  0:00.02 su - mysql
 1674 Debian-e  20   0 64724   408   332 S  0.0  0.0  0:09.08 /usr/sbin/exim4 -bd -q30m
 1030 root      20   0 63256   472   360 S  0.0  0.0  1:32.65 /usr/sbin/sshd
    1 root      20   0 61840   996   472 S  0.0  0.0  1:05.14 /sbin/init

(There's probably a lot better ways to see what's using memory, but htop does a pretty good of showing me processes that are running.)

Upvotes: 2

Fahad Ahammed
Fahad Ahammed

Reputation: 371

I think you are being spammed. Your mail server is taking too much mails or sending. It is better to check your incoming/outgoing mails.

And will you consider setup Spamassasin/Amavisd or something like that ? I think if you turn of your mail server you will see that it lowers and it will be verified that its Mail server by spams.

Upvotes: 3

Related Questions