ã©ã¤ããã¢ãã¯ããã¸ã¼ã»ããã¼ã«è¡ã£ã¦ãã¾ãããã
id:naoyaãã㯠LVS++ã¨ãã話 ã§ããããèªåã 1å¹´ã»ã©åã«ãæãµã¤ãã®è² è·åæ£ã LVS + Ultra Monkey (heartbeat + ldrectord) ã§ãã£ãã®ã§ã社å
Wiki ã«æ¸ãã¦ãã¡ã¢ãæãã¦ããã¾ãã
# ä»ãªã heartbeat ãããªã㦠keepalived ãæ®éãªã®ããç¥ãããæ
å ±ãå¤ãã®å¯è½æ§ã¯ããã¾ã
ã¨ããæ§æã
LVS 㨠Real Server ãå¥ã«ããã®ã¯ã¡ãã£ã¨ã³ã¹ãçã«ãã£ãããªãã£ããããDirector 㨠Real Server ãåä¸ãã·ã³ã«ä¹ããå½¢ã«ãhttp://ultramonkey.jp/2.0.1/topologies/sl-ha-lb-eg.html ã®å½¢æ
ã
帰ãã®ãã±ãã㯠Director ãçµç±ãããç´æ¥ã¯ã©ã¤ã¢ã³ãã«å¸°ããããã DSR ã§ãã
# 以ä¸ãIPã¢ãã¬ã¹ããã¹ãåã¯å®éã¨ã¯å¤ãã¦ããã¾ãã
www 192.168.0.10(VIP) www1 | | www2 www3 +----192.168.0.7-----+ +-----192.168.0.8----+ +-----192.168.0.9----+ | Director (active) | | Director (standby) | | httpd | | httpd | | httpd | +--------------------+ +--------------------+ +--------------------+ +-----192.168.0.11-----+ | PostgreSQL | +----------------------+
OS 㯠CentOS-4 (kernel-2.6.9)ã
Heartbeat, ipvsadm 㯠www1 㨠www2 ã®ã¿ã«ã¤ã³ã¹ãã¼ã« / è¨å®ãarptables ã®è¨å®ã¯3å°å
±éã
- Heartbeat 㯠Ultra Monkey ã®ãµã¤ããã RHEL3 ç¨ã® SRPMS ããªãã«ã
- ipvsadm 㯠http://www.linuxvirtualserver.org/ ãã Kernel-2.6 ç¨ã® ipvsadm-1.24-6.src.rpm ããªãã«ã
- http://www.linuxvirtualserver.org/software/ipvs.html#kernel-2.6
- RHEL3 ç¨ã® 1.21 㯠Kernel-2.4 ç¨ã§ CentOS 4 ã«ã¯ä½¿ç¨ã§ããªãã®ã§æ³¨æ
[追è¨] ç¾å¨ã¯ãCentOS-4 extras ã« heartbeat, ipvsadm ã®ããã±ã¼ã¸ãããã¾ãã
ã¤ã³ã¹ãã¼ã«ããã RPMã
- heartbeat-1.2.3.cvs.20050927-1.centos.um.1
- heartbeat-pils-1.2.3.cvs.20050927-1.centos.um.1
- heartbeat-ldirectord-1.2.3.cvs.20050927-1.centos.um.1
- heartbeat-stonith-1.2.3.cvs.20050927-1.centos.um.1
- ipvsadm-1.24-6
- arptables-noarp-addr-0.99.1-1.rh.el.um.1
- arptables_jf-0.0.8-2
# /etc/ha.d/haresources www1.example.com 192.168.0.10 \ ldirectord::ldirectord.cf \ IPaddr::192.168.0.10/24/eth0
ldirectord ã§ãVIP ã§å ¬éãããµã¼ãã¹ã¨ Real Server ã®è¨å®ã
# /etc/ha.d/ldirectord.cf # Global Directives checktimeout=10 checkinterval=5 autoreload=no logfile="local0" quiescent=yes # Virtual Server for HTTP virtual=192.168.0.10:80 real=192.168.0.7:80 gate real=192.168.0.8:80 gate real=192.168.0.9:80 gate service=http request="ping.cgi" receive="ok" scheduler=rr #persistent=600 protocol=tcp checktype=negotiate virtual=192.168.0.10:443 real=192.168.0.7:443 gate real=192.168.0.8:443 gate real=192.168.0.9:443 gate service=https request="ping.cgi" receive="ok" scheduler=rr #persistent=600 protocol=tcp checktype=negotiate
Directorã®æ»æ´»ç£è¦ (heartbeat) è¨å®ã
# /etc/ha.d/ha.cf logfacility local0 # bcast eth0 ucast eth0 192.168.0.8 <-- ç¸æã® IP addr auto_failback off node www1.example.com node www2.example.com respawn hacluster /usr/lib/heartbeat/ipfail
heartbeat ã®èªè¨¼æ å ±ã
# /etc/ha.d/authkeys auth 2 2 sha1 xxxxxxxx
arptables ã¯ãVirtual IP addr ã«å¯¾ãã arp ã«ããªã¢ã«ãµã¼ããåå¿ããªãããã«ããããã«ä½¿ãã
# /etc/sysconfig/arptables *filter :IN ACCEPT [10:280] :OUT ACCEPT [1:28] :FORWARD ACCEPT [0:0] [6:168] -A IN -d 192.168.0.10 -j DROP [0:0] -A OUT -s 192.168.0.10 -o eth0 -j mangle --mangle-ip-s 192.168.0.7 <-- èªåã® real IP addr COMMIT
Director ã Active / Standby ã«ãªã£ãã¿ã¤ãã³ã°ã§ãarptables ã®è¨å®ãå¤æ´ããããã«
# ( cd /etc/ha.d/rc.d && ln -s arptables-noarp-addr_takeip local_takeip; ) # ( cd /etc/ha.d/rc.d && ln -s arptables-noarp-addr_giveip local_giveip; )
ãå®è¡ã
ãã¨ã¯ãèµ·åæã« heartbeat, arptables_jf ãèµ·åããããã«è¨å®ãldirectord 㯠heartbeat çµç±ã§èµ·åãããã®ã§ãèªåèµ·åãããªãã
# chkconfig --level 345 heartbeat on # chkconfig --level 345 arptables_jf on # chkconfig --level 345 ldirectord off