UltaMonkey-L7 實現高可用負載均衡測試文檔

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

UltaMonkey-L7 實現高可用負載均衡測試文檔

UltaMonkey-L7 實現高可用負載均衡測試文檔





作者:NetSeek http://www.linuxtone.org(IT運維專家網|集群架構|性能調優)
歡迎轉載,轉載時請務必以超鏈接形式標明文章原始出處和作者信息及本聲明.



一.UltaMoneky-L7 介紹

負載均衡之UltraMonkey-L7為Ultra Monkeyproject一擴展項目,提供基於特定Url字符集及Session persistence
進行的L7交換負載均衡.通過該架構可非常靈活把各種協議及負載均衡方式有機結合,支持High Availability和負載均衡技術.

二.UltaMonek-L7安裝
1下載相關軟體包wget http://apache.mirror.phpchina.com/apr/apr-1.3.3.tar.gz

•wget http://apache.mirror.phpchina.com/apr/apr-util-1.3.4.tar.bz2

•wgethttp://apache.etoak.com/logging/ ... g4cxx-0.10.0.tar.gz

•wget http://www.packetfactory.net/libnet/dist/libnet.tar.gz

•wget http://hg.linux-ha.org/lha-2.1/archive/STABLE-2.1.4.tar.bz2

•wgethttp://sourceforge.jp/projects/u ... ip?use_mirror=jaist複製代碼2.安裝相關軟體包
Apr安裝:# tar zxvf apr-1.3.3.tar.gz

•# cd apr-1.3.3.

•# ./configure --prefix=/usr --libdir=/usr/lib複製代碼Apr-tuil安裝# tar jxvf apr-util-1.3.4.tar.bz2

•# cd apr-util-1.3.4

•# ./configure --prefix=/usr --libdir=/usr/lib --with-apr=/usr複製代碼apache-log4cxx 安裝# tar zxvf apache-log4cxx-0.10.0.tar.gz

•# cd apache-log4cxx-0.10.0

•# ./configure --prefix=/usr --libdir=/usr/lib複製代碼Libnet安裝# tar zxvf libnet.tar.gz

•#cd libnet

•# ./configure &&make &&make install

•複製代碼Heartbeat安裝# groupadd -g 694 haclient

•# useradd -u 694 -g haclient hacluster 複製代碼# yum install glib2-devel•# tar jxvf Heartbeat-STABLE-2-1-STABLE-2.1.4.tar.bz2

•# cd Heartbeat-STABLE-2-1-STABLE-2.1.4

•# ./ConfigureMe configure --disable-swig --disable-snmp-subagent

•# make && make install



•# cp doc/ha.cf doc/haresources doc/authkeys /etc/ha.d/複製代碼ultramonkey-l7-2.0.0-1-rpm 安裝# unzip ultramonkey-l7-2.0.0-1-rpm.zip

•# cd ultramonkey-l7-2.0.0-1-rpm

•# rpm -Uvh ultramonkey-l7-2.0.0-1.i386.rpm // 用rpm安裝ultamonkey.複製代碼三.UltraMonkey-L7配置(NAT)
方案結構:virtual= 192.168.1.200:80

•     real=192.168.1.204:80 masq 1

•   real=192.168.1.205:80 masq 1

•HA-IP(DR):

•LVS Director (Master) 192.168.1.202   primarylb.linuxtone.org

•LVS Director (Backup) 192.168.1.203   backuplb.linuxtone.org•RealServer: 192.168.1.204 192.168.1.205
複製代碼1.配置/etc/hosts192.168.1.202 primarylb.linuxtone.org

•192.168.1.203 backuplb.linuxtone.org複製代碼2.配置ha.cf# vi /etc/ha.d/ha.cf
logfile/var/log/ha-log

•logfacility

•local0

•keepalive2

•deadtime30

•warntime10

•initdead120

•udpport694

•baud

•19200

•serial

•/dev/ttyS0

•# Linux

•#ucasteth2 10.0.0.3

•ucast eth0 192.168.1.203

•#備份機上填寫ucast eth0192.168.1.202

•auto_failbackon

•watchdog/dev/watchdog

•#crm on

•nodeprimarylb.linuxtone.org

•nodebackuplb.linuxtone.org

•ping192.168.1.203

•#ping_grouplbgroup 10.0.0.1 10.0.0.2

•ping_grouplbgroup 192.168.1.202 192.168.1.203

•respawnroot /usr/lib/heartbeat/ipfail

•apiauth ipfail gid=root uid=root複製代碼3.配置authkeys
# vi/etc/ha.d/authkeys
auth 2

•2 sha1 Hey!
複製代碼#chmod 600 /etc/ha.d/authkeys

4.配置haresources
主伺服器配置:# vi /etc/ha.d/haresources
primarylb.linuxtone.org  192.168.1.200/32/eth0:0 l7vsd l7directord複製代碼備份伺服器配置:# vi /etc/ha.d/haresources
backuplb.linuxtone.org 192.168.1.200/32/eth0:0 l7vsd l7directord複製代碼將相關資源建立鏈接:# ln -s /usr/sbin/l7vsd /etc/ha.d/resource.d/
# ln -s /etc/init.d/l7directord /etc/ha.d/resource.d/

5.配置l7directord.conf (cat l7directord.cf |grep -v "#")
# vi /etc/ha.d/conf/l7directord.cf
checktimeout=4

•checkinterval=10

•autoreload=yes

•logfile="/var/log/l7directord.log"

•quiescent=no

•virtual=192.168.1.200:80

•real=192.168.1.204:80 masq 1

•real=192.168.1.205:80 masq 1

•module=cinsert --cookie-name 'linuxtone'--cookie-expire 5

•scheduler=wrr

•protocol=tcp

•maxconn=2000複製代碼6.配置完成啟動heartbeat
# /etc/init.d/heartbeatstart

7. Realserver配置(略,請參考http://www.linuxtone.org 相關文檔.)

四. 故障排除與測試.1.查看日誌.
# tail -f /var/log/messages 實時監聽相看日誌變化.


2.查看服務是否正常
# ps -ef |grepl7directord
# ps -ef |grepl7vsd
# ifconfig 或 ip add show

3. # watch l7vsadm?l
Layer-7 Virtual Server version 2.0.0-1

•Prot LocalAddressort ProtoMod Scheduler

•  -> RemoteAddressort           Forward Weight ActiveConn InactConn

•TCP 192.168.1.200:http cinsert wrr

•  -> 192.168.1.204:http           Masq    1  0          1

•  -> 192.168.1.205:http           Masq    1  0          0複製代碼4. ha.cf 配置錯誤導致Heartbeat不能正常停止和接管相關資源[提醒]
在測試過程中在backuplb機器上,配置ha.cf的時候是直接copy了primarylb的配置
文件: ucast eth0 192.168.1.202 寫成了ucast eth0 192.168.1.203 導致heartbeat不能正
停止和接管資源。所以朋友們在配置過程中盡量要仔細認真,多分析日誌.

五.相關參考文檔:
1. 負載均衡之UltraMonkey-L7[龍如俊大哥之作]: http://www.linuxtone.org/thread-1351-1-1.html
2. 官方參考文檔:  http://ultramonkey-l7.sourceforge.jp/index_en.html




[火星人 ] UltaMonkey-L7 實現高可用負載均衡測試文檔已經有579次圍觀

http://coctec.com/docs/service/show-post-1791.html