Configuring HAProxy software
Follow these steps to configure HAProxy for the HA setup.
Procedure
-
Edit the /etc/haproxy/haproxy.cfg file to add the following lines:
Where,global maxconn 100 defaults log global mode tcp retries 2 timeout client 30m timeout connect 4s timeout server 30m timeout check 5s listen prd_stats mode http bind *:<STATISTIC_PORT> stats enable stats uri / prd listen prd_postgres bind *:<posgresql_PORT> option httpchk http-check expect status 200 default-server inter 3s fall 3 raise 2 on-marked-down shutdown-sessions server POSTGRESQL_1 Node1_IP_address:5432 maxconn 100 check port 8008 server POSTGRESQL_2 Node2_IP_address:5432 maxconn 100 check port 8008 server POSTGRESQL_N NodeN_IP_address:5432 maxconn 100 check port 8008- Node1_IP_address, Node2_IP_address, NodeN_IP_address are the IP addresses or hostnames for the nodes that are running PostgreSQL instances.
- <STATISTIC_PORT>
The port where you want to see the cluster statistics.
- <POSTGRESQL_PORT>
The port where you want to listen the PostgreSQL connections.
- Save the file.