Sei sulla pagina 1di 4

Configuring High Availability Linux

Many Linux distributions ship with the heartbeat suite of software for setting up High Availability Linux. The Linux HA project has details and downloads for those who do not have it available for their system. This text addresses setting up a very simple HA Linux configuration using the configuration files versus a G ! or the "ML definition files.

Setup
The example setup will have two servers that serve up an apache webserver. #ne can have many other services assigned as well and shared data over $%& for example. %or instance' if the failover was for an apache server where htdocs was sitting on storage it could be li(e so)
mass storage/NFS/iSCSI/Fibre | server1:/mnt/htdocs server2:/mnt/htdocs

&imilarly a common mys*l db bac(end could be available or even more exotic tiered mys*l dbs + basically whatever the needs are. ,hat Linux HA can do is using a shared !- it can host the same !from any server in the cluster list. %or demonstration purposes' however' the apache servers root will have an index file with the actual hostname of the system + what should be observed is the index file contents will change after a failover but still be accessible via the shared IP. %ollowing are the hostnames and ipv. addresses that will be used) /01./23././4 prime 5sles// webserver6 /01./23././2 calc 5sles// webserver6 /01./23./.17 sigma 5ha address6

Installation & Test Setup


&u&8' 9edHat and :ebian all support the heartbeat pac(ages from the Linux HA project. &ince the example is &u&8 // the syntax is)
yast -i heartbeat

A basic apache server for the test is re*uired as well)


yast -i apache2

To illustrate the test' a simple page on each webserver with its hostname can be used and put into /srv/www/htdocs/index htm!)
"htm!#"head#"/head"body#prime"/body#"/htm!# "htm!#"head#"/head"body#ca!c"/body#"/htm!#

$ext + startup and set to start at boot the webservers 5run on both systems6)
service apache2 start ch$con%ig apache2 on

$ow time to test the systems separately with !ynx --d&mp)


' !ynx --d&mp prime prime ' !ynx --d&mp ca!c ca!c

Last and not least the hosts must be able to resolve to eachother by name. Host file entries wor( fine for this.

HA Configuration
;onfiguring the HA services is relatively simple. This configuration is very basic< three files are needed) /. =etc=ha.d=ha.cf) protocol' server options and servers. 1. =etc=ha.d=auth(eys) shared (eysfile >. =etc=ha.d=resources) resource definitions ha.cf %or the example setup the ha.cf file loo(s li(e the following)
deb&g%i!e /var/!og/ha-deb&g !og%i!e /var/!og/ha-!og !og%aci!ity !oca!( $eepa!ive 2 deadtime 1( &dpport )*+ bcast eth( node ca!c node prime

The above options are pretty straightforward< where the debuglog is' logfile' what level' tcp (eepalive in seconds' deadtime in between in seconds' what udp port' what interface to broadcast on then the nodes in the cluster. authkeys The documentation explains the various options but for this example there is one md4' so the auth(eys file has the following in it)
a&th 1 1 md, -)e(.a21.%cd)1%b*-1-.2ec,.b)--+,

The sum was generated by simply echoing a string and piping it to md,s&m. Also the auth(eys file must be read only root)
chmod ()(( a&th$eys

haresources The resources file dictates the shared address and services in init to startup 5or shutdown as the case may be6)
prime 1*2 1)- 1 2( apache2

The starting or primary server is put as the first argument. $ow the the configuration is done on the primary server + the exact same settings can be used on the secondary one.

Firing it p
&tarting up is pretty simple)

' ch$con%ig heartbeat on ' service heartbeat start Starting /igh-0vai!abi!ity services2((*/(./2,121:(+:2( INF3: 4 5eso&rce is stopped heartbeat6+(.17: 2((*/(./2,121:(+:2( in%o: 8ersion 2 s&pport: %a!se heartbeat6+(.17: 2((*/(./2,121:(+:2( in%o: 99999999999999999999999999 heartbeat6+(.17: 2((*/(./2,121:(+:2( in%o: 4 Con%ig&ration va!idated Starting heartbeat 2 ** 2

$ow a litmus test of the shared address)


' !ynx --d&mp 1*2 1)- 1 2( prime

Testing
Testing can be a little tric(y + the simplest way is to stop the heartbeat service on the active node and let the other one ta(e over' observe the log entries on the calc node)
I:addr6,1()7: 2((*/(./2,121:22:,, INF3: eva! 4 i%con%ig eth(:( 1*2 1)- 1 2( netmas$ 2,, 2,, 2,, ( broadcast 1*2 1)- 1 2,, I:addr6,(-*7: 2((*/(./2,121:22:,, INF3: S&ccess 5eso&rce;anager6,(()7: 2((*/(./2,121:22:,, 4 in%o: 5&nning /etc/init d/apache2 start mach1down6+*-(7: 2((*/(./2,121:22:,- in%o: 4 mach1down ta$eover comp!ete %or node prime heartbeat6+2+17: 2((*/(./2,121:22:(, <05N: node prime: is dead heartbeat6+2+17: 2((*/(./2,121:22:(, in%o: =ead node prime gave &p reso&rces heartbeat6+2+17: 2((*/(./2,121:22:(, in%o: 5eso&rces being ac>&ired %rom prime heartbeat6+2+17: 2((*/(./2,121:22:(, in%o: ?in$ prime:eth( dead harc6,2,-7: 2((*/(./2,121:22:() in%o: 5&nning /etc/ha d/rc d/stat&s stat&s heartbeat6,2,*7: 2((*/(./2,121:22:() in%o: 4 No !oca! reso&rces 6/&sr/share/heartbeat/5eso&rce;anager 4 !ist$eys ca!c7 to ac>&ire mach1down6,2-.7: 2((*/(./2,121:22:() in%o: 4 @a$ing over reso&rce gro&p 1*2 1)- 1 2( 5eso&rce;anager6,2127: 2((*/(./2,121:22:() 4 in%o: 0c>&iring reso&rce gro&p: prime 1*2 1)- 1 2( apache2 I:addr6,2+(7: 2((*/(./2,121:22:() INF3: 5&nning 3A mach1down6,2-.7: 2((*/(./2,121:22:(. 4 in%o: mach1down ta$eover comp!ete %or node prime

And a *uic( chec( with lynx)


' !ynx --d&mp 1*2 1)- 1 2( ca!c

$ote that once prime is bac( online that calc gives control bac()
5eso&rce;anager6,,1,7: 2((*/(./2,121:22:+2 in%o: 4 5e!easing reso&rce gro&p: prime 1*2 1)- 1 2( apache2 5eso&rce;anager6,,1,7: 2((*/(./2,121:22:+2 in%o: 4 5&nning /etc/init d/apache2 stop 5eso&rce;anager6,,1,7: 2((*/(./2,121:22:++ in%o: 4 5&nning /etc/ha d/reso&rce d/I:addr 1*2 1)- 1 2( stop I:addr6,,*27: 2((*/(./2,121:22:++ INF3: i%con%ig eth(:( down I:addr6,,.,7: 2((*/(./2,121:22:++ INF3: S&ccess

Su!!ary
The example shown here is very primitive' ideally there would be a dedicated nic on each machine for this function or a serial connection between them. Also the services are not exactly exotic but this should be enough to get a Linux HA setup off the ground.

Potrebbero piacerti anche