RAM limitation for AMaVIS and ClamAV on mail server hosted on VPS with only 1Gb RAM

 

  • Introduction

If you want to manage your email box on your own server (dedicated or shared) - you can easily create and manage email address related to your own domain name for instance - you may be interested in the following explanations...

I am not going to detail all the steps to get a mail server working because there are lots of good tutorials doing this. Most of the time, those tutorials explain how to install AMaViS (A Mail Virus Scanner) and ClamAV. The first one is able to manage spam whereas the second one treat potential viruses. Are you still here?

If you manage to install all the things correctly (with AMaVIS and ClamAV), congratulations... Yet, be aware of the use of RAM from AMaVIS and ClamAV if it is precious for you (server with less than 1Gb). You can look at the use of CPU and RAM.

 

  • A server getting slow...

Nothing critical, do not worry. But, you find that it is different than before, isn't it? In order to observe used ressources, you have two solutions:

  1. To have a graphical (web) interface detailling all the real-time statistics.
  2. To connect to your server to see what's happening.

 

For the first option, it is much easier than the second one. Everything is clear whitout doing nothing!

For the second choice, you have to use command line to get what you want. There is a command that show the list of all running processes with the use (in %) of CPU and RAM:

ps aux

We see that ClamAV and AMaViS are working very hard for you server (they use lots of memory)!

For those who want to get directly the good lines, you can use the following command:

ps aux | grep '%MEM\|amavis\|clamav'

 

Another way to see the use of your memory (RAM) is to type this:

free

 

If you find the rest of RAM is not enough (for web purpose for example), you have to ask yourself if ClamAV and AMaVIS are essential for your use. For a yes answer, you should change your server configuration in order to get more RAM (to pay more). Otherwise, you can stop them.

 

  • To stop ClamAV and AMaVIS

For those who prefer to stop both RAM eater, you just have to use the following commands (for Linux Debian and Ubuntu):

/etc/init.d/clamav-daemon stop
/etc/init.d/clamav-freshclam stop
/etc/init.d/amavis stop

It stops only ClamAV and AMaVIS processes. But you need to know that at the next reboot, they will start again. If you want to avoid this, use the following commands to remove them from the startup processes:

update-rc.d -f clamav-daemon remove
update-rc.d -f clamav-freshclam remove
update-rc.d -f amavis remove

 

ATTENTION:

If you have followed tutorials that explain how to set up you mail server, you will have to remove the link between postfix and AMaVIS. Otherwise, you won't receive your email anymore (they are waiting to get analysed by AMaVIS who is not running anymore on you server).

To do this, just open the /etc/postfix/main.cf file and comment the folowing line:

#content_filter = amavis:[127.0.0.1]:10024

You just have to reload postfix :

/etc/init.d/postfix restart

or

service postfix reload

 

  • Start (again) ClamAV and AMaVIS

AMaVIS and ClamAV are not uninstalled. You can start them again with:

/etc/init.d/clamav-daemon start
/etc/init.d/clamav-freshclam start
/etc/init.d/amavis start

If you want to get them running at the next reboot, you have to include them in the startup process list:

update-rc.d clamav-daemon defaults
update-rc.d clamav-freshclam defaults
update-rc.d amavis defaults

 

  • To check if everything is fine

To do this, nothing easier than sending an email to this mail server. If you do not receive your email, there is something wrong with the configuraiton. To understand where is the problem, you can look at the mail logs:

cat /var/log/mail.log

 

I f you get a line like the following one:

...
Nov 07 07:07:07 server007 postfix/smtp[2698]: 
connect to 127.0.0.1[127.0.0.1]:10024: Connection refused
...

It probably means that you do not remove the link between AMaVIS and postfix. Go back to the section "To stop ClamAV and AMaVIS" and read the attention note.

 

If everything is fine, well done! You server will thank you for the saving of RAM...

 

Hope this helps! wink

 

Comments

This website was... how do you say it? Relevant!! Finally I've found something which helped me.
Cheers!

Add new comment