LVS + Ultra Monkey で負荷分散 (設定編) - 酒日記 はてな支店 ã®ç¶ãã§ãã
ãã©ãã«æ
- real server ãè½ã¡ã! -> ldirectord ãæ¤ç¥ (æ大 checktimeout + checkinterval ç§ä»¥å ) ãã¦åãé¢ã
- director (active) ãè½ã¡ã! -> director (standby) ã® heartbeat ãæ¤ç¥ããactive ã«ææ ¼
å®éã«ãã㨠active ãªæ¹ã® heartbeat ãè½ã¨ãã¦ã¿ãã¨ã2ç§ç¨åº¦ã§åãæ¿ããã¾ããã
ã¡ã³ããã³ã¹æ
real server ãã¡ã³ããã³ã¹ãªã©ã§ä¸æçã«åãé¢ãããå ´åã¯ã以ä¸ã®ããã«ãã¾ãã
director ä¸ã§ãipvsadm ã³ãã³ãã使ã£ã¦ weight ã 0 ã«è¨å®ããæ¹æ³ã
# ipvsadm -e -t 192.168.0.10:http -r 192.168.0.7:http -w 0 # ipvsadm -e -t 192.168.0.10:https -r 192.168.0.7:https -w 0
復帰ããå ´å㯠weight ã 1 (ãªã©) ã«ã
ldirectord ã«åãé¢ãã¦ãããæ¹æ³ã
ldirectord.cf ã«ä»¥ä¸ã®ããã«è¨è¿°ãã¦ããå ´åã
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
ldirectord 㯠real server ã® /ping.cgi ã«ãªã¯ã¨ã¹ããæããçµæã« ok ã¨ããæååãå«ã¾ããã°æ£å¸¸ãã¨å¤æãã¾ãã
# ãã㧠ping.cgi ã¯ãDB æ¥ç¶ãã¦ç°¡åãªã¯ã¨ãªãçºè¡ããåé¡ãªããã° ok ã¨ããæååãè¿ãããã«ãã¦ãã¾ã
ã¨ãããã¨ã§ãããã¨çµæã« ok ãå«ã¾ããªãããã«ãã¦ãããã¨ã§ãreal server ãåãé¢ããã¨ãã§ãã¾ãã
åèµ·åãä¼´ããããªä½æ¥ãããµã¼ãã¹å ¨ä½ã¨ãã¦ã¯ãã¦ã³ã¿ã¤ã ç¡ãã§è¡ããã®ã§ (å³å¯ã«ã¯ director ã®åãæ¿ãæã®ã¿ãæ°ç§æ¢ã¾ãã¾ãã)ãç²¾ç¥çã«ãèä½çã«ãé常ã«æ°æ¥½ã§ããä¼ç¤¾ã«æ³ã¾ãè¾¼ãã§å¤ä¸ã«ã¡ã³ãããªãã¦ããã®ãå¬ããã
å®å®æ§ãè² è·ã«ã¤ãã¦
1æ¥ãããæ大 100ä¸ page view ã®æºå¸¯ãµã¤ã㧠1å¹´ééç¨ãã¾ããããLVS ãåå ã®ãã©ãã«ã¯ããã¾ããã
追å ãã server ãçªç¶æ»ãã (å¤åãã¼ãã¦ã§ã¢ãåå ) ãã¨ãæ°åãã£ã¦ãå³ãããé«å¯ç¨æ§ã®ããããã¿ãå®æããããã¾ãããã
ã¾ããLVS èªä½ã®è² è·ã¯ã»ã¼ 0 ã®ããã§ããldirectord ãã»ãã®ã¡ãã£ã¨ CPU 使ãããã§
㧠24æéåãã㦠CPU æé 35ç§ç¨åº¦ãLoad Average 㧠0.05 ããããä»ã®ãã·ã³ããä¸ããããªãã¨ããç¨åº¦ã§ãã
ãã£ã¨å¤æ°ã® real server ãç£è¦ããã¨ããã«å¿ã㦠ldirectord ã®è² è·ã¯ä¸ããã§ããããã©ãã¾ãæ°åå°ã® real server ã使ãã®ã§ããã° director ã¯åç¬ã®ãã·ã³ãå²ãå½ã¦ãããã§ããããããåé¡ãªãããªã¨æãã¾ãã