NFS – Dovecot Wiki

NFS

NFS is commonly used in one of these ways:

  1. Dovecot is run in a single computer.
  2. Dovecot is run in multiple computers, users are redirected more or less randomly to different computers.
  3. Dovecot is run in multiple computers, each user is assigned a specific computer which is used whenever possible.

The only way to reliably implement the 2nd setup is with the director service.

Dovecot configuration

Single Dovecot server setup or Dovecot director cluster setup:

mmap_disable = yes
#dotlock_use_excl = no # only needed with NFSv2, NFSv3+ supports O_EXCL and it's faster
mail_fsync = always
mail_nfs_storage = no
mail_nfs_index = no

Multi-server setup that tries to flush NFS caches (increases NFS operations, and isn’t fully reliable), try not to use this:

mmap_disable = yes
#dotlock_use_excl = no # only needed with NFSv2, NFSv3+ supports O_EXCL and it's faster
mail_fsync = always
# These settings slow things down and don't fully work, use director proxy instead:
mail_nfs_storage = yes
mail_nfs_index = yes

Common issues

Clock synchronization

Run ntpd in the NFS server and all the NFS clients to make sure their clocks are synchronized. If the clocks are more than one second apart from each others and multiple computers access the same mailbox simultaneously, you may get errors.

NFS caching problems

NFS caching is a big problem when multiple computers are accessing the same mailbox simultaneously. The best fix for this is to prevent it from happening. Configure your setup so that a user always gets redirected to the same server (unless it’s down). This also means that mail deliveries must be done by the same server, or alternatively it shouldn’t update index files.

Dovecot flushes NFS caches when needed if you set mail_nfs_storage=yes, but unfortunately this doesn’t work 100%, so you can get random errors.

Disabling NFS attribute cache helps a lot in getting rid of caching related errors, but this makes the performance MUCH worse and increases the load on NFS server. This can usually be done by giving actimeo=0 or noac mount option.

Index files

If you keep the index files stored on NFS, you’ll need to set mmap_disable=yes. If you’re not running lockd you’ll have to set lock_method=dotlock, but this degrades performance. Note that some NFS installations have problems with lockd. If you’re beginning to get all kinds of locking related errors, try if the problems go away with dotlocking.

With mbox/Maildir formats (but not dbox!) it’s also possible to store index files on local disk instead of on NFS. If the user gets redirected to different servers, the local indexes are automatically created/updated. If the user is (nearly) always redirected to the same server this should be fine and you would likely get higher performance than indexes stored on NFS, but if the server changes it can be slow to recreate the index/cache files.

Source: NFS – Dovecot Wiki

NFS – Dovecot Wiki was last modified: June 30th, 2020 by Jovan Stosic

Leave a Reply