Chapter 9. Install and Configure HA Proxy

The Tungsten Cluster Manager listens on port 8090 for API calls, so we configure the HA Proxy listener ports to not conflict with that.

There must be one frontend per cluster, so the first one starts with port 8091.

In the example below, we assign frontend port 8091 to the composite global, frontend port 8092 to the cluster east and frontend port 8093 to the cluster west.

It is imperative that there be one backend per cluster containing all nodes in that cluster. In the case of a composite, the backend should contain all nodes from all member clusters.

In the below example, backend east contains member nodes db1-3, backend west contains nodes db4-6 and backend global contains nodes db1-6.

NOTE: See haproxy.cfg in the examples directory for a more complete sample config to be used locally on a web server or jump host.

Install and prepare the HA Proxy install:

shell> sudo -i
shell> yum install haproxy
shell> cd /etc/haproxy/
shell> cp haproxy.cfg haproxy.cfg.orig

Edit /etc/haproxy/haproxy.cfg and define the services and associated hosts:

shell> vim /etc/haproxy/haproxy.cfg

frontend global
    bind *:8091
    default_backend             global

frontend east
    bind *:8092
    default_backend             east

frontend west
    bind *:8093
    default_backend             west

backend global
    balance     roundrobin
    server  db1 db1.yourdomain.com:8090 check
    server  db2 db2.yourdomain.com:8090 check
    server  db3 db3.yourdomain.com:8090 check
    server  db4 db4.yourdomain.com:8090 check
    server  db5 db5.yourdomain.com:8090 check
    server  db6 db6.yourdomain.com:8090 check

backend east
    balance     roundrobin
    server  db1 db1.yourdomain.com:8090 check
    server  db2 db2.yourdomain.com:8090 check
    server  db3 db3.yourdomain.com:8090 check

backend west
    balance     roundrobin
    server  db4 db4.yourdomain.com:8090 check
    server  db5 db5.yourdomain.com:8090 check
    server  db6 db6.yourdomain.com:8090 check

Configure start at boot:

shell> chkconfig haproxy on

Restart the HA Proxy service:

shell> service haproxy restart