I have configuration in haproxy to connect to two standby database servers (postgresql) in roundrobin fashion on one DB server I have configured pgbouncer with port 6432 and other database with db port 5432 but the haproxy always connects with 5432 port but when I manually connect with port 6432 I can from haporxy IP
PFA the haproxy config file:
[postgres@testbed06 haproxy]$ cat /etc/haproxy/haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
#chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-ciphers PROFILE=SYSTEM
ssl-default-bind-options no-sslv3
defaults
log global
option dontlognull
timeout connect 5000ms
timeout client 5m # 10 minutes
timeout server 5m # 10 minutes
# timeout client-fin 10s
# timeout server-fin 10s
Stats configuration
listen stats
# Set mode to HTTP
mode http
# Bind to port 8080
bind *:8080
# Enable stats
stats enable
# Stats URI
stats uri /
Frontend for write operations on port 5000
frontend postgresql_write
bind 10.114.16.50:5000
mode tcp
option tcplog
Route all traffic to the write backend
default_backend write_backend
Frontend for read operations on port 5001
frontend postgresql_read
bind 10.114.16.50:5001
mode tcp
option tcplog
# Route all traffic to the read backend
default_backend read_backend
Backend for write operations (primary node)
backend write_backend
mode tcp
option tcp-check
default-server inter 3s fall 3 rise 2
server primary_node 10.114.16.28:5432 check
Backend for read operations (secondary nodes)
backend read_backend
mode tcp
option tcp-check
balance roundrobin
default-server inter 3s fall 3 rise 2
server secondary_node1 10.114.16.33:6432 check
server secondary_node2 10.114.16.34:5432 check