在linux下做双机热备步骤精.docx
《在linux下做双机热备步骤精.docx》由会员分享,可在线阅读,更多相关《在linux下做双机热备步骤精.docx(16页珍藏版)》请在冰点文库上搜索。
在linux下做双机热备步骤精
在linux下做双机热备步骤
Redhat9linux的双机热备安装比较简单,需要的安装文件有以下几个:
heartbeat-1.0.4-2.rh.9.um.1.i386.rpm
heartbeat-pils-1.0.4-2.rh.9.um.1.i386.rpm
heartbeat-stonith-1.0.4-2.rh.9.um.1.i386.rpm
net-snmp-5.0.6-17.i386.rpm
按顺序依次安装:
1、heartbeat-pils-1.0.4-2.rh.9.um.1.i386.rpm
2、net-snmp-5.0.6-17.i386.rpm
3、heartbeat-stonith-1.0.4-2.rh.9.um.1.i386.rpm
4、heartbeat-1.0.4-2.rh.9.um.1.i386.rpm
#rpm-ivhheartbeat-pils-1.0.4-2.rh.9.um.1.i386.rpm
#rpm-ivhnet-snmp-5.0.6-17.i386.rpm
#rpm-ivhheartbeat-stonith-1.0.4-2.rh.9.um.1.i386.rpm
#rpm-ivhheartbeat-1.0.4-2.rh.9.um.1.i386.rpm
安装完成之后,开始配置主服务器。
配置文件位于/etc/ha.d下,用rpm安装之后不会产生配置文件,需要从/usr/share/doc/heartbeat-1.0.4下,把ha.cf,,,,authkeys,,,,,,,,haresources,,,,三个文件cp到/etc/ha.d下面。
文件在ha.cf是主要heartbeat的配置文件,authkeys是heartbeat的安全配置文件,haresource文件是heartbeat的资源文件
其文件说明如下:
ha.cf
#############################################################################################
#
#Therearelotsofoptionsinthisfile.Allyouhavetohaveisaset
#ofnodeslisted{"node...}
#andoneof{serial,bcast,mcast,orucast}
#
#ATTENTION:
Astheconfigurationfileisreadlinebyline,
#THEORDEROFDIRECTIVEMATTERS!
#
#Inparticular,makesurethatthetimingsandudpport
#etalaresetbeforetheheartbeatmediaaredefined!
#Allwillbefineifyoukeepthemorderedasinthis
#example.
#
#
#Noteonlogging:
#Ifanyofdebugfile,logfileandlogfacilityaredefinedthenthey
#willbeused.Ifdebugfileand/orlogfilearenotdefinedand
#logfacilityisdefinedthentherespectivelogginganddebug
#messageswillbelogedtosyslog.Iflogfacilityisnotdefined
#thendebugfileandlogfilewillbeusedtologmessges.If
#logfacilityisnotdefinedanddebugfileand/orlogfilearenot
#definedthendefaultswillbeusedfordebugfileandlogfileas
#requiredandmessageswillbesentthere.
#
#Filetowritedebugmessagesto
debugfile/var/log/ha-debug【heartbeat的debug信息记录文件】
#
#
#Filetowriteothermessagesto
#
logfile/var/log/ha-log【日志文件】
#
#
#Facilitytouseforsyslog()/logger
#
logfacilitylocal0【记录日志在syslog中,可选项】
#
#
#Anoteonspecifying"howlong"timesbelow...
#
#Thedefaulttimeunitisseconds
#10meanstenseconds
#
#Youcanalsospecifytheminmilliseconds
#1500msmeans1.5seconds
#
#
#keepalive:
howlongbetweenheartbeats?
#
keepalive3【每3秒发送一次keeplive消息】
#
#deadtime:
howlong-to-declare-host-dead?
#
deadtime15【如果15秒没有收到keeplive消息将会认为节点已经失效】
#
#warntime:
howlongbeforeissuing"lateheartbeat"warning?
#SeetheFAQforhowtousewarntimetotunedeadtime.
#
warntime10【在日志中记录最后心跳lastheartbeat-best前的警告时间】
#
#
#Veryfirstdeadtime(initdead)
#
#Onsomemachines/OSes,etc.thenetworktakesawhiletocomeup
#andstartworkingrightafteryou'vebeenrebooted.Asaresult
#wehaveaseparatedeadtimeforwhenthingsfirstcomeup.
#Itshouldbeatleasttwicethenormaldeadtime.
#
initdead60【如果节点的机器重启后,可能需要一些时间启动网络,这个时间与deadtime不一样,要单独对待】
#
#
#nice_failback:
determineswhetheraresourcewill
#automaticallyfailbacktoits"primary"node,orremain
#onwhatevernodeisservingituntilthatnodefails.
#
#Thedefaultis"off",whichmeansthatitWILLfail
#backtothenodewhichisdeclaredasprimaryinharesources
#
#"on"meansthatresourcesonlymovetonewnodeswhen
#thenodestheyareservedondie.Thisisdeemedasa
#"nice"behavior(unlessyouwanttodoactive-active).
#
nice_failbackon【如果主节点失效之后,重新恢复后,不会再成为主节点,只有当当前主节点失效,此节点才可恢复为主节点】
#
#hopfudgemaximumhopcountminusnumberofnodesinconfig
#hopfudge1
#
#
#Baudrateforserialports...
#(mustprecede"serial"directives)
#
#baud19200
#
#serialserialportname...
#serial/dev/ttyS0#Linux
#serial/dev/cuaa0#FreeBSD
#serial/dev/cua/a#Solaris
#
#WhatUDPporttouseforcommunication?
#[usedbybcastanducast]
#
#udpport694
#
#Whatinterfacestobroadcastheartbeatsover?
#
#bcasteth1#Linux
#bcasteth1eth2#Linux
#bcastle0#Solaris
#bcastle1le2#Solaris
#
#Setupamulticastheartbeatmedium
#mcast[dev][mcastgroup][port][ttl][loop]
#
#[dev]devicetosend/rcvheartbeatson
#[mcastgroup]multicastgrouptojoin(classDmulticastaddress
#224.0.0.0-239.255.255.255)
#[port]udpporttosendto/rcvfrom(noreasontodiffer
#fromtheportusedforbroadcastheartbeats)
#[ttl]thettlvalueforoutboundheartbeats.Thisaffects
#howfarthemulticastpacketwillpropagate.(1-255)
#[loop]togglesloopbackforoutboundmulticastheartbeats.
#ifenabled,anoutboundpacketwillbeloopedbackand
#receivedbytheinterfaceitwassenton.(0or1)
#Thisfieldshouldalwaysbesetto0.
#
#
mcasteth1225.0.0.2269410【使用组播225.0.0.22,端口694发送keeplive消息】
#
#Setupaunicast/udpheartbeatmedium
#ucast[dev][peer-ip-addr]
#
#[dev]devicetosend/rcvheartbeatson
#[peer-ip-addr]IPaddressofpeertosendpacketsto
#
#ucasteth0192.168.1.2
#
#
#Watchdogisthewatchdogtimer.Ifourownheartdoesn'tbeatfor
#aminute,thenourmachinewillreboot.
#
#watchdog/dev/watchdog
#
#"Legacy"STONITHsupport
#Usingthisdirectiveassumesthatthereisonestonith
#deviceinthecluster.Parameterstothisdeviceare
#readfromaconfigurationfile.Theformatofthislineis:
#
#stonith
#
#NOTE:
itisuptoyoutomaintainthisfileoneachnodeinthe
#cluster!
#
#stonithbaytech/etc/ha.d/conf/stonith.baytech
#
#STONITHsupport
#Youcanconfiguremultiplestonithdevicesusingthisdirective.
#Theformatofthelineis:
#stonith_host
#isthemachinethestonithdeviceisattached
#toor*tomeanitisaccessiblefromanyhost.
#isthetypeofstonithdevice(alistof
#supporteddrivesisin/usr/lib/stonith.)
#aredriverspecificparameters.Toseethe
#formatforaparticulardevice,run:
#stonith-l-t
#
#
#Notethatifyouputyourstonithdeviceaccessinformationin
#here,andyoumakethisfilepublicallyreadable,you'reasking
#foradenialofserviceattack;-)
#
#
#stonith_host*baytech10.0.0.3myloginmysecretpassword
#stonith_hostken3rps10/dev/ttyS1kathy0
#stonith_hostkathyrps10/dev/ttyS1ken30
#
#Tellwhatmachinesareinthecluster
#nodenodename...--mustmatchuname-n
noderh-9-a【定义节点名称,必须是节点的主机名】
noderh-9-b
#
#Lesscommonoptions...
#
#Treats10.10.10.254asapsuedo-cluster-member
#
#ping
#
#Startedandstoppedwithheartbeat.Restartedunlessitexits
#withrc=100
#
#respawnuserid/path/name/to/run
##################################################################
authkeys
#
#Authenticationfile.Mustbemode600
#
#
#Musthaveexactlyoneauthdirectiveatthefront.
#authsendauthenticationusingthismethod-id
#
#Then,listthemethodandkeythatgowiththatmethod-id
#
#Availablemethods:
crcsha1,md5.Crcdoesn'tneed/wantakey.
#
#Younormallyonlyhaveoneauthenticationmethod-idlistedinthisfile
#
#Putmorethanonetomakeasmoothtransitionwhenchangingauth
#methodsand/orkeys.
#
#
#sha1isbelievedtobethe"best",md5nextbest.
#
#crcaddsnosecurity,exceptfrompacketcorruption.
#Useonlyonphysicallysecurenetworks.
#
auth3【指定认证加密方式,3表示加密方式的行号】
#1crc
#2sha1HI!
3md5Hello!
【使用md5加密,密码为hello!
】
####################################################################################################################################
#
#Thisisalistofresourcesthatmovefrommachinetomachineas
#nodesgodownandcomeupinthecluster.Donotinclude
#"administrative"orfixedIPaddressesinthisfile.
#
#
#TheharesourcesfilesMUSTBEIDENTICALonallnodesofthecluster.
#
#Thenodenameslistedinfrontoftheresourcegroupinformation
#isthenameofthepreferrednodetoruntheservice.Itis
#notnecessarilythenameofthecurrentmachine.Ifyouarerunning
#nice_failbackOFFthentheseserviceswillbestarted
#uponthepreferrednodes-anytimethey'reup.
#
#Ifyouarerunningwithnice_failbackON,thenthenodeinformation
#willbeusedinthecaseofasimultaneousstart-up.
#
#BUTFORALLOFTHESECASES,theharesourcesfilesMUSTBEIDENTICAL.
#Ifyourfilesaredifferentthenalmostcertainlysomething
#won'tworkright.
#
#
#
#Werefertothisfilewhenwe'recomingup,andwhenamachineisbeing
#takenoveraftergoingdown.
#
#Youneedtomakethisrightforyourinstallation,theninstallitin
#/etc/ha.d
#
#Eachlogicallineinthefileconstitutesa"resourcegroup".
#Aresourcegroupisalistofresourceswhichmovetogetherfrom
#onenodetoanother-intheorderlisted.Itisassumedthatthere
#isnorelationshipbetweendifferentresourcegroups.These
#resourceinaresourcegrouparestartedleft-to-right,andstopped
#right-to-left.Longlistsofresourcescanbecontinuedfromline
#tolinebyendingthelineswithbackslashes("\").
#
#TheseresourcesinthisfileareeitherIPaddresses,orthename
#ofscriptstorunto"start"or"stop"thegivenresource.
#
#Theformatislikethis:
#
#node-nameresource1resource2...resourceN
#
#
#Iftheresourcenamecontainsan:
:
inthemiddleofit,the
#partafterthe:
:
ispassedtotheresourcescriptasanargument.
#Multipleargumentsareseparatedbythe:
:
delimeter
#
#InthecaseofIPaddresses,theresourcescriptnameIPaddris
#implied.
#
#Forexample,theIPaddress135.9.8.7couldalsoberepresented
#asIPaddr:
:
135.9.8.7
#
#THISISIMPORTAN