I have made a setup of multi-master replication of PostgreSQL using BDR (Bi-Directional Replication) among 4 nodes (virtual machines).
Now i want to put a load-balancer for High Availability. For this i have installed and configured "HAProxy" on a different virtual machine, which is listening over 5432/tcp to connect. The haproxy configuration is as follows:
listen pgsql_bdr *:5432
mode tcp
option httpchk
balance roundrobin
server master 192.168.123.1:5432 check backup
server slave1 192.168.123.2:5432 check
server slave2 192.168.123.3:5432 check
server slave3 192.168.123.4:5432 check
The ip address of HAProxy server is 192.168.123.5
I have use the IP address of HAproxy server in my application to connect with the database (that must redirect the connection to actual database servers). But at that time i am getting following error:
Error connecting to the server: server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request.
And note that i have try to resolve the problem using 2 manner. 1st I disabled the firewall on all servers (HAProxy and all postgres servers) and also i try to replace configuration with the following:
listen pgsql_bdr 0.0.0.0:5432
or
listen pgsql_bdr 127.0.0.1:5432
or
listen pgsql_bdr localhost:5432
But all was not working in my case.
Please help me to solve the problem. what i am doing wrong in this scenario?
Thanks in advance!