When i connect to haproxy balancer and try execute every queries psql tell me:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
I repeat this command and now it works, but why?
When i use them direct on current base it works without errors, and reserve server got it
My configuration:
Main server: 192.168.8.201
keepalived for 192.168.8.210
haproxy
patroni
etcd
postgresql look for *:5432
Fail-over server: 192.168.8.202
keepalived for 192.168.8.210
haproxy
patroni
etcd(deep copy of previous, because onlye 2 machines, without changes on future)
postgresql look *:5432
Haproxy config:
global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 4s
timeout connect 4s
timeout server 4s
timeout check 5s
listen stats
mode http
bind *:7000
stats enable
stats uri /
listen batman
bind *:5000
option httpchk
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server postgresql_0 192.168.8.201:5432 maxconn 100 check port 8008
server postgresql_1 192.168.8.202:5433 maxconn 100 check port 8009