DRBD Zimbra

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Howto: Highly available Zimbra cluster using Heartbeat and DRBD Submitted by mig5 on Wed, 27/08/2008 - 14:10 Tags:

clustering replication ig -a!ailability mys"l drbd eartbeat p p linu# sysadmin $imbra redundancy

PLEA E !"TE: This article is # years old$ % no longer use Zimbra$ Please don&t as' me to u(date or address any issues that the guide has) due to newer versions o* Zimbra that have been released since$ % don&t 'now what wor's+doesn&t wor') because % don&t use it$ % acce(t no res(onsibility *or anything that results by running any o* the commands in this guide$ % is morning & success'ully set up a clustered, ig a!ailability pair o' (imbra )*+,are !irtual- ser!ers, synced ,it ./0. and using 1eartbeat to 'ailo!er to t e secondary standby ser!er2 % is is a o,to t at tries to co!er 3all3 t e steps, as t ere seems to be a great series o' 1o,to4s on t e sub5ect t at in one ,ay or anot er, lea!e somet ing out ,it 4& am assuming you already )insert ser!ice ere- ,or6ing and ,ill not co!er t is4 clauses2 &n particular & ran into a 'e, small urdles ,it ./0. and ostnames and , atnot, so tried to document , at & needed to do to ma6e it ,or62 &n t is set up, & install .ebian 7tc 420 on a *+,are *+ using t e netinstall iso image, and along t e line )a'ter installing (imbra itsel'- & clone t e mac ine by copying its !md6 dis6 image to sa!e time and a!oid a!ing to duplicate too many steps2 &n t is o,to, t e one $imbra 4domain4 t at bot ser!ers belie!e t emsel!es to be is 4$imbra2yourdomain2com42 8ou4ll notice a bit o' ostname 'iddling 'rom time to time: t is is re"uired to 6eep (imbra appy at install time, and also later during ./0. con'iguration t ings c ange again2 &n t e end, t e t,o *+s are 4$imbra-14 and 4$imbra-24 ,it respecti!e &9s o' 1:221;821211 and 1:221;8212122 % e 4!irtual4 &9 o' 4$imbra2yourdomain2com4 is 1:221;8212102 1eartbeat con'igures , ic e!er ser!er is to ta6e o!er t e running o' (imbra ,it t is !irtual &9 as a !irtual et ernet inter'ace2 9lease replace $imbra2yourdomain2com, $imbra-1, $imbra-2 and t e &9 addresses to , ate!er suits your en!ironment2 1o,to ,- .irst ste(s / D! & edited t e .<S ser!er aut oritati!e 'or t e domain 4yourdomain2com4 )in my case, an internal .<S ser!er on t e same =><- to add t ese entries: $imbra &< > 1:221;821210 $imbra +? 10 $imbra $imbra-1 &< > 1:221;821211 $imbra-1 +? 10 $imbra-1 $imbra-2 &< > 1:221;821212 $imbra-2 +? 10 $imbra-2 as ,ell as t e re!erse 9%/ entries2 0- Debian %nstall / 1anual Partitioning & did a standard netinstall o' .ebian 7tc on t e $imbra-1 *+, but manually set up t e partitioning as 'ollo,s2

<ote t e lo, specs o' t ese mac ines, it ,as only a test a'ter all and not a production ser!er :/boot /de!/sda1 100+0 )primary- )bootable 'lag on/ /de!/sda5 @A0 )logical- )e#t@s,ap /de!/sda; 512+0 )logical)unmounted- /de!/sda7 150+0 )logical- )e#t@- B t is4ll be t e ./0. meta-dis6 )unmounted- /de!/sda8 7A0 )logical- )e#t@- B t is4ll be t e /opt partition used by ./0. <ote t at sda7 and sda8 are not mounted2 .ebian ,ill try to ,arn you about t is, but 5ust ignore t e ,arnings and continue ,it t e installation2 We ,ill let 1eartbeat mount t ese de!ices t roug /de!/drbd0 , en needed2 2- Remove e3im# &' you installed .ebian ,it a net,or6 mirror and 4Standard System4 c ec6ed in tas6sel, .ebian ,ill install e#im4 , ic ,e don4t ,ant since (imbra ,ill be using its 9ost'i# installation2 apt-get remo!e --purge e#im4 e#im4-base e#im4-con'ig e#im4-daemon-lig t #- %nstall e3tra (ac'ages % ese pac6ages are re"uired to install (imbra2 We also t ro, in ./0. 'or use later on2 apt-get install ntp ntpdate libc;-i;8; sudo libidn11 curl 'etc mail libgmp@c2 libe#pat1 libgetopt-mi#ed-perl lib#ml2 libstdcCC; libpcre@ libltdl@ ss drbd027-module-source drbd027-utils linu#- eaders-Duname -rD 4- Edit 5*udge- the hostname to 'ee( Zimbra ha((y %o install (imbra success'ully, ,e must tric6 t e ser!er into t in6ing it is t e 4real4 domain $imbra2yourdomain2com , ere in 'act it is $imbra-12 ec o $imbra2yourdomain2com E /etc/ ostname 6- Reboot the server reboot 7- 1ount +o(t We ,ill no, temporarily mount /de!/sda8 as /opt so t at ,e can do a (imbra installation2 mount -t e#t@ /de!/sda8 /opt 8- Download) e3tract and install Zimbra 9ollaboration uite 5"(en ource edition>t t e time o' ,riting, (FS ,as !ersion 520: and ,e are do,nloading t e Gpen Source 7dition .ebian pac62 cd /tmp/ ,get HIa re'JH ttp:// 2yimg2com/lo/do,nloads/5202:KA>/$cs5202:KA>K25@@2.70&><42022008081521521:2tg$H tarHE ttp:// 2yimg2com/lo/do,nloads/5202:KA>/$cs-5202:KA>K25@@2.70&><42022008222I/aE $#'! $cs5202:KA>K25@@2.70&><42022008081521521:2tg$ cd $cs-5202:KA>K25@@2.70&><42022008081521521: 2/install2s -l % is install s ould go o6 i' your ostname is set to $imbra2yourdomain2com2 (imbra ,ill alert you to a .<S +? record error, because t e +? record 'or $imbra2yourdomain2com points to t e !irtual &9 )1:221;821210- and not $imbra-14s &9 )1:221;821211- 2 % at4s o6, ,e ,ant it li6e t at, so ignore t e error and say 4<o4 to 4F ange domain4 or , ate!er t e "uestion is2 :- Remove Zimbra startu( scri(ts We ,ant to remo!e t e (imbra startup scripts because 1eartbeat ,ill be andling t e starting o' (imbra , en it needs to2 % is command ,ill probably ,or6: update-rc2d -' $imbra remo!e 0ut & did it t e long, and probably non-.ebian ,ay, because & ,as not t in6ing straig t: rm /etc/rc22d/S::$imbra rm /etc/rc@2d/S::$imbra rm /etc/rc42d/S::$imbra rm /etc/rc52d/S::$imbra ,;- 9hange hostname bac' *or DRBD) modi*y +etc+hosts <o, t at ,e a!e (imbra installed, ,e need to c ange t e ostname again to ma6e ./0. ,or62 <ote t at you can4t 5ust edit /etc/ osts and 'udge t e local ostname because ./0. is smarter and ,ill report a mismatc i' /etc/ ostname and /etc/ osts don4t agree2 ec o $imbra-1 E /etc/ ostname <onet eless ,e ,ill no, edit /etc/ osts and tell $imbra-1 t at it is also $imbra2yourdomain2com, and also t at t ere is a $imbra-2 at 1:221;821212 )alt oug t ere isn4t 5ust yet-2 8our /etc/ osts on $imbra-1 s ould no, loo6 li6e

t is: 127202021 $imbra2yourdomain2com local ost2localdomain local ost 1:221;821211 $imbra-1 $imbra2yourdomain2com 1:221;821212 $imbra-2 B % e 'ollo,ing lines are desirable 'or &9!; capable osts ::1 ip;-local ost ip;-loopbac6 'e00::0 ip;-localnet ''00::0 ip;-mcastpre'i# ''02::1 ip;-allnodes ''02::2 ip;-allrouters ''02::@ ip;-all osts ,,- hutdown and clone <imbra/, to ma'e a <imbra/0 >t t is point & cloned $imbra-14s !md6 image and created a $imbra-22 Edit (er comment: glossed o!er t is, but it seems pretty ob!ious, being a clone, it ,ill a!e t e same &9 etc as $imbra-12 %o ma6e $imbra-2 t e e"ui!alent o' $imbra-1, set its &9 to be 1:221;821212 instead o' $imbra-14s 1:221;821211 )you may a!e issues bringing up t e et inter'ace entirely until t at point, since it ,as a !irtual mac ine, edit /etc/net,or6ing/inter'aces 'rom ,it in t e *+,are Fonsole- and c ange t e ostname: ec o $imbra-2 E /etc/ ostname >nd edit t e osts 'ile to loo6 li6e t is: 127202021 $imbra2yourdomain2com local ost2localdomain local ost 1:221;821212 $imbra-2 $imbra2yourdomain2com 1:221;821211 $imbra-1 B % e 'ollo,ing lines are desirable 'or &9!; capable osts ::1 ip;-local ost ip;-loopbac6 'e00::0 ip;-localnet ''00::0 ip;-mcastpre'i# ''02::1 ip;-allnodes ''02::2 ip;-allrouters ''02::@ ip;-all osts ,0- Reboot both servers) install DRBD and con*igure Gn bot $imbra-1 and $imbra-2: cd /usr/src/ tar #!'$ drbd0272tar2g$ cd modules/drbd/drbd ma6e ma6e install m! /etc/drbd2con' /etc/drbd2con'2orig +a6e a ne, /etc/drbd2con' t at loo6s li6e t is: resource r0 L protocol FM incon-degr-cmd H alt -'HM startup L degr-,'c-timeout 120M B 2 minutes N dis6 L on-io-error detac M N net L N syncer L rate 10+M group 1M al-e#tents 257M N on $imbra-1 L de!ice /de!/drbd0M dis6 /de!/sda8M

address 1:221;821211:7788M meta-dis6 /de!/sda7O0PM N on $imbra-2 L de!ice /de!/drbd0M dis6 /de!/sda8M address 1:221;821212:7788M meta-dis6 /de!/sda7O0PM N N ,2- =et the *irst DRBD sync going Gn $imbra-1 and $imbra-2 modprobe drbd drbdadm up all &' you get a eap o' complaint about mispelt or mismatc ing ostnames, c ec6 t at you c anged t e ostnames on eac ser!er to t eir respecti!e $imbra-1/$imbra-2 ostname as per abo!e, and t at you did a reboot o' eac 2 Gt er,ise ,it no errors: Gn $imbra-1: drbdadm -- --do-, at-&-say primary all drbdadm -- connect all W en & ran t e 4connect all4 second command, & got some odd error about a ./0. c ild process t at couldn4t terminate2 &t ,as odd, because & didn4t get t at , en & set up 1> <QS using ./0. and 1eartbeat t e pre!ious day on ot er ser!ersR <onet eless, & ran: cat /proc/drbd >nd & could see t at t e syncing ,as ta6ing place bet,een t e t,o ser!ers nonet eless2 &t loo6ed somet ing li6e t is )stole t is output 'rom an <QS o,to but it loo6s li6e t is!ersion: 027220 )api:77/proto:74S*< /e!ision: 174@ build by Ia re'JHmailto:p ilSmescalHEp ilSmescalI/aE, 2005-01-@1 12:22:07 0: cs:SyncSource st:9rimary/Secondary ld:Fonsistent ns:1@441;@2 nr:0 d,:0 dr:1@4;7108 al:0 bm:2@;: lo:0 pe:2@ ua:22; ap:0 OJJE22222222222222P sync4ed: @21T )7000/71;8-+ 'inis : 1:14:1; speed: 2,;44 )2,204- U/sec 1: cs:Vncon'igured =et t is process run be'ore doing anyt ing else2 W at is appening is t at ./0. is syncing bot ser!ers data on /etc/sda82 Gn my 7 A0 partitions, t is too6 about 1 our )slo, *+s, could be 'aster or slo,er on yours-2 Wust 6eep running Dcat /proc/drbdD until you see t at t e progress is complete2 We4re almost t ereRR ,#- %nstall and con*igure Heartbeat Gn $imbra-1 and $imbra-2: apt-get install eartbeat 8ou4ll see some sort o' error a'ter t e pac6age is installed2 1eartbeat doesn4t install a a2c', aresources or aut 6eys 'ile by de'ault, you need to create t ese 'irst be'ore eartbeat ,ill run2 Gn $imbra-1 and $imbra-2, create t ese t ree 'iles: /etc/ eartbeat/ a2c' log'acility local0 6eepali!e 2 deadtime 20 B timeout be'ore t e ot er ser!er ta6es o!er bcast et 0 node $imbra-1 $imbra-2 B our t,o $imbra *+s autoK'ailbac6 on B !ery important or auto 'ailo!er ,on4t appen /etc/ eartbeat/ aresources $imbra-1 &9addr::1:221;821210/24/et 0 drbddis6::r0 Qilesystem::/de!/drbd0::/opt::e#t@ $imbra <ote t at t e abo!e de'ines t e primary node $imbra-1: do not c ange t is to $imbra-2 , en you ma6e t e 'ile on $imbra-22 % e last ,ord 4$imbra4 is not a typo 'or one o' t e ser!ers: t is tells 1eartbeat , at ser!ice to start , en it does its magic2 Qinally, create /etc/ eartbeat/aut 6eys on bot ser!ers % is 'ile needs an md5 string, , ic eac eartbeat daemon uses to aut enticate ,it t e ot er2 & ran a "uic6 p p

4ec o md5)Hmy pass,ordH-M to get an md5 string2 aut @ @ md5 yourrandommd5string 9rotect t e permissions o' aut 6eys 'ile on bot ser!ers: c mod ;00 /etc/ eartbeat/aut 6eys ,4- Reboot> >t t is point (imbra s ould 'ire up on $imbra-1 as normal2 .o a 4d' - 4 on $imbra-1 and you4ll see t e /de!/drbd0 de!ice as mounted /opt and i' you run i'con'ig, you4ll see t e et 0:0 entry t at contains t e !irtual &9 1:221;8212102 8ou s ould be able to !isit ttp://$imbra2yourdomain2com or ttp://1:221;821210 and see a ,or6ing (imbra system t at is running o'' o' $imbra-12 ,6- Test the *ailover S utdo,n $imbra-12 &' you tail -' /!ar/log/messages on $imbra-1 as it s uts do,n, you s ould see it release drbd and eartbeat, and running tail -' /!ar/log/messages on $imbra-2 ,ill s o, it pic6 up t e !irtual &9, mount /de!/drbd0 and 6ic6 o'' t e (imbra startup scripts2 W en t e startup scripts a!e 'inis ed, !isit ttp://$imbra2yourdomain2com 5ust li6e you did be'ore and e!eryt ing s ould appear to still be running, e#cept no, ,e4re running o'' $imbra-2R Qire up $imbra-1 again and it ,ill ta6e bac6 t e control 'rom $imbra-22 Fongratulations, you a!e automatic 'ailo!er and ig a!ailability o' your (imbra ser!iceR

Howto: Highly available Zimbra cluster using Heartbeat and DRBD % is morning & success'ully set up a clustered, ig a!ailability pair o' (imbra )*+,are !irtual- ser!ers, synced ,it ./0. and using 1eartbeat to 'ailo!er to t e secondary standby ser!er2 % is is a o,to t at tries to co!er 3all3 t e steps, as t ere seems to be a great series o' 1o,toXs on t e sub5ect t at in one ,ay or anot er, lea!e somet ing out ,it Y& am assuming you already )insert ser!ice ere- ,or6ing and ,ill not co!er t isX clauses2 &n particular & ran into a 'e, small urdles ,it ./0. and ostnames and , atnot, so tried to document , at & needed to do to ma6e it ,or62 O"rcode si$eJH150H lin6JHtrueHP ttp://,,,2p ilipla,lor2com/ o,to- ig ly-aZtbeat-and-drbd [ Flic6 lin6 to enroll2 <ormal .ata rates may apply2O/"rcodeP &n t is set up, & install .ebian 7tc 420 on a *+,are *+ using t e netinstall iso image, and along t e line )a'ter installing (imbra itsel'- & clone t e mac ine by copying its !md6 dis6 image to sa!e time and a!oid a!ing to duplicate too many steps2 &n t is o,to, t e one $imbra YdomainX t at bot ser!ers belie!e t emsel!es to be is Y$imbra2yourdomain2comX2 8ouXll notice a bit o' ostname 'iddling 'rom time to time: t is is re"uired to 6eep (imbra appy at install time, and also later during ./0. con'iguration t ings c ange again2 &n t e end, t e t,o *+s are Y$imbra-1\ and Y$imbra-2\ ,it respecti!e &9s o' 1:221;821211 and 1:221;8212122 % e Y!irtualX &9 o' Y$imbra2yourdomain2comX is 1:221;8212102 1eartbeat con'igures , ic e!er ser!er is to ta6e o!er t e running o' (imbra ,it t is !irtual &9 as a !irtual et ernet inter'ace2 9lease replace $imbra2yourdomain2com, $imbra-1, $imbra-2 and t e &9 addresses to , ate!er suits your en!ironment2 1o,to ,- .irst ste(s ? D! & edited t e .<S ser!er aut oritati!e 'or t e domain Yyourdomain2comX )in my case, an internal .<S ser!er on t e same =><- to add t ese entries: $imbra &< > 1:221;821210 $imbra +? 10 $imbra $imbra-1 &< > 1:221;821211 $imbra-1 +? 10 $imbra-1 $imbra-2 &< > 1:221;821212 $imbra-2 +? 10 $imbra-2 as ,ell as t e re!erse 9%/ entries2 0- Debian %nstall ? 1anual Partitioning & did a standard netinstall o' .ebian 7tc on t e $imbra-1 *+, but manually set up t e partitioning as 'ollo,s2 <ote t e lo, specs o' t ese mac ines, it ,as only a test a'ter all and not a production ser!er /boot /dev/sda1 100MB / /dev/sda5 3GB swap /dev/sda 51!MB ("nmo"nted) /dev/sda# 150MB dis* ("nmo"nted) /dev/sda+ #GB partition "sed by '(B' (primary) (bootable flag on) (logical) (ext3) (logical) (logical) (ext3) $ t%is&ll be t%e '(B' meta) (logical) (ext3) $ t%is&ll be t%e /opt

<ote t at sda7 and sda8 are not mounted2 .ebian ,ill try to ,arn you about t is, but 5ust ignore t e ,arnings and continue ,it t e installation2 We ,ill let 1eartbeat mount t ese de!ices t roug /de!/drbd0 , en needed2 2- Remove e3im#

&' you installed .ebian ,it a net,or6 mirror and YStandard SystemX c ec6ed in tas6sel, .ebian ,ill install e#im4 , ic ,e donXt ,ant since (imbra ,ill be using its 9ost'i# installation2 apt)get remove ))p"rge exim, exim,)base exim,)config exim,)daemon)lig%t #- %nstall e3tra (ac'ages % ese pac6ages are re"uired to install (imbra2 We also t ro, in ./0. 'or use later on2 apt)get install ntp ntpdate libc )i + s"do libidn11 c"rl fetc%mail libgmp3c! libexpat1 libgetopt)mixed)perl libxml! libstdc-- libpcre3 libltdl3 ss% drbd0.#)mod"le)so"rce drbd0.#)"tils lin"x)%eaders)/"name )r/ 4- Edit 5*udge- the hostname to 'ee( Zimbra ha((y %o install (imbra success'ully, ,e must tric6 t e ser!er into t in6ing it is t e YrealX domain $imbra2yourdomain2com , ere in 'act it is $imbra-12 ec%o 0imbra.yo"rdomain.com 1 /etc/%ostname 6- Reboot the server reboot 7- 1ount +o(t We ,ill no, temporarily mount /de!/sda8 as /opt so t at ,e can do a (imbra installation2 mo"nt )t ext3 /dev/sda+ /opt 8- Download) e3tract and install Zimbra 9ollaboration uite 5"(en ource edition>t t e time o' ,riting, (FS ,as !ersion 520: and ,e are do,nloading t e Gpen Source 7dition .ebian pac62 cd /tmp/ wget 2%ttp3//%.yimg.com/lo/downloads/5.0.45G6/0cs) 5.0.45G65!533.'7B869,.0.!00+0+15!15!14.tg02 tar 0xfv 0cs)5.0.45G65!533.'7B869,.0.!00+0+15!15!14.tg0 cd 0cs)5.0.45G65!533.'7B869,.0.!00+0+15!15!14 ./install.s% )l % is install s ould go o6 i' your ostname is set to $imbra2yourdomain2com2 (imbra ,ill alert you to a .<S +? record error, because t e +? record 'or $imbra2yourdomain2com points to t e !irtual &9 )1:221;821210- and not $imbra-1\s &9 )1:221;821211- 2 % atXs o6, ,e ,ant it li6e t at, so ignore t e error and say Y<oX to YF ange domainX or , ate!er t e "uestion is2 :- Remove Zimbra startu( scri(ts We ,ant to remo!e t e (imbra startup scripts because 1eartbeat ,ill be andling t e starting o' (imbra , en it needs to2 % is command ,ill probably ,or6: "pdate)rc.d )f 0imbra remove 0ut & did it t e long, and probably non-.ebian ,ay, because & ,as not t in6ing straig t: rm rm rm rm /etc/rc!.d/:440imbra /etc/rc3.d/:440imbra /etc/rc,.d/:440imbra /etc/rc5.d/:440imbra

,;- 9hange hostname bac' *or DRBD) modi*y +etc+hosts <o, t at ,e a!e (imbra installed, ,e need to c ange t e ostname again to ma6e ./0. ,or62 <ote t at you canXt 5ust edit /etc/ osts and 'udge t e local ostname because ./0. is smarter and ,ill report a mismatc i' /etc/ ostname and /etc/ osts donXt agree2 ec%o 0imbra)1 1 /etc/%ostname <onet eless ,e ,ill no, edit /etc/ osts and tell $imbra-1 t at it is also $imbra2yourdomain2com, and also t at

t ere is a $imbra-2 at 1:221;821212 )alt oug t ere isnXt 5ust yet-2 8our /etc/ osts on $imbra-1 s ould no, loo6 li6e t is: 1!#.0.0.1 14!.1 +.1.11 14!.1 +.1.1! 0imbra.yo"rdomain.com local%ost.localdomain local%ost 0imbra)1 0imbra.yo"rdomain.com 0imbra)! capable %osts

$ ;%e following lines are desirable for 8<v 331 ip )local%ost ip )loopbac* fe00330 ip )localnet ff00330 ip )mcastprefix ff0!331 ip )allnodes ff0!33! ip )allro"ters ff0!333 ip )all%osts

,,- hutdown and clone <imbra/, to ma'e a <imbra/0 >t t is point & cloned $imbra-1\s !md6 image and created a $imbra-22 Edit (er comment: glossed o!er t is, but it seems pretty ob!ious, being a clone, it ,ill a!e t e same &9 etc as $imbra-12 %o ma6e $imbra-2 t e e"ui!alent o' $imbra-1, set its &9 to be 1:221;821212 instead o' $imbra-1\s 1:221;821211 )you may a!e issues bringing up t e et inter'ace entirely until t at point, since it ,as a !irtual mac ine, edit /etc/net,or6ing/inter'aces 'rom ,it in t e *+,are Fonsole- and c ange t e ostname: ec%o 0imbra)! 1 /etc/%ostname >nd edit t e osts 'ile to loo6 li6e t is: 1!#.0.0.1 14!.1 +.1.1! 14!.1 +.1.11 0imbra.yo"rdomain.com local%ost.localdomain local%ost 0imbra)! 0imbra.yo"rdomain.com 0imbra)1 capable %osts

$ ;%e following lines are desirable for 8<v 331 ip )local%ost ip )loopbac* fe00330 ip )localnet ff00330 ip )mcastprefix ff0!331 ip )allnodes ff0!33! ip )allro"ters ff0!333 ip )all%osts ,0- Reboot both servers) install DRBD and con*igure Gn bot $imbra-1 and $imbra-2: cd /"sr/src/ tar xvf0 drbd0.#.tar.g0 cd mod"les/drbd/drbd ma*e ma*e install mv /etc/drbd.conf /etc/drbd.conf.orig +a6e a ne, /etc/drbd2con' t at loo6s li6e t is: reso"rce r0 = protocol >? incon)degr)cmd 2%alt )f2? start"p = degr)wfc)timeo"t 1!0? $ ! min"tes @ dis* = on)io)error detac%? @ net = @ syncer =

rate 10M? gro"p 1? al)extents !5#? @ on 0imbra)1 = device /dev/drbd0? dis* /dev/sda+? address 14!.1 +.1.113##++? meta)dis* /dev/sda#A0B? @ on 0imbra)! = device /dev/drbd0? dis* /dev/sda+? address 14!.1 +.1.1!3##++? meta)dis* /dev/sda#A0B? @ @ ,2- =et the *irst DRBD sync going Gn $imbra-1 and $imbra-2 modprobe drbd drbdadm "p all &' you get a eap o' complaint about mispelt or mismatc ing ostnames, c ec6 t at you c anged t e ostnames on eac ser!er to t eir respecti!e $imbra-1/$imbra-2 ostname as per abo!e, and t at you did a reboot o' eac 2 Gt er,ise ,it no errors: Gn $imbra-1: drbdadm )) ))do)w%at)8)say primary all drbdadm )) connect all W en & ran t e Yconnect allX second command, & got some odd error about a ./0. c ild process t at couldnXt terminate2 &t ,as odd, because & didnXt get t at , en & set up 1> <QS using ./0. and 1eartbeat t e pre!ious day on ot er ser!ersR <onet eless, & ran: cat /proc/drbd >nd & could see t at t e syncing ,as ta6ing place bet,een t e t,o ser!ers nonet eless2 &t loo6ed somet ing li6e t is )stole t is output 'rom an <QS o,to but it loo6s li6e t isversion3 0.#.!0 (api3##/proto3#,) :C9 (evision3 1#,3 b"ild by p%ilDmescalE !005)01)31 1!3!!30# 03 cs3:ync:o"rce st3<rimary/:econdary ld3>onsistent ns313,,1 3! nr30 dw30 dr313, #10+ al30 bm3!3 4 lo30 pe3!3 "a3!! AFF1..............B sync&ed3 3.1G (#000/#1 +)M finis%3 131,31 speed3 !E ,, (!E!0,) H/sec 13 cs3Inconfig"red

ap30

=et t is process run be'ore doing anyt ing else2 W at is appening is t at ./0. is syncing bot ser!ers data on /etc/sda82 Gn my 7 A0 partitions, t is too6 about 1 our )slo, *+s, could be 'aster or slo,er on yours-2 Wust 6eep running Dcat /proc/drbdD until you see t at t e progress is complete2 WeXre almost t ereRR ,#- %nstall and con*igure Heartbeat Gn $imbra-1 and $imbra-2: apt)get install %eartbeat 8ouXll see some sort o' error a'ter t e pac6age is installed2 1eartbeat doesnXt install a a2c', aresources or aut 6eys 'ile by de'ault, you need to create t ese 'irst be'ore eartbeat ,ill run2

Gn $imbra-1 and $imbra-2, create t ese t ree 'iles: /etc/ eartbeat/ a2c' logfacility local0 *eepalive ! deadtime !0 $ timeo"t before t%e ot%er server ta*es over bcast et%0 node 0imbra)1 0imbra)! $ o"r two 0imbra CMs a"to5failbac* on $ very important or a"to failover won&t %appen /etc/ eartbeat/ aresources 0imbra)1 8<addr3314!.1 +.1.10/!,/et%0 drbddis*33r0 Jilesystem33/dev/drbd033/opt33ext3 0imbra <ote t at t e abo!e de'ines t e primary node $imbra-1: do not c ange t is to $imbra-2 , en you ma6e t e 'ile on $imbra-22 % e last ,ord Y$imbraX is not a typo 'or one o' t e ser!ers: t is tells 1eartbeat , at ser!ice to start , en it does its magic2 Qinally, create /etc/ eartbeat/aut 6eys on bot ser!ers % is 'ile needs an md5 string, , ic eac eartbeat daemon uses to aut enticate ,it t e ot er2 & ran a "uic6 p p Yec o md5)]my pass,ord^-M to get an md5 string2 a"t% 3 3 md5 yo"rrandommd5string 9rotect t e permissions o' aut 6eys 'ile on bot ser!ers: c%mod 00 /etc/%eartbeat/a"t%*eys

,4- Reboot> >t t is point (imbra s ould 'ire up on $imbra-1 as normal2 .o a Yd' - X on $imbra-1 and youXll see t e /de!/drbd0 de!ice as mounted /opt and i' you run i'con'ig, youXll see t e et 0:0 entry t at contains t e !irtual &9 1:221;8212102 8ou s ould be able to !isit ttp://$imbra2yourdomain2com or ttp://1:221;821210 and see a ,or6ing (imbra system t at is running o'' o' $imbra-12 ,6- Test the *ailover S utdo,n $imbra-12 &' you tail -' /!ar/log/messages on $imbra-1 as it s uts do,n, you s ould see it release drbd and eartbeat, and running tail -' /!ar/log/messages on $imbra-2 ,ill s o, it pic6 up t e !irtual &9, mount /de!/drbd0 and 6ic6 o'' t e (imbra startup scripts2 W en t e startup scripts a!e 'inis ed, !isit ttp://$imbra2yourdomain2com 5ust li6e you did be'ore and e!eryt ing s ould appear to still be running, e#cept no, ,eXre running o'' $imbra-2R Qire up $imbra-1 again and it ,ill ta6e bac6 t e control 'rom $imbra-22

Zimbra 9luster on 9ent" 4$6 9ubblicato il 2; luglio 2011 da 'ast'ire _ 2 Fommenti ` Installazione ZIMBRA in cluster active/passive con DRBD/Heartbeat Hardware a disposizione: 1 IBM X365 con 2 processori Intel XEON MP 2. ! "#z$ 16"B ra% 1 IBM X365 con & processori Intel XEON MP 2$ ! "#z$ 12"B ra% 1 IBM '(&3!! con 1 arra) e 2 lo*ical dri+e: lo*ical dri+e 1!!"B opt,zi%-ra per director) -ase .opt.zi%-ra lo*ical dri+e 2!!"B store,zi%-ra per director) caselle di posta .opt.zi%-ra.store 'istri-/zione /tilizzata: 0entO( 5.6 32 -it 1/esta */ida tratta l2installazione in alta a33ida-ilit4 di 5i%-ra Networ6 6.!.13 32 -it. 0o%e distri-/zione 7 stato scelto di /tilizzare 0entos5.6$ c#e 7 piena%ente s/pportata da 5i%-ra. I so3tware /tilizzati per *estire l2alta a33ida-ilit4 del ser+izio sono in+ece '8B' e Heart-eat. Inizia%o con l2installazione di 0entO( 5.6$ il %io consi*lio 7 di installare escl/si+a%ente l2indispensa-ile$ sar4 poi necessario personalizzare alc/ne opzioni d/rante il processo di installazione. 92installazione andr4 o++ia%ente ese*/ita s/ entra%-i i nodi co%ponenti il cl/ster. I%postare /n indirizzo IP 9:N 3isso I%postare il no%e #ost %an/al%ente ;es. %ail.do%inio.co%< I%postare il *atewa) e il 'N( Personalizzare i pacc#etti da installare 'eselezionare t/tti i pacc#etti proposti nel -o= in alto$ sce*liere >0/sto%ize now? e andare a+anti (elezionare solo i se*/enti so3tware: :pplications Editors @e=tA-ased internet 'e+elope%ent 'e+elope%ent li-raries 'e+elope%ent tools 9e*ac) so3tware de+elope%ent Base s)ste% Base 9e*ac) so3tware s/pport

:l pri%o ria++io$ nelle i%postazioni di sic/rezza$ disa-ilitare il 3irewall e (e9in/=. 'isa-ilitare poi alc/ni ser+izi c#e +anno in con3litto con 5i%-ra. [root@web1 ~] c!"con#i$ sen%&ail o## [root@web1 ~] c!"con#i$ ip'tables o## [root@web1 ~] c!"con#i$ iptables o## Installare poi le dipendenze per 5i%-ra: [root@web1 ~] (u& install libtool)lt%l s(sstat co&pat)libst%c**)++ co&pat)libst%c**),-' [root@web1 ~] (u& up%ate Bare il re-oot del siste%a e %odi3icare il 3ile /etc/redhat-release ri%/o+endo la ri*a di de3a/lt e inserire >8ed Hat Enterprise 9in/= E( release 5 ;Na#ant Cpdate X<? ;senza le +ir*olette<$ D/esto ser+e per >in*annare? 5i%-ra poic#7 la +ersione 6 non p/E essere installata s/ 0entO(. Editare poi il 3ile /etc/sudoers co%%entando la ri*a >Default require tty]$ se non +iene co%%entata ci saranno pro-le%i d/rante l2installazione di zi%-raAldap. Editare il 3ile /etc/hosts inserendo l2ip locale c#e p/nta al no%e #ost ;i%portante per non *enerare errori d/rante la creazione di certi3icati<. Nel %io caso il 3ile .etc.#osts si presenta cosF:

[root@web1 ~] &ore /etc/!osts G 'o not re%o+e t#e 3ollowin* line$ or +ario/s pro*ra%s G t#at reD/ire networ6 3/nctionalit) will 3ail. 12 .!.!.1 local#ost.localdo%ain local#ost ::1 local#ost6.localdo%ain6 local#ost6 1H2.16I.!.11H %ail.do%inio.co% %ail we-1 1H2.16I.!.12! we-2 I./0A11AZI2.3 /41I0 D./ (e ci si tro+a dietro ad /n 3irewall$ 7 consi*lia-ile e33ett/are D/esta %odi3ica: [root@web1 ~] (u& install bin% bin%)c!root bin%)libs bin%)utils 0reare il 3ile /var/na&e%/c!root/etc/na&e%5con#

92IP da inserire in >3orwarders? de+e essere il 'N( ser+er p/--lico del nostro pro+ider. 0reare il 3ile /var/named/chroot/var/named/db.dominio.com ;sostit/ire ip,locale,ser+er con l2ip del ser+er 5i%-ra<

Editare il 3ile /etc/resolv5con# searc# do%inio.co% na%eser+er ip,locale,ser+er 0osF 3acendo noi stessi 3accia%o da 'N(. Baccia%o D/indi partire il ser+er 'N( [root@web1 ~] /etc/init5%/na&e% start [root@web1 ~] c!"con#i$ na&e% on Jeri3icare il corretto 3/nziona%ento con: [root@web1 ~] nsloo"up &ail5%o&inio5co& (er+er: %io,ip,locale :ddress: %io,ip,localeG53

Na%e: %ail.do%inio.co% :ddress: %io,ip,locale I%postare s/ccessi+a%ente co%e 'N( ser+er nei client D/esta %acc#ina$ in D/esto %odo i client potranno c#ia%are da -rowser il ser+er zi%-ra con il no%e #ost. Ese*/ire /n re-oot del siste%a e installare 5i%-ra: KrootL%ail t%pMG tar z=+3 zcsANE@NO8OA6.!.13,":,2H1I.8HE95.2!11!5131&!552.t*z KrootL%ail t%pMG cd zcsANE@NO8OA6.!.13,":,2H1I.8HE95.2!11!5131&!552 KrootL%ail zcsANE@NO8OA6.!.13,":,2H1I.8HE95.2!11!5131&!552MG ..install.s# A= l2opzione >A=? ser+e per indicare all2installer di non controllare lo spazio disponi-ile in .$ in D/anto 5i%-ra ric#iede c#e il 3iles)ste% contentente l2installazione a--ia al%eno 5"B disponi-ili. Nel %io caso #o creato la partizione . piP piccola di 5"B$ in D/anto 5i%-ra +err4 installato s/ /n 3iles)ste% residente s/lla (:N IBM '(&3!!. Installare t/tti i co%ponenti co%e proposti di de3a/lt e alla ric#iesta: @#e s)ste% will -e %odi3ied. 0ontin/eQ KNM R Inseria%o >R? e l2installazione partir4. Pri%a di scri+ere o*ni %odi3ica s/l ser+er sar4 necessario inserire la password di a%%inistrazione Pre%ere il tasto >+^ e poi sce*liere l2opzione >6]$ inserire la password di a%%inistrazione ;ser+ir4 per entrare in we- ad%in<. 'i*itare D/indi >,7^ e inserire il pat# del 3ile =%l contenente la licenza di 5i%-ra. 1/esto /lti%o passo non 7 necessario se si sta installando la +ersione Open (o/rce Edition ;O(E< di 5i%-ra. Pre%ere >r^ per tornare indietro e poi >a^ per sal+are le opzioni. 92installazione contin/er4 senza alc/n inter+ento dell2/tente. Per +eri3icare se t/tti i ser+izi siano online$ lo**arsi co%e /tente zi%-ra [root@web1 ~] su 8 zi&bra Jeri3ica stato dei ser+izi [zi&bra@web1 ~]9 z&control status Ora 7 possi+ile entrare in a%%inistrazione we- all2indirizzo #ttps:..no%e.do%inio.co%: ! 1 /ser: ad%inL%ail.do%inio.co% pwd: password,i%%essa,d/rante,installazione 5i%-ra di de3a/lt +iene installato con il do%inio /*/ale all2#ostna%e ;es. Lno%e.do%inio.co%<$ per i%postare /n do%inio senza il no%e #ost a**i/n*ere tra%ite il pannello di controllo a%%inistrazione /n n/o+o do%inio e creare *li /tenti. Nel caso in c/i si +i*lia ca%-iare no%e ad /n do%inio$ dalla s#ell dell2/tente zi%-ra ese*/ire il co%ando: [zi&bra@web1 ~]9 z&prov )l rena&eDo&ain &ail5%o&inio5co& %o&inio5co& [zi&bra@web1 ~]9 z&prov &c# zi&braDe#aultDo&ain.a&e %o&ainio5co& .203: 0a%-io password a%%inistrazione [zi&bra@web1 ~]9 z&prov sp a%&in@no&e5%o&inio5co& nuova;passwor% Ponendo il caso di a+ere /n disco a disposizione$ +isi-ile dal siste%a operati+o co%e de+ice .de+.sd-$ 7 per pri%a cosa necessario creare /na partizione di tipo 9JM s/l disco$ /tilizzando il co%ando 3dis6. [root@web1 ~] #%is" /%ev/s%b Il dispositi+o non contiene nS /na ta-ella delle partizioni 'O( +alida$ nS /na dis6la-el (/n$ ("I od O(B 0reazione di /na n/o+a dis6la-el 'O(. 9e %odi3ic#e ri%arranno %e%orizzate sola%ente 3ino a D/ando si decide di scri+erle. 'opodic#S$ o++ia%ente$ il conten/to precedente non potr4 essere rec/perato. @#e n/%-er o3 c)linders 3or t#is dis6 is set to 21II52. @#ere is not#in* wron* wit# t#at$ -/t t#is is lar*er t#an 1!2&$ and co/ld in certain set/ps ca/se pro-le%s wit#: 1< so3tware t#at r/ns at -oot ti%e ;e.*.$ old +ersions o3 9I9O<

2< -ootin* and partitionin* so3tware 3ro% ot#er O(s ;e.*.$ 'O( B'I(O$ O(.2 B'I(O< :ttenzione: il 3la* !T!!!! non +alido della ta-ella delle partizioni & +err4 corretto con w;rite< 0o%ando ;% per ric#ia%are la */ida<: p 'isco .de+.sd-: 1I!!.1 "B$ 1I!!123H 3632 -)te 255 #eads$ 63 sectors.trac6$ 21II52 c)linders Cnit4 U cilindri di 16!65 V 512 U I2252I! -)te 'ispositi+o Boot (tart End Bloc6s Id ()ste% 0o%ando ;% per ric#ia%are la */ida<: n :zione co%ando e estesa p partizione pri%aria ;1A&< p N/%ero della partizione ;1A&<: 1 Pri%o cilindro ;1A21II52$ prede3inito 1<: Ctilizzo del +alore prede3inito 1 Clti%o cilindro o Wsize o WsizeM o WsizeO ;1A21II52$ prede3inito 21II52<: Ctilizzo del +alore prede3inito 21II52 0o%ando ;% per ric#ia%are la */ida<: p 'isco .de+.sdc: 1I!!.1 "B$ 1I!!123H 3632 -)te 255 #eads$ 63 sectors.trac6$ 21II52 c)linders Cnit4 U cilindri di 16!65 V 512 U I2252I! -)te 'ispositi+o Boot (tart End Bloc6s Id ()ste% .de+.sd#1 1 21II52 1 5 H2I65IW I3 9in/= 0o%ando ;% per ric#ia%are la */ida<: t Partizione selezionata 1 0odice esadeci%ale ;di*itare 9 per elencare i codici<: Ie Modi3icato il tipo di siste%a della partizione 1 in Ie ;9in/= 9JM< 0o%ando ;% per ric#ia%are la */ida<: p 'isco .de+.sd-: 1I!!.1 "B$ 1I!!123H 3632 -)te 255 #eads$ 63 sectors.trac6$ 21II52 c)linders Cnit4 U cilindri di 16!65 V 512 U I2252I! -)te 'ispositi+o Boot (tart End Bloc6s Id ()ste% .de+.sd-1 1 21II52 1 5 H2I65IW Ie 9in/= 9JM 0o%ando ;% per ric#ia%are la */ida<: w 9a ta-ella delle partizioni 7 stata alterataX 0#ia%ata di ioctl;< per rile**ere la ta-ella delle partizioni. (incronizzazione dei disc#i in corso. (i procede D/indi con la creazione del p#)sical +ol/%e$ /tilizzando il co%ando p+create e dando co%e inp/t la partizione appena creata. [root@web1 ~] pvcreate /%ev/s%b1 E2 necessario D/indi creare il +ol/%e *ro/p$ dando in inp/t /n no%e a scelta e il de+ice da /tilizzare ;la partizione .de+.sd-1 creata in precedenza<. [root@web1 ~] v$create zi&bra;opt /%ev/s%b1 E2 ora *i/nto il %o%ento di creare i lo*ical +ol/%e$ /tilizzando il co%ando l+create. Jerranno creati d/e +ol/%i$ /no c#e +err4 s/ccessi+a%ente %ontato s/lla director) .opt e c#e conterr4 l2installazione di 5i%-ra$ piP /n secondo c#e +err4 /tilizzato co%e 3le=i-leA%etaAdis6 ;+edi .etc.dr-d.con3< da dr-d. [root@web1 ~] lvcreate )1 size )n lv1 zi&bra;opt ;i%postare size a piacere$ l2i%portante 7 lasciare al%eno IMB a disposizione del lo*ical +ol/%e per il 3le=i-leA%etaAdis6< [root@web1 ~] lvcreate )1 <M )n %rb%&eta)lv1 zi&bra;opt Installare ora il so3tware dr-d e il relati+o %od/lo del 6ernel: [root@web1 ~] (u& install "&o%)%rb%<,)4A3 %rb%<,)<5,5')1 : D/esto p/nto 7 necessario con3i*/rare le risorse dr-d nel 3ile .etc.dr-d.con3$ c#e alla 3ine delle %odi3ic#e si presenter4 cosF: [root@web1 ~] &ore /etc/%rb%5con# # # please have a a look at the example configuration file in # /usr/share/doc/drbd82/drbd.conf # global usage-count no! "

resource opt#$imbra protocol %! startup &fc-timeout '! degr-&fc-timeout (2'! " disk on-io-error detach! " # or panic) * net cram-hmac-alg +sha(,! shared-secret +sibttn2-.,! " # don/t forget to choose a secret for auth 0 syncer rate ('1! " on &eb( device /dev/drbd'! disk /dev/$imbra#opt/lv(! address (.2.(28.'.((.34488! flexible-meta-disk /dev/$imbra#opt/drbdmeta-lv(! " on &eb2 device /dev/drbd'! disk /dev/$imbra#opt/lv(! address (.2.(28.'.(2'34488! flexible-meta-disk /dev/$imbra#opt/drbdmeta-lv(! " " resource store#$imbra protocol %! startup &fc-timeout '! degr-&fc-timeout (2'! " disk on-io-error detach! " # or panic) * net cram-hmac-alg +sha(,! shared-secret +pass&ord5! " # don/t forget to choose a secret for auth 0 syncer rate ('1! " on &eb( device /dev/drbd(! disk /dev/$imbra#store/lv(! address (.2.(28.'.((.3448.! flexible-meta-disk /dev/$imbra#store/drbdmeta-lv(! " on &eb2 device /dev/drbd(! disk /dev/$imbra#store/lv(! address (.2.(28.'.(2'3448.! flexible-meta-disk /dev/$imbra#store/drbdmeta-lv(! " " In D/esto caso sono state create d/e risorse ;nel %io caso #o creato /n secondo +ol/%e *ro/p con all2interno /n lo*ical +ol/%e /tilizzando /n di+erso #ard dis6$ %a 7 possi-ile creare /n secondo lo*ical +ol/%e nello stesso +ol/%e *ro/p se si #a a disposizione /n solo #ard dis6<$ /na c#e +err4 /tilizzata per la director) di -ase di 5i%-ra .opt.zi%-ra ;reso/rce opt,zi%-ra< e /na c#e +err4 /tilizzata per la director) do+e +en*ono sal+ate le caselle di posta .opt.zi%-ra.store ;reso/rce store,zi%-ra<. E2 anc#e stata i%postata /na password ;%odi3icare il +alore del ca%po shared-secret<$ c#e +err4 /tilizzata dai de%oni dr-d dei nodi per a/tenticarsi. 'a notare c#e i de+ice l+% creati s/l nodo we-1 non sono a/to%atica%ente +isi-ili dal secondo nodo colle*ato alla (:N ;we-2<. E2 necessario D/indi ese*/ire i se*/enti co%andi per rendere +isi-ili i lo*ical +ol/%e anc#e s/l secondo nodo: [root@web, ~] pvscan [root@web, ~] v$scan [root@web, ~] lvscan [root@web, ~] v$c!an$e )a ( /%ev/zi&bra;opt [root@web, ~] v$c!an$e )a ( /%ev/zi&bra;store Ora +erranno creati i de+ice +irt/ali di dr-d ;secondo D/anto indicato ne 3ile .etc.dr-d.con3 saranno .de+.dr-d! e .de+.dr-d1<. Ese*/ire s/ entra%-i i nodi i se*/enti co%andi: [root@web1 ~] %rb%a%& create)&% opt;zi&bra [root@web1 ~] %rb%a%& create)&% store;zi&bra 'o+e opt,zi%-ra e store,zi%-ra sono i no%i delle risorse indicati in .etc.dr-d.con3. :++iare D/indi il ser+izio dr-d s/ entra%-i i nodi: [root@web1 ~] service %rb% start

[root@web, ~] service %rb% strart 'opo a+er creato i de+ice ed a+er atti+ato il ser+izio dr-d 7 necessario sincronizzare i disc#i dei nodi co%ponenti il cl/ster. Ese*/ire D/indi il co%ando di sincronizzazione ;(O9O s/l nodo c#e si ritiene il nodo pri%ario<$ /tilizzando se%pre l2/tilit) dr-dad%: [root@web1 ~] %rb%a%& = 8overwrite)%ata)o#)peer pri&ar( opt;zi&bra Jeri3icare la sicronizzazione dei disc#i /tilizzando il co%andi watc# e cat per a+ere il reload a/to%atico: [root@web1 ~] watc! )n 1 cat /proc/%rb% Clti%ata la sincronizzazione del pri%o disco$ ese*/ire la sincronizzazione del secondo: [root@web1 ~] %rb%a%& = 8overwrite)%ata)o#)peer pri&ar( store;zi&bra Cna +olta sincronizzati entra%-i i disc#i$ 7 possi-ile 3or%attarli: [root@web1 ~] &"#s5e>t+ /%ev/%rb%? [root@web1 ~] &"#s5e>t+ /%ev/%rb%1 Possia%o adesso testare il 3/nziona%ento dei de+ice .de+.dr-d! e .de+.dr-d1 ;i prossi%i co%andi incl/dono sola%ente il de+ice .de+.dr-d! e la risorsa opt,zi%-ra. (e$ co%e nel %io caso$ si opta per a+ere d/e de+ice ;.de+.dr-d! e .de+.dr-d1< e d/e risorse ;opt,zi%-ra e store,zi%-ra<$ i co%andi do+ranno essere ese*/iti per entra%-i: [root@web1 ~] &"#s5e>t /%ev/%rb%?@ &"%ir /rep%ata1: &ount /%ev/%rb%? /rep%ata1 creia%o dei dati s/l 3iles)ste%: [root@web1 ~] #or i in A1557B@%o %% i#C/%ev/zero o#C/rep%ata/#ile9i bsC1M countC1??@%one adesso spostia%o %an/al%ente il 3iles)ste% s/l secondo nodo: [root@web1 /] u&ount /rep%ata @ %rb%a%& secon%ar( opt;zi&bra [root@web, /] &"%ir /rep%ata @ %rb%a%& pri&ar( opt;zi&bra @ &ount /%ev/%rb%? /rep%ata [root@web, /] ls /rep%ata/ #ile1 #ile, #ile+ #ile6 #ile7 lost*#oun% Bene$ i dati sono +isi-ili anc#e s/l secondo nodo Y. adesso eli%inia%o e a**i/n*ia%o alc/ni 3ile : [root@web, /] r& /rep%ata/#ile, @ %% i#C/%ev/zero o#C/rep%ata/#ile' bsC1??M countC, (postia%o n/o+a%ente il 3iles)ste% s/l pri%o nodo: [root@web, /] u&ount /rep%ata/ @ %rb%a%& secon%ar( opt;zi&bra [root@web1 /] %rb%a%& pri&ar( opt;zi&bra @ &ount /%ev/%rb%? /rep%ata [root@web1 /] ls /rep%ata/ #ile1 #ile+ #ile6 #ile7 #ile' lost*#oun% O6$ 'r-d 3/nzionaX :ssic/ria%o c#e +en*a se%pre a++iato al -oot: [root@web1 ~] c!"con#i$ %rb% on [root@web, ~] c!"con#i$ %rb% on Possia%o adesso eli%inare le director) e i 3ile creati e s%ontare %an/al%ente il 3iles)ste%: [root@web1 /] r& )r# /rep%ata/D@ u&ount /rep%ata@ r& )r# /rep%ata[root@web, /] r& )r# /rep%ata/ 0reare adesso s/l pri%o nodo /na director) te%poranea do+e spostere%o l2installazione di 5i%-ra: [root@web1 ~] &"%ir /opt;save (toppia%o D/indi t/tti i ser+izi di 5i%-ra$ c#e in D/esto %o%ento non ci ser+ono. KrootLwe-1 ZMG ser+ice zi%-ra stop e spostia%o la director) di -ase di 5i%-ra nella director) te%poranea .opt,sa+e [root@web1 ~] &v /opt/zi&bra /opt;save (/l secondo nodo in+ece possia%o tranD/illa%ente eli%inare la director) di -ase di 5i%-ra: [root@web, ~] r& )r# /opt/zi&bra Installare ora il so3tware Heart-eat s/ entra%-i i nodi$ c#e ci per%etter4 di con3i*/rare e *estire il cl/ster. KrootLwe-1 ZMG )/% install #eart-eat KrootLwe-2 ZMG )/% install #eart-eat Per con3i*/rare Heart-eat 7 s/33iciente creare il 3ile .etc.#a.d.#a.c3$ c#e alla 3ine do+r4 presentarsi in D/esto %odo: KrootLwe-1 .MG cat .etc.#a.d.#a.c3 6eepali+e 2 deadti%e 3! warnti%e 1!

initdead 12! -cast et#! node we-1 node we-2 cr% )es 0reia%o poi il 3ile .etc.#a.d.a/t#6e)s ;con per%essi 6!! XXX<$ con il se*/ente conten/to: a/t# 1 1 s#a1 M)(ecret o++ia%ente >M)(ecret? 7 /na strin*a da %odi3icare con la password scelta. :++ia%o poi Heart-eat s/l nodo we-1 : KrootLwe-1 #a.dMG ser+ice #eart-eat start (tartin* Hi*#A:+aila-ilit) ser+ices: KOOM Osser+ia%o lo stato del cl/ster : KrootLwe-1 #a.dMG cr%,%on 8eplic#ia%o ora i 3ile #a.c3 e a/t#6e)s s/l nodo we-2 e a++ia%o #eart-eat s/llo stesso: KrootLwe-1 #a.dMG scp .etc.#a.d.#a.c3 .etc.#a.d.a/t#6e)s rootLwe-2:.etc.#a.d. KrootLwe-2 #a.dMG ser+ice #eart-eat start Jeri3ic#ia%o n/o+a%ente lo stato del cl/ster: UUUUU 9ast /pdated: Ned (ep 12 16:2!:3H 2!! 0/rrent '0: node1.centos.or* ;6c- 12e&A&e&3A&H-3AI2!!A&315d6-d 3I5< 2 Nodes con3i*/red. ! 8eso/rces con3i*/red. UUUUU Node: node1.)o/rdo%ain.or* ;6c- 12e&A&e&3A&H-3AI2!!A&315d6-d 3I5<: online Node: node2.)o/rdo%ain.or* ;36112aaeAIe2-A&!33AaeH3Ae53d&ac&d2 e<: online Per la con3i*/razione +era e propria delle risorse del cl/ster si p/E editare diretta%ente il 3ile =%l .+ar.li-.#eart-eat.cr%.ci-.=%l opp/re /tilizzare il so3tware #eart-eatA*/i. Installia%olo s/ entra%-i i nodi: KrootLwe-1 ZMG )/% install #eart-eatA*/i KrootLwe-2 ZMG )/% install #eart-eatA*/i Per ese*/ire il so3tware #eart-eatA*/i 7 necessario colle*arsi al nodo re%oto con ss# /tilizzando l2opzione >AX?$ c#e consente l2esportazione dell2a%-iente X11 e D/indi l2esec/zione di applicazioni *ra3ic#e. Cna +olta colle*ati al nodo re%oto$ ese*/ire il %ana*er di Heart-eat: KrootLwe-1 ZMG #-,*/i @ra%ite #eart-eatA*/i #o a**i/nto d/e nodi ;we-1 e we-2<$ /n *r/ppo di risorse ;*ro/p,si-t,we-<$ 5 risorse e /na >9ocations?$ /tilizzata per identi3icare il nodo pre3erito s/l D/ale 3are partire le risorse. 9e risorse a**i/nte sono: 1 risorsa di tipo >Ipaddr2? per l2indirizzo ip cl/sterizzato 1 risorsa di tipo >dr-ddis6? per la co%pati-ilit4 con '8B' 2 risorse di tipo >Biles)ste%? per i 3iles)ste% .opt.zi%-ra e .opt.zi%-ra.store 1 risorsa di tipo >zi%-ra? per lo script di start.stop di 5i%-ra :l ter%ine della con3i*/razione il 3ile .+ar.li-.#eart-eat.cr%.ci-.=%l appare cosF: Ecib $enerate%CFtrueF a%&in;epoc!CF?G !ave;Huoru&CFtrueF i$nore;%t%CF#alseF nu&;peersCF,G cib;#eature;revisionCF,5?G cc&;transitionCF,G %c;uui%CFIa-#a##7)7<c7)6b66) bIe<)+?b?--e#,#'6G epoc!CF6,7G nu&;up%ates CF1G cib)last)writtenCF/at Jul ,+ ?-:6':7I ,?11GK Econ#i$urationK Ecr&;con#i$K Ecluster;propert(;set i%CFcib)bootstrap)optionsFK EattributesK Envpair i%CFcib)bootstrap)options)%c)versionF na&eCF%c)versionF valueCF,515+)no%e:

77,+?7'1,7-11<+b1',<baa7bc'e-?+e?#1e,'a+G/K Envpair na&eCFlast)lr&)re#res!F i%CFcib)bootstrap)options)last)lr&)re#res!F valueCF1+116?I1',G/K E/attributesK E/cluster;propert(;setK E/cr&;con#i$K Eno%esK Eno%e i%CFIa-#a##7)7<c7)6b66)bIe<)+?b?--e#,#'6G una&eCFweb,G t(peCFnor&alFK Einstance;attributes i%CFno%es)Ia-#a##7)7<c7)6b66)bIe<)+?b?--e#,#'6GK EattributesK Envpair i%CFstan%b()Ia-#a##7)7<c7)6b66)bIe<)+?b?--e#,#'6G na&eCFstan%b(F valueCFo##F/K E/attributesK E/instance;attributesK E/no%eK Eno%e i%CFc-,'c%?6)c%6b)6ab+)<%I#)?7766cIc+#+aF una&eCFweb1G t(peCFnor&alFK Einstance;attributes i%CFno%es)c-,'c%?6)c%6b)6ab+)<%I#)?7766cIc+#+aFK EattributesK [n+pair idU?stand-)AcH26cd!&Acd&-A&a-3AId 3A!55&&c c333a? na%eU?stand-)? +al/eU?o33?.\ E/attributesK E/instance;attributesK E/no%eK E/no%esK EresourcesK E$roup i%CF$roup;sibt;webFK E&eta;attributes i%CF$roup;sibt;web;&eta;attrsFK EattributesK Envpair i%CF$roup;sibt;web;&etaattr;tar$et;roleF na&eCFtar$et;roleF valueCFstoppe%F/K Envpair i%CF$roup;sibt;web;&etaattr;or%ere%F na&eCFor%ere%F valueCFtrueF/K Envpair i%CF$roup;sibt;web;&etaattr;collocate%F na&eCFcollocate%F valueCFtrueF/K E/attributesK E/&eta;attributesK Epri&itive classCFoc#F t(peCFI4a%%r,G provi%erCF!eartbeatF i%CFresource;ip;zi&braFK Einstance;attributes i%CFresource;ip;zi&bra;instance;attrsFK EattributesK Envpair i%CFa-1ba%c1)I'b6)6bae)-+6,)#''-ab#7e6eIG na&eCFipF valueCF1-,51'<5?511<G/K E/attributesK E/instance;attributesK E&eta;attributes i%CFresource;ip;zi&bra;&eta;attrsFK EattributesK Envpair na&eCFtar$et;roleF i%CFresource;ip;zi&bra;&etaattr;tar$et;roleF valueCFstoppe%F/K E/attributesK E/&eta;attributesK E/pri&itiveK Epri&itive i%CFDRBD;%ataF classCF!eartbeatF t(peCF%rb%%is"F provi%erCF!eartbeatFK Einstance;attributes i%CFDRBD;%ata;instance;attrsFK EattributesK Envpair i%CF1'I%'+a+)#%77)6,,6)b1?-)#7beeI66+--1G na&eCF1G valueCFopt;zi&braF/K E/attributesK E/instance;attributesK E&eta;attributes i%CFDRBD;%ata;&eta;attrsFK EattributesK Envpair i%CFDRBD;%ata;&etaattr;tar$et;roleF na&eCFtar$et;roleF valueCFstarte%F/K E/attributesK E/&eta;attributesK E/pri&itiveK Epri&itive i%CFL/;opt;zi&braF classCFoc#F t(peCFLiles(ste&F provi%erCF!eartbeatFK Einstance;attributes i%CFL/;opt;zi&bra;instance;attrsFK EattributesK Envpair i%CF<e%'ecI6)1<#')6,6+)ab<-)#-6?167b1<a%F na&eCF%eviceF valueCF/%ev/%rb%?G/K [n+pair idU?H2& -d3aA2I- A&3 3AI1e5A6 H3 ee-61&] na%eU?director)? +al/eU?.opt?.\

Envpair i%CFb'1bIa6,)c#ae)6+7,)<?b#)6,,#+'',1'eeF na&eCF#st(peF valueCFe>t+G/K E/attributesK E/instance;attributesK E&eta;attributes i%CFL/;opt;zi&bra;&eta;attrsFK EattributesK Envpair i%CFL/;opt;zi&bra;&etaattr;tar$et;roleF na&eCFtar$et;roleF valueCFstarte%F/K E/attributesK E/&eta;attributesK E/pri&itiveK Epri&itive i%CFL/;store;zi&braF classCFoc#F t(peCFLiles(ste&F provi%erCF!eartbeatFK Einstance;attributes i%CFL/;store;zi&bra;instance;attrsFK EattributesK Envpair i%CF<?#'%<?a)?,,c)6?6+)bc<+)b#1#?ee-'1?,G na&eCF%eviceF valueCF/%ev/%rb%1G/K Envpair i%CF-'aI,e?<)6c1+)6e?+)a<6+)#I6I?66?7%,IG na&eCF%irector(F valueCF/opt/zi&bra/storeF/K Envpair i%CFa,-+Ie-b)1,?1)6eb<)<#a<)c%7c'<-<17a,G na&eCF#st(peF valueCFe>t+G/K E/attributesK E/instance;attributesK E&eta;attributes i%CFL/;store;zi&bra;&eta;attrsFK EattributesK Envpair i%CFL/;store;zi&bra;&etaattr;tar$et;roleF na&eCFtar$et;roleF valueCFstarte%F/K E/attributesK E/&eta;attributesK E/pri&itiveK Epri&itive i%CFzi&bra;lsbF classCFlsbF t(peCFzi&braF provi%erCF!eartbeatFK EoperationsK Eop i%CF+#<<-I,e)6,#,)6-a,)-c-I)%6eb+6c#<ce%F na&eCFstopF intervalCF?G ti&eoutCF-?G %isable%CF#alseF roleCF/toppe%F start;%ela(CF?G/K Eop i%CF7#+%+ea+)a?<-)6+<,)<6bI)<I6e6#ae1+e?G na&eCFstartF intervalCF?G ti&eoutCF1<?G %isable%CF#alseF roleCF/tarte%F start;%ela(CF?G/K E/operationsK E&eta;attributes i%CFzi&bra;lsb;&eta;attrsFK EattributesK Envpair i%CFzi&bra;lsb;&etaattr;tar$et;roleF na&eCFtar$et;roleF valueCFstarte%F/K E/attributesK E/&eta;attributesK Einstance;attributes i%CFzi&bra;lsbFK Eattributes/K E/instance;attributesK E/pri&itiveK E/$roupK E/resourcesK EconstraintsK Ersc;location i%CFruns;on;pre#er;no%eF rscCF$roup;sibt;webFK Erule i%CFpre#ere%;runs;on;pre#er;no%eF scoreCF1??GK Ee>pression attributeCF una&eF i%CF1cbI<I?,)a<<1)6a?a)<e,?)%b661<67ae%'G operationCFeHF valueCFweb,G/K E/ruleK E/rsc;locationK E/constraintsK E/con#i$urationK E/cibK #-,*/i in+ece presenta D/esta con3i*/razione:

Clti%ata la con3i*/razione del cl/ster ese*/ia%o il %o/nt del de+ice .de+.dr-d! s/lla director) .opt. KrootLwe-1 ZMG %o/nt .de+.dr-d! .opt 'ando il co%ando d3 do+re%%o +edere /n o/tp/t si%ile a D/esto: Kzi%-raLwe-2 ZM^ d3 Biles)ste% 1OA-loc6s Csed :+aila-le Cse_ Mo/nted on .de+.%apper.Jol"ro/p!!A9o*Jol!! &H516II &6&56& &231536 1!_ . .de+.%apper.Jol"ro/p!!A9o*Jol!3 HH!3&32 &2126I IH !HI& 5_ .+ar .de+.%apper.Jol"ro/p!!A9o*Jol!1 HH!3&32 15366& H23I5II 2_ .#o%e .de+.%apper.Jol"ro/p!!A9o*Jol!6 125H6&I 1I&22! 6 3H 22! 1_ ./ .de+.%apper.Jol"ro/p!!A9o*Jol!2 2& IH6&& 162 5&I 21II25!I _ ./sr .de+.%apper.Jol"ro/p!!A9o*Jol!& HH!3&32 11565&! I235 12 13_ .t%p .de+.sda1 1!1!I6 265&2 6H325 2I_ .-oot t%p3s 623 1 6 ! 623 1 6 !_ .de+.s#% .de+.dr-d! 1!2I!IIII 3&&222! H&1&&26I &_ .opt Possia%o +edere il de+ice .de+.dr-d! %ontato s/ .opt Ese*/ia%o adesso il %o+e della conten/to della director) .opt,sa+a s/lla director) .opt KrootLwe-1 ZMG %+ .opt,sa+e.zi%-ra .opt @er%inato il %o+e della director) s%ontia%o il 3iles)ste% .opt e cancellia%o la director) .opt.sa+e$ c#e non ser+er piP. KrootLwe-1 ZMG /%o/nt .opt KrootLwe-1 ZMG r% Ar3 .opt,sa+e Ora non resta c#e ria++iare #eart-eat s/ entra%-e le %acc#ine ed ese*/ire lo start delle risorse /tilizzando #-,*/i$ D/indi colle*arci alla /rl #ttps:..%ail.do%ain.co%: ! 1 per personalizzare la con3i*/razione di 5i%-ra.

1irror remoto con DRBD en Linu3 ./0. )Distri buted Replicated Block Device, drbd2org- permite mirror remoto en tiempo real )e"ui!alente a />&.-1 en red-, algo muy di'acil de conseguir con otros sistemas como rsync ya "ue bste no puede traba5ar en tiempo real por su consumo de memoria y F9V2 ./.0 crea un dispositi!o de blo"ues drbd0 accesible desde ambos ser!idores2 7l ser!idor primario es el "ue tiene acceso /W en el dispositi!o drbd0: cada !e$ "ue escribe algo en drbd0 lo escribe en la particicn 'asica y esos mismos datos se en!aan por %F9/&9 al ser!idor secundario )"ue sclo tiene acceso /G- consiguiendo "ue ambas particiones 'asicas estbn sincroni$adas, e#actamente igual "ue un />&.-12 *amos a !er un e5emplo con ./0., 1eart0eat y <QS para implementar almacenamiento compartido en un cluster =*S2 0uscamos tres cosas:

12 almacenamiento com(artido: para "ue todos los ser!idores ,eb de un cluster =*S con >pac e sir!an
los mismos datos e#portaremos el directorio /data/export mediante <QS para "ue lo monten los ser!idores reales del cluster2 22 tener una co(ia de los datos 5mirroring-: el contenido de drbd0 )/data- estard sincroni$ado mediante ./0. entre server1 y server22 @2 alta dis(onibilidad: usaremos 1eart0eat en los ser!idores ./.0 para acti!ar el secundario si el primario 'alla, consiguiendo de ese modo un almacenamiento de alta disponibilidad2

7l proceso para implementar mirror remoto con ./0. consta de los siguientes pasos:

12 22 @2 42 52

Fon'iguracicn inicial Fon'igurar ./0. Fon'igurar <QS Fon'igurar 1eart0eat >rrancar y comprobar

*eamos la con'iguracicn inicial de ser!er1 y ser!er22

a2 Particiones: particionaremos server1 y server2 de la siguiente manera:


/dev/sda1: /boot, primaria, e#t@, bootable2 /dev/sda5: /, lcgica, e#t@2 /dev/sda6: lcgica, s,ap2 /dev/sda7: 150 +0, unmounted, lcgica, e#t@ )contendrd los meta-datos de ./0.-2 /dev/sda8: unmounted, lcgica, e#t@ )contendrd el directorio /data-2 Atenci@n

/dev/sda7 y /dev/sda8 deben tener idbntico tamaeo en ambos ser!idores2 =os meta-datos de ./0. )logs de estado y de 'lu5o, al estilo de un 5ournal- necesitan 128 +0,
por lo "ue /dev/sda7 tendrd 150 +02

<o ay "ue montar ni /dev/sda7 ni/dev/sda82 7l instalador nos preguntard:


No a asi!nado "mount point" a la partici#n $7 de /dev/sda% &Desea re!resar al men' de particionado( /esponderemos No) continuar con el particionado2

b2 +etc+*stab: comprobaremos en ambos ser!idores "ue /dev/sda7 y /dev/sda8 no aparecen en /etc/*stab, "ue
debe ser similar a: # File_system /dev/sda5 /dev/sda1 /dev/sda proc /dev/%dc /dev/fd0 Mount_point / /boot none /proc /media/cdrom0 /media/floppy0 Type ext3 ext3 swap proc iso4 a"to Options defa"lts defa"lts sw defa"lts 0 roE"serEnoa"to rwE"serEnoa"to Dump 0 0 0 0 0 0 Pass 1 ! 0 0 0 0

c2 %nstalar un cliente !TP )pa"uete ntpdate-: conectaremos ambos ser!idores al mismo ser!idor <%9 para
asegurarnos de "ue tienen la misma ora del sistema )+,stem -ime-2 Su sinta#is es: $ ntpdate Kserver1 9ara comprobar la ora del sistema: $ date

*eamos la con'iguracicn de ./0.2

a2 com(ilar el m@dulo DRBD )pa"uetes drbd027-module-source drbd027-utils-: en ambos ser!idores


)necesitamos tambibn las 'uentes del 6ernel-: $ $ $ $ $ $ $ apt)get install *ernel)%eaders)!. .+)!)3+ apt)get install drbd0.#)mod"le)so"rce drbd0.#)"tils cd /"sr/src/ tar xvf0 drbd0.#.tar.g0 cd mod"les/drbd/drbd ma*e ma*e install

b2 cargar el m@dulo DRBD: en ambos ser!idores:


$ modprobe drbd

c2 +etc+drbd$con*: editar el arc i!o de con'iguracicn de ./0. )idbntico en ambos ser!idores-:


reso"rce r0 = protocol >; incon)degr)cmd 2%alt )f2; start"p =

degr)wfc)timeo"t 1!0; # 2 minutes @ dis* = on)io)error detac%; @ net = @ syncer = rate 10M; gro"p 1; al)extents !5#; @ on server1 = device /dev/drbd0; dis* /dev/sda+; address 14!.1 +. .1#!3##++; meta)dis* /dev/sda#A0B; @ on server! = device /dev/drbd0; dis* /dev/sda+; address 14!.1 +. .1#33##++; meta)dis* /dev/sda#A0B; @ @

d2 activar DRBD: en ambos ser!idores:


$ drbdadm "p all $ cat /proc/drbd version3 0.#.10 (api3##/proto3#,) :C9 (evision3 1#,3 b"ild by p%ilDmescalE !005)01)31 1!3!!30# 03 cs3>onnected st3:econdary/:econdary ld38nconsistent ns30 nr30 dw30 dr30 al30 bm315,+ lo30 pe30 "a30 ap30 13 cs3Inconfig"red *emos "ue ningfn ser!idor a sido con'igurado como primario )+econdar,/+econdar,- y "ue los datos son inconsistentes ).nconsistent-, ya "ue toda!aa no emos ec o la sincroni$acicn inicial2

e2 con*igurar el servidor (rimario: e5ecutaremos el siguiente comando en server1 para "ue sea el ser!idor
primario: $ drbdadm )) ))do)w%at)8)say primary all

'2 sincroni<aci@n inicial e5ecutaremos el siguiente comando en server1 para reali$ar la sincroni$acicn
inicial entre server1 y server2: $ drbdadm )) connect all .urard un buen rato, por lo "ue tendremos paciencia2 9ara !er el progreso de la sincroni$acicn: $ cat /proc/drbd version3 0.#.10 (api3##/proto3#,) :C9 (evision3 1#,3 b"ild by p%ilDmescalE !005)01)31 1!3!!30# 03 cs3:ync:o"rce st3<rimary/:econdary ld3>onsistent ns313,,1 3! nr30 dw30 dr313, #10+ al30 bm3!3 4 lo30 pe3!3 "a3!! AFFFFFFFFFF1.........B sync&ed3 53.1G (11 0 /!,#33)M finis%3 131,31 speed3 !E ,, (!E!0,) H/sec 13 cs3Inconfig"red Fuando termine la salida serd:

ap30

$ cat /proc/drbd :C9 (evision3 1#,3 b"ild by p%ilDmescalE !005)01)31 1!3!!30# 03 cs3>onnected st3<rimary/:econdary ld3>onsistent ns33#134 nr30 dw30 dr3,4035 al30 bm3 lo30 pe30 "a30 ap30 13 cs3Inconfig"red *eamos la con'iguracicn de <QS2

a2 instalar el servidor !. )pa"uete n's-6ernel-ser!er-: en ambos ser!idores:


$ apt)get install nfs)*ernel)server

b2 borrar los scri(ts de inicio de !. : <QS estard ba5o el control de 1eart0eat )"ue se encargard de
lan$arlo- por lo "ue borraremos los scripts de inicio de <QS en ambos ser!idores: $ "pdate)rc.d )f nfs)*ernel)server remove $ "pdate)rc.d )f nfs)common remove $ /etc/init.d/nfs)*ernel)server stop

c2 directorio a e3(ortar: en ambos ser!idores editaremos /etc/exports y aeadiremos una entrada para
e#portar /data/export )en este punto la particicn /dev/sda8 toda!aa estd !acaa y sin montar-: /data/export/ 14!.1 +. .0/!55.!55.!55.0(rwEno5root5sL"as%Esync)

d2 +var+lib+n*s: <QS almacena in'ormacicn importante )loc6s, etc2- en /var/lib/n*s2 Si server1 'alla server2 le
reempla$ard pero la in'ormacicn "ue server2 tiene en /var/lib/n*s serd di'erente de la "ue tenaa server12 9ara resol!er este problema !amos a almacenar la in'ormacicn de /var/lib/n*s en la particicn /dev/sda8 "ue estd sincroni$ada mediante ./0. entre server1 y server22 >sa, si server1 'alla server2 dispondrd de toda su in'ormacicn2 7n server1: $ $ $ $ $ $ m*dir /data mo"nt )t ext3 /dev/drbd0 /data mv /var/lib/nfs /data ln )s /data/nfs /var/lib/nfs m*dir /data/export "mo"nt /data

7n server2: $ m*dir /data $ rm )fr /var/lib/nfs $ ln )s /data/nfs /var/lib/nfs

*eamos la con'iguracicn de 1eart0eat2 &nstalaremos 1eart0eat en ambos ser!idores2 1eart0eat controla todo el asunto: lan$a y detiene <QS en ambos ser!idores, los monitori$a y acti!a el ser!idor secundario si el primario 'alla y se encarga de "ue el ser!idor <QS responda en la &9 !irtual )*&9- 1/2%168%6%1702

a2 instalar HeartBeat )pa"uete eartbeat-: en ambos ser!idores:


$ apt)get install %eartbeat

b2 +etc+heartbeat+ha$c*: crearemos este arc i!o idbntico en ambos ser!idores:


logfacility bcast et%0 *eepalive ! deadtime 10 node server1 node server! local0

c2 +etc+heartbeat+haresources: crearemos este arc i!o idbntico en ambos ser!idores:

server1 8<addr3314!.1 +. .1#,/!,/et%0 drbddis*33r0 Jilesystem33/dev/drbd033/data33ext3 nfs)*ernel)server 7n este arc i!o se especi'ica el nombre del ser!idor primario )server1-, la &9 !irtual )1/2%168%6%170-, el resource ./0. de'inido en /etc/drbd%con* )r0-, el dispositi!o ./0. )/dev/drbd0, /data, ext1- y el ser!idor a monitori$ar )n*s2kernel2server-2

d2 +etc+heartbeat+auth'eys: crearemos este arc i!o idbntico en ambos ser!idores:


a"t% 3 3 md5 mi5password >"ua de'inimos el mecanismo de autenti'icacicn )md5- y el pass,ord para "ue los dos demonios eartbeat de los ser!idores se autenti'i"uen uno contra el otro ) mi3pass4ord-2 Sclo root debe tener permisos de lectura sobre /etc/ eartbeat/aut ke,s por lo "ue aremos: $ c%mod 00 /etc/%eartbeat/a"t%*eys

9or fltimo, nos "ueda arrancar y comprobar2

a2 arrancar DRBD: en ambos ser!idores:


$ /etc/init.d/drbd start

b2 arrancar HeartBeat: en ambos ser!idores:


$ /etc/init.d/%eartbeat start

c2 com(robar la %P virtual: en server1:


$ ifconfig et%0 Min* encap37t%ernet NOaddr 0030>3!43613>534B inet addr314!.1 +. .1#! Bcast314!.1 +. .!55 Mas*3!55.!55.!55.0 inet addr3 fe+033!0c3!4ff3fea13c54b/ , :cope3Min* I< B(P6'>6:; (I9989G MIM;8>6:; M;I31500 Metric31 (Q pac*ets31+44! errors30 dropped30 overr"ns30 frame30 ;Q pac*ets3!,+1 errors30 dropped30 overr"ns30 carrier30 collisions30 txL"e"elen31000 (Q bytes3!#35++# (!. MiB) ;Q bytes3!+1140+# (! .+ MiB) 8nterr"pt31## Base address30x1,00 et%030 Min* encap37t%ernet NOaddr 0030>3!43613>534B inet addr314!.1 +. .1#, Bcast314!.1 +. .!55 Mas*3!55.!55.!55.0 I< B(P6'>6:; (I9989G MIM;8>6:; M;I31500 Metric31 8nterr"pt31## Base address30x1,00 Si acemos esto mismo en server2 no !eremos la &9 !irtual2

d2 com(robar los dis(ositivos montados: en server1:


$ df )% Jilesystem /dev/sda5 tmpfs /dev/sda1 /dev/drbd0 :i0e ,. G 1! M +4M !,G Ised 6vail IseG Mo"nted on ,30M ,.0G 10G / 0 1! M 0G /dev/s%m 11M #,M 13G /boot 33M !3G 1G /data

Si acemos esto mismo en server2 no !eremos /dev/drbd02

e2 simular el *allo de server,: creamos en server1 el arc i!o /data/export/test1 y simulamos el 'allo de
server1: $ to"c% /data/export/test1

$ /etc/init.d/%eartbeat stop > ora, si todo 'unciona, si e5ecutamos en server2: $ i*con*i!: !eremos la &9 !irtual 1/2%168%6%170 $ d* 2 : !eremos el dispositi!o /dev/drbd0 $ ls 2l /data/export: !eremos el arc i!o test1 )el mirror 'unciona-2

'2 simular Aue server, vuelve a estar en lBnea: !amos a comprobar "ue cuando server1 !uel!a a estar en
lanea es acti!ado como primario y recupera la &9 !irtual y el dispositi!o /dev/drbd02 Freamos en server2 el arc i!o /data/export/test2: $ to"c% /data/export/test! =e!antamos server1: $ /etc/init.d/%eartbeat start 7speramos unos segundos y, si todo 'unciona, si e5ecutamos en server1: $ i*con*i!: !eremos la &9 !irtual 1/2%168%6%170 otra !e$2 $ d* 2 : !eremos el dispositi!o /dev/drbd0 otra !e$2 $ ls 2l /data/export: !eremos el arc i!o test2 )el mirror 'unciona-2

g2 com(robar !. desde los clientes: para acceder desde los clientes a los datos e#portados mediante <QS
por server1 y server2 usaremos la &9 !irtual 1/2%168%6%170: $ mo"nt 14!.1 +. .1#,3/data/export /var/www 9ara montar el dispositi!o al arrancar editaremos /etc/*stab y aeadiremos una entrada: # File_system 14!.1 +. .1#,3/data/export Mount_point Type Options Dump Pass /var/www nfs rw 0 0

You might also like