heartbeat v2 安装和配置原理

Click here to load reader

Upload: lichun-pickup

Post on 26-Jun-2015

4.864 views

Category:

Technology


4 download

DESCRIPTION

Heartbeat v2 安装和配置原理

TRANSCRIPT

  • 1. Information Technologies, IncHang zhou, China Product NameHeartbeat V2 Author Name Pickup.Li1

2. 2 3. .......................................................................................................................................3 1 ................................................................................................................................5 2 ................................................................................................................................62.1 .........................................................................................................................................62.2 ..............................................................................................................................6 3 Heartbeat ....................................................................................................73.1 Heartbeat ............................................................................................................................73.2 ha.cf.......................................................................................................................................83.3 Authkeys...............................................................................................................................103.4 haresources..........................................................................................................................113.5 cib.xml..................................................................................................................................123.6 HeartBeat..............................................................................................................................153.7 Heartbeat .......................................................................................................................15 4 Heartbeat .............................................................................................................19 5 Heartbeat .........................................................................................................215.1 heartbeat ...........................................................................................................................215.2 CRMcluster resource manager...................................................................................................215.3 LRMlocal resource manager......................................................................................................215.4 PECRM Policy Engine...............................................................................................................225.5 TETransition engine...................................................................................................................223 4. 5.6 CIBcluster information base........................................................................................................225.7 CCMconsensus cluster membership..........................................................................................225.8 LOGDlogging daemonnon-blocking.....................................................................................235.9 APPHBDapplication heartbeat daemon......................................................................................235.10 RMDrecovery manager daemon...............................................................................................23 6 Heartbeat - .................................................................................24 7 Resource agent ...........................................................................................................297.1 LSB resource agent.......................................................................................................................297.2 Heartbeat resource agent..............................................................................................................297.3 OCF resource agent......................................................................................................................307.4 ..............................................................................................................................................30 8 ......................................................................................................................324 5. 2008-7-29 1.0 create Pickup.Li 1 5 6. 2 2.1 linux-HA v2 linux-HA Failover 2.2 1.linux-HA linux Heartbeat FreeBSD, Solaris, OpenBSD 2.Heartbeat linux-HA Heartbeat heartbeat 3.CCM/Consensus Cluster Membership 4.CRM/Cluster Linux-HA Resource Linux-HA Manager 5.LRM/Local resource agent CRM LRM Resource Manager 6.CIB/Cluster Information Base 7.transition graph PE TE CurrentClusterState TargetClusterState 8.PE/pengine/CRM transition graph policy engineresource 9.TE/tengine/CRM PE transition graph LRM Transition Enginestartstop TargetClusterState 10. resource 11. RA/resource agent 12. 6 7. 3HEARTBEAT 3.1 Heartbeat Heartbeat V1 IBM heartbeat Apache Web Heartbeat V2 V1 rpm prefix Heartbeat heartbeat installation guide 2.x 1.x 1) 2.x CRM , haresources cib.xml, 2) OCF resource agent, 3) 4) HeartbeatV2 V1 CRM off Heartbeat V2 ha.cfauthkey cib.xml V1 cib.xml V1 cib.xml haresources 1 2 haresources2cib.py haresources cib.xml , 2.x haresources , node1 192.168.1.205 runhttpd.sh node2 runjboss.sh , node1,node2 prefered node, node , 192.168.1.205 runhttpd.sh , http vip, 7 8. ,. a): /usr/local/lib/heartbeat/haresources2cib.py --stout -c /usr/local/etc/ha.d/ha.cf /usr/local/etc/ha.d/haresources b): /usr/local/etc/ha.d/haresources echo "" > /usr/local/etc/ha.d/haresources 3.2 ha.cf Heartbeat ha.cf/etc/ha.d Heartbeat ha.cf linux-HA ha.cf serial /dev/ttyS0 heartbeat heartbeat bcastheartbeat /dev/ttyS0 watchdog /dev/watchdog Watchdog heartbeat heartbeat fail over softdoginsmod softdoggrep misc /proc/devices 10cat /proc/misc | grep watchdog 130 mknod /dev/watchdog c 10 130 bcast eth1 eth1 heartbeat eth1 eth0eth2 keepalive 2 heartbeat 2 8 9. warntime 10 late heartbeat deadtime 30 30 initdead 120 deadtime deadtime baud 19200 udpport 694 694 bcast ucast IANA udpport bcast ucast udpport bcast ucast 694 auto_failback on Tru64 Unix heartbeat favored member failover haresources auto_failback on off nice_failback nice_failback off flash cut FAQ V2 crm cib.xml default_resource_stickiness node linuxha1.linux-ha.org uname n respawn ccm respawn hacluster /usr/lib/heartbeat/ccm Heartbeat userid hacluster ipfail 9 10. respawn hacluster /usr/lib/heartbeat/ipfail 100 ping ping1.linux-ha.org ping2.linux-ha.org .... ping ipfail ping_group ping1.linux-ha.org ping2.linux-ha.org .... ping ping ping ping 3.3 Authkeys authkeys crcmd5 sha1 Heartbeat crc CPU md5 CPU sha1 auth [] sha1/etc/ha.d/authkeys auth 1 1 sha1 key-for-sha1-any-text-you-want md5 sha1 md5 crc auth 2 2 crc10 11. auth auth 44 600any text you want 3.4 haresources haresources cib.xml HA Apache Samba IP haresources haresources linuxha1.linux-ha.org 192.168.85.3 httpd smb linuxha1 IP 192.168.85.3 Apache Samba Heartbeat smb Apache IP 192.168.85.3uname n linuxha1.linux-ha.orglinuxha1linuxha1 httpd smb Apache Samba Heartbeat /etc/ha.d/resource.d /etc/init.d start stop :: maid vacuum haresources linuxha1 192.168.85.3 httpd smb maid::vacuum IP maid linuxha1 IPaddr::192.168.85.3 httpd smb IPaddr 192.168.85.3/etc/ha.d/resource.d 11 12. IPaddr IP 32 IPaddr linuxha1 192.168.85.3/27 httpd smb IP 192.168.85.3 255.255.255.224 192.168.85.31 192.168.85.16 linuxha1 192.168.85.3/27/192.168.85.16 httpd smb IP Heartbeat IP Heartbeat 3.5 cib.xml Cluster Information Base (CIB) resource, cluster nodes constraints cib.xml heartbeat cib.xml cibadmin Heartbeat CIB 12 13. CIB crm_config node Heartbeat resources Heartbeat 2 interval="120s" 60s timeout="60s" VIP , 5S vip vip,timeout 5s, 5s 13 14. Heartbeat V2 V1 constraints constraintsLocationalCo-Locational Ordering Co-Locational Locational rules and expressions Ordering ClusterInformationBase/SimpleExamples constraints score score score Heartbeat INFINITY -INFINITY INFINITY +/- -INFINITY : ERROR INFINITY +/- int: INFINITY -INFINITY +/- int : -INFINITY resource constraints resource group constraints resource node status Heartbeat 14 15. 3.6 HeartBeat HeartBeat HeartBeatV2 hacluster haclient heartbeat find / -type d -name "heartbeat" -exec chown -R hacluster:haclient {} ; authkey chmod 600 service heartbeat start Heartbeat Heartbeat Designated Coordinator Heartbeat /var/log/ha-log Heartbeat Heartbeat warning Logiing deamon heartbeat[22522]: 2008/07/25_09:52:32 WARN: Logging daemon is disabled --enabling logging daemon is recommended Heartbeat logd ha.cf use_logd yes logd I/O Heartbeat Heartbeat Heartbeat 3.7 Heartbeat Heartbeat GUI crm_*Heartbeat GUI Guide Linux X server crm_*crm_attribute, crm_failcount, crm_mon, crm_sh, crm_uuid, crm_diff, crm_master, crm_resource , crm_standby, crm_verify Heartbeat hb_standbyhb_takeover cl_status prefix/sbin prefix Heartbeat configure prefix crm_resource Linux-HA CRM crm_resource : Examples 1) 15 16. crm_resource -L2)crm_resource -W -r runhttpd.sh_2resource runhttpd.sh_2 is running on: server1crm_resource -W -r runhttpd.sh_2resource runhttpd.sh_2 is NOT running4)/crm_resource -r runhttpd.sh_2 -p target_role -v startedcrm_resource -r runhttpd.sh_2 -p target_role -v stopped5) cib.xml crm_resource -x -r runhttpd.sh_26)crm_resource -M -r runhttpd.sh_27)crm_resource -M -r runhttpd.sh_2 -H c001n028)crm_resource -U -r runhttpd.sh_2NOTE: the values of resource_stickiness and default_resource_stickiness may mean that it doesnt move back. In such cases, you should use -M to move it back and then run this command.9) CRM crm_resource -D -r runhttpd.sh_2 -t primitive10) CRM crm_resource -D -r my_first_group -t group 16 17. 11) CRM crm_resource -p is_managed -r runhttpd.sh_2 -t primitive -v off 12) CRM crm_resource -p is_managed -r runhttpd.sh_2 -t primitive -v on 13)Resetting a failed resource after having been manually cleaned upcrm_resource -C -H c001n02 -r runhttpd.sh_2 14) CRM crm_resource -P 15) CRM crm_resource -P -H c001n02 Querying a parameter of a resource. Say the resource is the following: You could query the email address using the following:crm_resource -r example_mail -g email 16)17 18. crm_resource -r example_mail -p email -v "[email protected]"18 19. 4 HEARTBEAT Heartbeat heartbeat CCM CRM heartbeat CCM heartbeat CRM Heartbeat resource resource 1HeartBeat 19 20. 56 Alibaba DBA Team Heartbeat 20 21. 5 HEARTBEAT 5.1 heartbeat Heartbeat handler handler Heartbeat 5.2 CRM cluster resource manager v2 heartbeat heartbeat heartbeat CCM membership LRMlocal resource manager startstoprestart monitor LRM CRM 5.3 LRM local resource managerLRM Heartbeat resource agentheartbeat ocfopen cluster frameworklsblinux standard base linux init stonithstonith resource agent heartbeat/etc/ha.d/resource.d/ocf:/usr/lib/resource.d/heartbeat/lsb:/etc/init.d/ 21 22. LRM LRM care 5.4 PE CRM Policy Engine CRM CRM TETransition engine action PE 5.5 TE Transition engine PE PE TE PE TE active PE TE Heartbeat CRM 5.6 CIB cluster information baseCIB heartbeat CIB xml Heartbeat v2 haresources cib.xml CIB CIB 5.7 CCM consensus cluster membershipCCM heartbeat CCM 22 23. 5.8 LOGD logging daemon non-blocking CRM logd CRM 5.9 APPHBD application heartbeat daemonapphbd watchdog 5.10 RMD recovery manager daemon apphbd hang RMD restart kill 23 24. 6 HEARTBEAT - V2 Heartbeat Heartbeat active CIB resource-stickiness 0resource-failure-stickiness 0 heartbeat restart resource-stickiness resource-failure-stickiness INFINITY-INFINITY heartbeat CIB resource-stickiness resource-failure-stickiness mysql_db resource resource_stickinessresource_failure_stickiness 100 -100 24 25. resource default 25 26. configuration constraints rule heartbeat value rule score a heartbeat resourceresource mysql1 node+resource+failcount*failure=200+0+(0*(-100))=200 mysql2 node+resource+failcount*failure=150+0+(0*(-100))=150 heartbeat mysql1 mysql_db mysql1 mysql1 node+resource+failcount*failure=200+100+(0*(-100))=300 mysql2 node+resource+failcount*failure=150+0+(0*(-100))=150bheartbeat monitor mysql_db crash mysql1 node+resource+failcount*failure=200+100+(1*(-100))=200 mysql2 node+resource+failcount*failure=150+0+(0*(-100))=150 heartbeat mysql1 mysql2 restart c b restart mysql1 node+resource+failcount*failure=200+100+(2*(-100))=100 26 27. mysql2 node+resource+failcount*failure=150+0+(0*(-100))=150 heartbeat mysql2 mysql1 mysql1 mysql_db mysql2 mysql2 mysql_db mysql1 node+resource+failcount*failure=200+0+(2*(-100))=0mysql2 node+resource+failcount*failure=150+100+(0*(-100))=250 mysql2 mysql2 -50 mysql1 mysql1mysql1 100 mysql2 -150 100 mysql2 heartbeat mysql1 mysql_db mysql2 heartbeat failcountcrm_failcount -G -U mysql1 -r mysql_db# mysql1 mysql_db failcountcrm_failcount -D -U mysql1 -r mysql_db# mysql1 mysql_db failcount mysql_db 27 28. INFINITY -INFINITY (nodeA score - nodeB score + stickiness)/abs(failure stickiness) A B 28 29. 7 RESOURCE AGENT CRM resource resource agentresource agent resource CRM resource agent Heartbeat Heartbeat OCFLSB Heartbeat resource agent 7.1LSB resource agentLSB resource agent shell Heartbeat V2 LSB Spec start, stop, statusLSB resource agent start resource 0 0 stop resource 0 status resource resource status 0 resource status 3 Heartbeat LSB resource agent 7.2Heartbeat resource agentHeartbeat resource agent LSB resource agent status LSBresource agent start, stop, status LSB Heartbeat resource agent start status resource resourceHeartbeat resourcestop resource stop resource Heartbeat resource agent resourceHeartbeat resource Heartbeat stop status resource Heartbeat resourceagent resource OK runningHeartbeat resource agent status Linux status OK running status start resource V1 stop status resource CRM V2 stonithHeartbeat LSB haresources IPaddr Heartbeat resource agent 10.10.10.1 IPaddr::10.10.10.1 Heartbeat IPaddr start 29 30. IPaddr 10.10.10.1 start 7.3OCF resource agentOCF specification LSB resource agent /usr/lib/ocf/resource.d//usr/lib/ocf/resource.d/heartbeat Heartbeat OCF resource agent {provider}/usr/lib/ocf/resource.d/ OCF resource agent OCF resource agent OCF /usr/lib/heartbeat/ocf-shellfuncsV2.1.3$OCF_ROOT/resource.d//heartbeat/.ocf-shellfuncs include Heartbeat OCF Spec OCF specificationHeartbeat ocf-tester OCF resource agent OCF resource agent start, stop, monitor, meta-datastart resource resouce 0 7 resource resoucestop 0 7 monitor resource 0 resource 7 meta-data xml xml snippet resource OCF Spec Heartbeat Heartbeat resource OCF resource agent validate-all paremeters 0 2 resource 6 resource agent 5 cloned multi-stateresources promote, demote notifypromote resource master/primary 0demote resource slave/secondary 0notify heartbeat agent pre post resource 0 OCF Heartbeat reload recoverreload resource recover start resource OCF resource OCF Heartbeat resource agent OCF OCF_RESKEY_ ip OCF_RESKEY_ip linux-HA OCF OCF resource agent OCF Spec 7.4 resource agent 30 31. parameters OCF start,stop,monitor,meta_dat /usr/lib/ocf/resource.d/{provider} OCF Spec a LSB start,stop,status /etc/init.dLSB SpecHeartBeat start,stop,status /etc/ha.d/resource.d /etc/init.d Heartbeat 1 resource agent 31 32. 8Linux-HA heartbeat installation guide Heartbeat V2 Heartbeat - heartbeat 2.x style ( cib.xml) Linux Standard Base (LSB) Specifications Open Clustering Framework Resource Agent API mon - Service Monitoring Daemon Heartbeat GUI Guide Getting Started with Linux-HA (Heartbeat 2) 32