multiple / backup sql servers for sql server access

Jack Snodgrass jack at
Tue Aug 30 22:10:45 UTC 2022

I prefer to use a 2 db approach where I specify 2 different Database 
servers as opposed to HAproxy.

I see on: where it 

*You can add multiple host parameters to the SQL connect string. Dovecot 
will do round robin load balancing between them. If one of them goes 
down, the others will handle the traffic.*

it would be really nice if that was expanded opon in the docs.... I am 
not sure WHO to ask that that be clarified.

I currently have:

connect = "host=<dbserver> dbname=<dbname> user=<dbuser> password=<dbpass>"

... would I use:

connect = "host=<dbserver> dbname=<dbname> user=<dbuser> 
password=<dbpass> host=<dbserver2> dbname=<dbname2> user=<dbuser2> 

and the system would just see host/host, dbname/dbname user/user 
password/password and automatically map the correct dbname/user/password 
to the correct host or it is assumed that the 2nd host is the only thing 
that changes and the dbname/user/password are the same? or do I use:

connect = "host=<dbserver> dbname=<dbname> user=<dbuser> 
password=<dbpass> host2=<dbserver> dbname2=<dbname> user2=<dbuser> 

to specify the host and host2 info?

"You can add multiple host parameters to the SQL connect string." is a 
bit lacking in info when you think about the possibility of having a 
different user/pass or dbname for the 2nd host instance.

I am going to play around with this on my production box... but having a 
bit more info in the docs would be preferred.

- jack

On 8/30/22 07:57 AM, Brendan Kearney wrote:
> per 
> you can add more than one "host=" parameter in the "connect" 
> directive, and leave dovecot to do round-robin load balancing. there 
> will probably be a delay in processing while a failed database 
> connection attempt times out.
> or you can use a load balanced database footprint, using something 
> like haproxy.  its not as simple as putting multiple databases behind 
> haproxy and calling it done.  i use mariadb, which via galera, can do 
> multi-primary HA, where all 3 primary instances can take write or read 
> events.  you need to configure each mariadb instance with galara 
> replication and then setup haproxy to properly attach to the databases 
> and perform a service check.
> postgresql or other databases may require different mechanisms to 
> achieve fault tolerant HA.
> On 8/30/22 4:18 AM, Sami Ketola wrote:
>>> On 30. Aug 2022, at 5.13, Jack Snodgrass <jack at> wrote:
>>> I am using this file:
>>> dovecot-sql.conf.ext
>>> and in there  I have a
>>> connect = "host=<dbserver> dbname=<dbname> user=<dbuser> 
>>> password=<dbpass>"
>>> My <dbserver> was down and I lost mail access for a few days before 
>>> I realized that there was an issue.  How can I specify a backup 
>>> server so that if my primary sql server goes down, a backup sql 
>>> server will be queried?
>> Use haproxy.
>> Sami
jack - Southlake Texas - <>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the dovecot mailing list