Heartbeat ¿¡ ´ëÇØ °£´ÜÈ÷ ¼³¸íÇϸé... »çÀüÀû Àǹ̴ ½ÉÀå¹Úµ¿
³»°¡ ÇÏ·Á´Â ÀÛ¾÷À¸·Î Àǹ̸¦ ¹Ù²ãº¸¸é ½Ã½ºÅÛÀÇ Á¤»óÀÛµ¿ ¿©ºÎ¸¦ ÆÇ´ÜÇؼ ´ë±âÁßÀÎ ´ëü½Ã½ºÅÛÀ¸·Î ¼ºñ½º Á¦°øÀ» ÇϱâÀ§ÇÑ ¸ðµâÀÌ´Ù.
HeartBeat¸¦ ¼³Ä¡ÇÏ¸é µÎ ¼¹ö »çÀÌ¿¡ Áï, Primary·Î ¼³Á¤µÈ ¼¹ö¿Í Standby·Î ¼³Á¤µÈ ¼¹ö »çÀÌ¿¡ ÁÖ±âÀûÀ¸·Î ¸Þ½ÃÁö¸¦ ±³È¯ÇØ ¼¹öÀÇ »óŸ¦ È®ÀÎÇÑ´Ù.
HeartBeat´Â Active·Î »ç¿ë ÁßÀÎ Primary ¼¹ö¿Í Passive »óÅÂÀÎ Standby ¼¹ö »çÀÌ¿¡ IP °ü¸® ±â´ÉÀÇ ÀÏȯÀ¸·Î, VIP¸¦ »ç¿ëÇØ Active »óÅÂÀÎ Primary ¼¹ö¿¡ Àå¾Ö°¡ ÀϾ´õ¶óµµ Passive »óÅÂÀÎ Standby ¼¹ö¸¦ ÀÌ¿ëÇØ ¼ºñ½º°¡ ÁøÇàµÉ ¼ö ÀÖµµ·Ï ÇÑ´Ù.
ÇÏÁö¸¸ Heartbeat¿¡ ÃÖ´ë´ÜÁ¡Àº ¸®´ª½º¿¡¼¸¸ ¿î¿µ°¡´ÉÇÏ°í, ½Ã½ºÅÛ ·¹º§¿¡¼ ÀÛµ¿Çϱ⿡ ½Ã½ºÅÛÀÇ ´Ù¿î/¾÷ ¿©ºÎ´Â °¡´ÉÇϳª ¾îÇø®ÄÉÀÌ¼Ç ·¯º§¿¡¼ ¼ºñ½º Fail-Over ´Â ÆÇ´ÜÇÏÁö ¸øÇÑ´Ù.
µû¶ó¼ mon µ¥¸ó°ú °°ÀÌ »ç¿ëÇÏ¸é ¾îÇø®ÄÉÀÌ¼Ç ¼öÁØ¿¡ Fail-Over ÆÇ´Ü¿©ºÎ°¡ °¡´ÉÇÏ´Ù.
Heartbeat ´Â YUMÀ¸·Î ¼Õ½±°Ô ¼³Ä¡ °¡´ÉÇÏ´Ù.
[root@node1 root]# rpm -qa |grep heartbeat
heartbeat-pils-2.1.3-3.el5.centos
heartbeat-devel-2.1.3-3.el5.centos
heartbeat-gui-2.1.3-3.el5.centos
heartbeat-2.1.3-3.el5.centos
heartbeat-ldirectord-2.1.3-3.el5.centos
heartbeat-stonith-2.1.3-3.el5.centos
±âº» ¿¹Á¦ÆÄÀÏÀ» °¡Áö°í ¼³Á¤ÆÄÀÏÀ» ¼öÁ¤Çؼ ÀÌ¿ëÇÑ´Ù.
/usr/share/doc/heartbeat-2.0.8/authkeys # ³ëµå°£ÀÇ ÀÎÁõ¹æ¹ý ÁöÁ¤
/usr/share/doc/heartbeat-2.0.8/ha.cf # primary/secondary °£ÀÇ ÇÊ¿äÇÑ ±âº»¼³Á¤ÆÄÀÏ
/usr/share/doc/heartbeat-2.0.8/haresources # ³ëµå°£¿¡ °øÀ¯ÇÒ ÀÚ¿ø°ú ½ºÅ©¸³Æ®¸¦ ÁöÁ¤
º¹»ç
[root@node1 root]# cp /usr/share/doc/heartbeat-2.0.8/authkeys /etc/ha.d/
[root@node1 root]# cp /usr/share/doc/heartbeat-2.0.8/ha.cf /etc/ha.d/
[root@node1 root]# cp /usr/share/doc/heartbeat-2.0.8/haresources /etc/ha.d
¼³Á¤ÆÄÀÏ
[root@node1 root]# cat > /etc/ha.d/authkeys
auth 1
1 crc
[root@node1 root]# chmod 600 /etc/ha.d/authkeys
[root@node1 root]# cat > /etc/ha.d/haresources
node1 218.236.115.216
[root@node1 root]# cat ha.cf
keepalive 2
deadtime 5
warntime 10
initdead 10
udpport 694
logfile /var/log/ha-log
bcast eth0
auto_failback on
node node1
node node2
[root@node1 root]# cat > /etc/hosts
218.236.115.225 node1
218.236.115.226 node2
Heartbeat ¼³Á¤À» ÀÌ·Î½á ³¡ÀÌ´Ù....
ÀÌÁ¦´Â mon µ¥¸óÀ» ÀÌ¿ëÇؼ ¸ð´ÏÅ͸µÇÏ´Ù°¡ ¼ºñ½º°¡ üũ µÇÁö ¾Ê¾ÒÀ» °æ¿ì¿¡ ´ëºñÇÑ ¼³Á¤ÀÌ´Ù.
- node1(Master)Àº ÀÚ±âÀÚ½ÅÀ» ¸ð´ÏÅ͸µÇÑ´Ù.
±×·¯´Ù°¡ ¼ºñ½º°¡ üũµÇÁö ¾Ê¾ÒÀ»°æ¿ì¿¡ httpd-down.alert °æ°í¸¦ ½ÇÇà½ÃŲ´Ù.
¸¶½ºÅÍÀÇ heartbeat µ¥¸óÀ» ÁßÁö½ÃŲ´Ù
[root@node1 mon]# cat /usr/local/src/mon/alert.d/httpd-down.alert
#!/bin/bash
echo "`date` $*" >> /var/log/echo.alert.log # ·Î±ë
# Heartbeat daemon check
PSID=$(ps ax |grep heartbeat |grep -v grep | awk '{print $1}')
if [ "$PSID" == "" ]; then
exit
else
/etc/init.d/heartbeat stop
fi
- /etc/mon.cf
cfbasedir = /etc/mon
alertdir = /usr/local/src/mon/alert.d
mondir = /usr/local/src/mon/mon.d
maxprocs = 20
histlength = 100
randstart = 30s
authtype = getpwnam
hostgroup node1 218.236.115.225 # ÀÚ±âÀڽŠ¸ð´ÏÅ͸µ
watch node1
service http # 80¹ø ¼ºñ½º
interval 5s
monitor http.monitor
period wd {Sun-Sat}
alert httpd-down.alert "node1 server httpd is down!!"
upalert echo.alert "node1 server is live!!"
Master ¼¹öÀÇ httpd µ¥¸óÀ» ³»¸®¸é ·Î±ë°ú ÇÔ²² Heartbeart µ¥¸óÀÌ ÁװԵǰí... Slave ¼¹ö¿¡¼´Â Master ÀÇ Heartbeat UDP Æ÷Æ®°¡ ¿¬°áÀÌ µÇÁö ¾Ê¾Æ ½Ã½ºÅÛ¿¡ ¹®Á¦°¡ »ý±ä°É·Î ÆÇ´ÜÇÏ°í VIP ¸¦ °¡Á®°¡¼ ½É´Â´Ù..
[º¹±¸] Master Àåºñ¿¡ Àå¾Ö°¡ º¹±¸°¡ µÇ¾úÀ» °æ¿ì¿¡´Â... ÇØ´ç ¼ºñ½º Æ÷Æ®¿¡ Á¤»óÀÛµ¿¿©ºÎ¸¦ È®ÀÎÇÏ°í Heartbeat µ¥¸óÀ» ´Ù½Ã »ì¸®¸é ´Ù½Ã ¸¶½ºÅÍ¿¡¼ ¿î¿µÇÏ°Ô µÈ´Ù.