To load balance RDBMS like MYSQL and Oracle, you cannot use
http as haproxy protocol.
Therefore you need to change the protocol from http to tcp.
We can do this by changing default mode to tcp.
Or we can mention protocol in frontends and backends like
below,
frontend http-in
bind *:<listening Port> #database listening port
option tcplog
mode tcp
default_backend db_backend
backend db_backend
mode tcp
balance source
server db1 <db server1 IP>:<your port> check #change with your IP and port
server db2 <db server2 IP>:<your port> check #change with your IP and port
listen stats *:8080
stats enable
stats scope http-in
stats scope db_backend
stats uri /haproxy?stats
stats hide-version
stats auth haproxy:stats
That’s all. Now restart haproxy service,