Munin, how to reduce IO with rrdcached

Few weeks ago Munin was flooding me with message alerts about IO latency, read or write, going too high. Ironically it turned out Munin was the culprit. And the solution was to use rrdcached.

Lets see a Munin graph that shows pretty well the difference using rrdcached made:

sda-month

Around week 21, when I deployed this optimization, writes dropped quite a lot and reads stabilized.

Now follows the step-by-step guide to use rrdcached (with Gentoo).

Continue reading “Munin, how to reduce IO with rrdcached”

Backup MX for Mailman, with Exim

This week a hard disk from one of my servers broke. It has been replaced with just 3 minutes of downtime (kudos to OVH), and right now the RAID array is being rebuilt.

Since this is the first time this happens to me, and the server is running a production mailman service, I decided to take my time and set-up a backup MX server. This is how I did it.

Remember that I am using a Gentoo distribution, this may be slightly different in other distro. Continue reading “Backup MX for Mailman, with Exim”

Gentoo: How to use Munin to monitor Mailman

Update 31/12/2012: Now this is a bit simpler, since bug 448414 has been fixed.

Before we start with the step-by-step procedure to get the mailman plug-in working, lets recall how to test a munin plug-in:

$ sudo munin-run mailman
posts.value 24
members.value 21892

The output above is what you should get once the mailman plug-in is correctly set-up. Continue reading “Gentoo: How to use Munin to monitor Mailman”

Gentoo: How to debug Exim

If you have some problem with exim, and the logs are not enough, edit the /etc/conf.d/exim file, and add the debugging option (-d):

/etc/conf.d/exim
# Command-line options for running exim
EXIM_OPTS="-bd -q15m -d"

Then restart exim:

# /etc/init.d/exim restart

The exim daemon will not be detached from the console, the debug information will be printed to the standard output. Good luck!

Gentoo: the HForge overlay

Just updated the ebuilds for itools and ikaaro in the hforge overlay, so I thought this is a good time to document how to use the hforge overlay.

Layman with Git support

If you have not installed layman yet, you have to, with the git use flag:

/etc/portage/package.use
app-portage/layman git

Then emerge layman:

$ sudo emerge layman

Tell layman about the HForge overlay

Edit the /etc/layman/layman.cfg file:

/etc/layman/layman.cfg
overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml
https://raw.github.com/hforge/overlay/master/layman/list.xml

Add the HForge overlay

$ sudo layman -S
$ sudo layman -a hforge-overlay

Then edit the make.conf file:

/etc/make.conf
source /var/lib/layman/make.conf

Test by emerging itools

Now you can test for instance by emerging itools. First unmask the package:

/etc/portage/package.keywords
dev-python/itools ~amd64

Then emerge:

$ sudo emerge -p itools

Gentoo: Mailman with Nginx & Exim

UPDATE 2014-07-23: Forgot to give nginx access to mailman archives. Stop using sudo. Use service.

UPDATE 2012-12-10: the process has been simplified now that bug #37429 is fixed.

This is how I installed Mailman in a Gentoo server, using Nginx as the web server and Exim as the MTA.

Mailman

By default Mailman runs with the Apache user and group. First step is to configure Mailman so it runs with the Nginx user and group. To do so edit /etc/make.conf and add these lines:

/etc/make.conf
MAILMAN_CGIUID="nginx"
MAILMAN_CGIGID="nginx"

Now you can go ahead and emerge Mailman. Next comes to configure it.

Edit /etc/mailman/mm_cfg.py (replace the url and email hosts by yours):

/etc/mailman/mm_cfg.py
DEFAULT_URL_HOST = 'mailman.example.com'
DEFAULT_EMAIL_HOST = 'example.com'
# Let Mailman know that the MTA (Exim) needs no aliases setting
MTA = None

As the mailman user (add the cron jobs, create the site password, and add the main list):

# su - mailman

mailman $ crontab cron/crontab.in
mailman $ bin/mmsitepass
mailman $ bin/newlist mailman

Run mailman:

# rc-update add mailman default
# service mailman start

Nginx

The Mailman web interface works with the CGI interface. To get it working with Nginx start by emerging spawn-fcgi and fcgiwrap:

# emerge spawn-fcgi fcgiwrap

Create the configuration file and edit it:

# cd /etc/conf.d
# cp spawn-fcgi spawn-fcgi.fcgiwrap

These are the changes to the configuration file:

/etc/conf.d/spawn-fcgi.fcgiwrap
FCGI_SOCKET=/run/fcgiwrap.sock
FCGI_ADDRESS=
FCGI_PORT=
FCGI_PROGRAM=/usr/sbin/fcgiwrap
FCGI_USER=nginx
FCGI_GROUP=nginx

Now start the daemon:

# cd /etc/init.d
# ln -s spawn-fcgi spawn-fcgi.fcgiwrap
# rc-update add spawn-fcgi.fcgiwrap default
# service spawn-fcgi.fcgiwrap start

Now add the Nginx server configuration:

/etc/nginx/mailman.conf
server {
    listen 80;
    server_name mailman.example.com;
    root /usr/lib/mailman/cgi-bin;

    # Redirect
    location / {
        rewrite ^ /mailman/listinfo permanent;
    }

    location ~ ^/mailman(/[^/]*)(/.*)?$ {
        fastcgi_split_path_info ^/mailman/([^/]*)(.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/$1;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/run/fcgiwrap.sock-1;
    }

    location /mailman-icons {
        alias /usr/lib/mailman/icons;
    }

    location /pipermail {
        alias /var/lib/mailman/archives/public;
    }
}

Include the file into the main Nginx configuration file:

/etc/nginx/nginx.conf
include mailman.conf;

Add nginx to the mailman group, so it has access rights to the archive:

# gpasswd -a nginx mailman

And restart Nginx:

# service nginx restart

Exim

There is very good documentation on running Mailman with Exim: Using Exim 4 and Mailman 2.1 together.

The only thing I found missing from the docs is a reference to the mailman-loop address. Add an alias for mailman-loop to a routable address, edit the /etc/mail/aliases file, for example:

/etc/mail/aliases
mailman-loop: root