Vous êtes sur la page 1sur 5

What is this going to soIve?

Hardware FaiIures! We are going to have redundant hardware all over the place, if one goes down, another one will be
immediately ready for taking its place. Also, by using load sharing schemes, this is going to solve our High Usage! issue.
Balancing the load among every server on our "farm" will reduce the amount of HTTP request per server (but you already
fgured that out, right?).
Let`s set it up! Firstly, we`re not going to use a domain scheme (let`s keep it simple), make sure your /etc/hosts fle looks
exactly like the picture below on every machine:
Secondly, here is what you`re going to install (on a per-server basis):
That`s right. We are going to use a very handsome application named "heartbeat" as our frst level redundancy, it will be
responsible for keeping our HAProxy (our "Reliable, High Performance TCP/HTTP Load Balancer") redundant. Don`t you
agree that having only ONE load balancer means there`s a single point of failure? Well, redundancy is all about overthrowing
this statement, we shall never have a single point of failure, and that`s why we are not deploying a single HAProxy.
So. how does this "heartbeat" work? It is very simple, indeed. Look at our topology (frst picture). We`re setting up heartbeat
to monitor two servers, one of them is called "master" and the other one "slave", and they are constantly exchanging their
status information through eth1 (10.100.100.0/32), a dedicated point-to-point network. Basically, they tell each other: "I`m up!
I`m up! I`m up!." and whenever a node stop listening this, it will act as the new master by adopting what we call the "virtual
IP address" (or VIP). By the way, the VIP is the address that your user is going to use whenever he wants to reach the web
Linux: Building Basic High Availability Infrastructure for W... http://blog.romerojunior.com/linux/linux-building-basic-hig...
2 of 5 11/26/2013 06:12 PM
server. Check out the illustration on the right.
Setting up the heartbeat is easy, after the installation you will need to create those fles on both servers:
haproxy@haproxy-01.~$ cal 1elc1ha.d1ha.ci
Walchdo 1dev1Walchdo
lol1ie 1var1lo1ha-lo
debui1le 1var1lo1ha-debu
deadl1me 5
Warnl1me 10
1n1ldead 15
bcasl elh1
aulo_ia1lback on
node haproxy-01
node haproxy-02
haproxy@haproxy-02.~$ cal 1elc1ha.d1ha.ci
Walchdo 1dev1Walchdo
lol1ie 1var1lo1ha-lo
debui1le 1var1lo1ha-debu
deadl1me 5
Warnl1me 10
1n1ldead 15
bcasl elh1
aulo_ia1lback on
node haproxy-01
node haproxy-02
haproxy@haproxy-01.~$ cal 1elc1ha.d1aulhkeys
aulh 3
1 crc
2 sha1 passWord
3 md5 passWord
haproxy@haproxy-02.~$ cal 1elc1ha.d1aulhkeys
aulh 3
1 crc
2 sha1 passWord
3 md5 passWord
haproxy@haproxy-01.~$ cal 1elc1ha.d1haresources
haproxy-01 \
TPaddr..10.0.0.11241elh0
haproxy@haproxy-02.~$ cal 1elc1ha.d1haresources
haproxy-01 \
TPaddr..10.0.0.11241elh0
This must be enough, right? Yes, for the heartbeat. We need to set up HAProxy to share the load between our web servers.
After intalling HAProxy, you will notice a single confguration fle (/etc/haproxy/haproxy.cfg), and you should append the
following:
haproxy@haproxy-01.~$ cal 1elc1haproxy1haproxy.ci
#{.} Append lh1s lo lhe end oi lhe i1le.
l1slen php-clusler 10.0.0.1.80
mode hllp
slals enable
slals aulh adm1n.passWord
balance roundrob1n
opl1on hllpclose
opl1on iorWardior
cook1e JSESST0NT0 prei1x
server php-01 10.0.0.4.80 cook1e A check
server php-02 10.0.0.5.80 cook1e B check
haproxy@haproxy-02.~$ cal 1elc1haproxy1haproxy.ci
#{.} Append lh1s lo lhe end oi lhe i1le.
l1slen php-clusler 10.0.0.1.80
mode hllp
slals enable
slals aulh adm1n.passWord
balance roundrob1n
opl1on hllpclose
Linux: Building Basic High Availability Infrastructure for W... http://blog.romerojunior.com/linux/linux-building-basic-hig...
3 of 5 11/26/2013 06:12 PM

Vous aimerez peut-être aussi