Installing a Web, Email & MySQL Database Cluster on Debian 8.4 Jessie with ISPConfig 3.1 - Page 5

This tutorial exists for these OS versions

On this page

  1. Sync Emails with Dovecot
  2. 9 Additional Notes
  3. 10 Links

8 Sync Emails with Dovecot

Since Dovecot 2 it`s possible to use Dovect's dsync to keep the main base in sync. If you have already mail's on server1, they will be replicated to server2 without any further interaction.

You must use the same port (4711) and the same password (replication_password) on both servers.

server1:

Open /etc/dovecot/dovecot-sql.conf

vi /etc/dovecot/dovecot-sql.conf

and enable the iterate_query:

old:

#iterate_query = SELECT email as user FROM mail_user

new:

iterate_query = SELECT email as user FROM mail_user

Open /etc/dovecot/dovecot.conf

vi /etc/dovecot/dovecot.conf

and add the following content:

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

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

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

service aggregator {
        fifo_listener replication-notify-fifo {
                user = vmail
                mode = 0666
        }

        unix_listener replication-notify {
                user = vmail
                mode = 0666
        }
}

service replicator {
        unix_listener replicator-doveadm {
                mode = 0666
        }
}

service doveadm {
        user = vmail
        inet_listener {
                port = 4711
        }
}

service config {
        unix_listener config {
                user = vmail
        }
}

# use tcp:ip as the dsync target
plugin {
        replication_full_sync_interval = 1 hours
        mail_replica = tcp:192.168.0.106:4711
}

protocol imap {
mail_plugins = quota imap_quota notify replication
}

restart Dovecot:

service dovecot restart

server2:

Open /etc/dovecot/dovecot-sql.conf

vi /etc/dovecot/dovecot-sql.conf

and enable the iterate_query:

old:

#iterate_query = SELECT email as user FROM mail_user

new:

iterate_query = SELECT email as user FROM mail_user

Open /etc/dovecot/dovecot.conf

vi /etc/dovecot/dovecot.conf

and add the following content:

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

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

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

service aggregator {
        fifo_listener replication-notify-fifo {
                user = vmail
                mode = 0666
        }

        unix_listener replication-notify {
                user = vmail
                mode = 0666
        }
}

service replicator {
        unix_listener replicator-doveadm {
                mode = 0666
        }
}

service doveadm {
        user = vmail
        inet_listener {
                port = 4711
        }
}

service config {
        unix_listener config {
                user = vmail
        }
}

# use tcp:ip as the dsync target
plugin {
        replication_full_sync_interval = 1 hours
        mail_replica = tcp:192.168.0.105:4711
}

protocol imap {
mail_plugins = quota imap_quota notify replication
}

restart Dovecot:

service dovecot restart

You can check the replication on each server:

doveadm replicator status '*'

username                                                                                priority fast sync full sync failed
[email protected]                                                                     none     00:16:34  00:16:40  -

9 Additional Notes

When you want to activate a firewall on the master or slave server, ensure that you open port 3306 for MySQL, 22 for SSH and 4711 for Dovecot on both servers.

Share this page:

5 Comment(s)

Add comment

Comments

From: sghazagh

Hi,

First of all, thank you. I have done the cluster setup as per your instruction on Ubuntu 16.0.4 for my ISPConfig servers and it works as perfectly as you explained. Database Master-Master replication and files syncronisation are working just fine.

However, I just thought I can use ISPConfig control panel on either of the servers but apparently I only have access to ISPConfig control panel on master server.If it is, what's the point of mirroing the server? in case the main server goes off, the second one cannot does the job.I also tried to login to emails from Roundcube on slave server, but that does not work either.May I kindly ask you to explain what is the applicaion for doing the cluster setup for ISPConfig on two servers?Can we set it up with the way that we can have same replicate of one server to another to use as backup server? I mean, use the slave server in case the master server goes offline or vise versa.I do appreciate your help in advance.

From: till

You should be able to use the ispconfig interface on both servers. Just ensure that you copied the file /usr/local/ispconfig/interface/lib/config.inc.php from master to the slave server (and redo that after an ispconfig update). When roundcube login is not working then there is an issue with the ispconfig connection between the servers. Please use the forum to get help to debug this.

From: sghazagh

Thanks till for your reply.

On page 3 of this instruction, it says:

Install ISPConfig Web Interface (y,n) [n]: <-- Hit Enter

How the interface works when we have not installed that on slave?At least I expect it should not work if the master is offline.Can you please let me know which forum is good to post this topic?Thanks again

 

From: Gwyneth Llewelyn

Thank you indeed. There are a few typos here and there, but nothing that someone with a little knowledge cannot fix (e.g. there is one tar command with duplicate parameters).

You might be pleased to know that your tutorial works pretty well with Ubuntu 16.04.1 LTS with MariaDB. The changes are really very small, and just related to the slightly different directories where Ubuntu stores its configurations (e.g. MariaDB has /etc/mysql/mariadb.conf.d/50-server.cnf instead of /etc/mysql/my.cnf).

From: dmgeurts

The currect ISPConfig 3.1 beat version (cluster install) now already enables iterate_query, but it has the string "WHERE service_id = '1'" attached.

Should this last statement be removed for Dovecot email sync, or should it be left as is?