Mails mit Dovecot über TCP syncen 7


Ich verwende auf meinen Servern ISPConfig, für IMAP und POP3 kommt Dovecot zum Einsatz. Mit Dovecot 2.x lassen sich die Mails auch zwischen zwei Servern synchron halten. Die Replikation erfolgt über die Dovecot Index-Files, so dass sich weder Fehler im Filesystem noch ein versehentlich gelöschtes Maildir negativ auswirken.

Ich beschreibe hier die Installation von Dovecot 2.x unter Debian Wheezy. Die Synchronisation erfolgt dabei über TCP (ssh ist zwar auch möglich, TCP ist aber mit weniger Aufwand einzurichten). Für andere Betriebsysteme finden sich die entsprechenden Repositores / Schritte hier.
echo "deb http://xi.rename-it.nl/debian/ stable-auto/dovecot-2.2 main" >> /etc/apt/sources.list

wget -O - http://xi.rename-it.nl/debian/archive.key | apt-key add -

apt-get update
apt-get upgrade

Damit ist Dovecot 2.x installiert. Überprüfen lässt sich die installierte Version mit
dovecot --version

Im nächsten Schritt muss Dovecot die Mailuser kennen, für die die Mails synchronisiert werden sollen. Die Datei /etc/dovecot/dovecot-sql.conf öffnen und den iterate_query aktivieren:

iterate_query = SELECT email as user FROM mail_user

Für die Synchronisation müssen noch verschieden Einträge in der Config vorgenommen werden. Die folgenden Erweiterungen werden alle in /etc/dovecot/dovecot.conf eingetragen.

# Enable the replication plugin globally
mail_plugins = $mail_plugins notify replication

# The mail processes need to have access to the replication-notify fifo and socket.
service aggregator {
  fifo_listener replication-notify-fifo {
    user = vmail
    mode = 0666
  }
  unix_listener replication-notify {
    user = vmail
    mode = 0666
  }
}

# Enable doveadm replicator commands
service replicator {
  unix_listener replicator-doveadm {
    mode = 0666
  }
}

# Create a listener for doveadm-server
service doveadm {
  user = vmail
  inet_listener {
    port = 12345
  }
}

# configure how many dsyncs can be run in parallel (10 by default)
replication_max_conns = 10

# tell doveadm client to use this port by default
doveadm_port = 12345

#Both the client and the server also need to have a shared secret
doveadm_password = secret

# use tcp:hostname as the dsync target
plugin {
  mail_replica = tcp:anotherhost.example.com # use doveadm_port
  #mail_replica = tcp:anotherhost.example.com:12345 # use port 12345 explicitly
}

service config {
  unix_listener config {
    user = vmail
  }
}

Danach kann dovecot neu gestartet werden.
/etc/init.d/dovecot restart

Ein paar Hinweise / Tipps zur Synchronisation:

Ausgabe des Status der Replikation:

doveadm replicator status

Die User in der Replication anzeigen:

doveadm replicator status '*'

Die Replikation für alle Mailboxen manuell starten:

doveadm sync -A tcp:anotherhost.example.com

Die Replikation für eine Mailbox manuell starten:

doveadm sync -u user@example.com tcp:anotherhost.example.com

Sieve-File
Das Sieve-File darf nicht unterhalb des Maildir-Verzeichnisses liegen, wenn es mit einem Punkt beginnt. Bei ISPConfig liegt .sieve bereits außerhalb des Maildirs – Änderungen sind also nicht erforderlich.


Hinterlasse einen Kommentar zu Florian Schaal Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

7 Gedanken zu “Mails mit Dovecot über TCP syncen

  • Jorge Canto

    Hello Florian, I just set up the replication between 2 servers following the steps on this tutorial and everything worked fine, those servers are running Dovecot 2.2.10; now I want to set up the replication between other 2 servers following the same steps but now the difference is that one of those servers is running dovecot 2.2.10 (Server B) and the other one is running 2.2.32 BUT on this server (Server A) the dovecot version was updated from 2.0.9 to 2.2.32, Server A has been working for almost 4 years (so it is not a new configuration) but I had to update dovecot to be able to replicate to Server B, I do not want to replicate every user from Server A to Server B so I set iterate_query to select only the users I want, but for some reason the replica service tries to replicate every user in the database, the weird thing is, on my dovecot-sql.conf.ext file I removed the iterate_query and the replication is still looking up users so it means (I think) the replicator service is reading the database from somewhere else and I would like to know where from, If I run the command “doveadm user ‘*’ ” I receive an error (obviuosly) ’cause there is not iterate_query set, but on the maillog file I can see replications tries to Server B, Do you have any suggestion?

    Thank you so much

    Jorge C.

  • Michael

    Hi Florian,

    danke für das HowTo.
    Die manuelle Synchronisation läuft problemlos.
    Allerdings synchronisieren meine beiden Server nur, wenn ich manuell den Befehl

    doveadm replicator replicate ‘*’

    eingebe.
    hast Du eine Idee, woran das liegen könnte?
    Mein Listing entspricht genau Deinem Listing (außer, dass ich andere Server und Passwörter benutze).

    Gruß, Michael

  • Micha

    Hallo Florian,

    eines ist mir nicht ganz klar: muss ich auf beiden Servern die dovecot.conf ändern? Und dann als mail_replica-Host jeweils
    den anderen eintragen?

    Trotzdem schon mal jetzt Danke fürs Teilen deiner Infos,

    Micha

  • wynni

    Hallo Florian,

    habe deine Anleitung erfolgreich nachbauen können. Vielen Dank dafür.
    Ich habe nur noch eine Frage:
    Wie sieht es mit den sync Zeiten aus. Wann wird ein fast sync bzw. full sync durchgeführt?

    Danke

    wynni