LVS是中国人发起的项目,真是意外呀!大家可以看http://www.douzhe.com/linuxtips/1665.html
我是从最初的HA(高可用性)开始的,别人的例子是用VMWARE,可以做试验但不能实际应用,我又没有光纤卡的Share Storage,于是就选用ISCSI,成功后又发现ISCSI+EXT3不能用于LVS,倒最后发现GFS可用,我最终成功配成可实际应用的LVS,前后断断续续花了四个月,走了很多弯路。我花了三天时间写下这篇文章,希望对大家有用。
这里要感谢linuxfans.org、linuxsir.com、chinaunix.com以及其它很多网站,很多资料都是从他们的论坛上找到的。参考文档及下载点
a.http://www.gyrate.org/misc/gfs.txt
b.http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/cluster-suite/index.html
http://www.redhat.com/docs/manuals/csgfs/admin-guide/index.html
c.ftp://ftp.redhat.com/pub/redhat/linux/updates/enterprise/3ES/en/RHGFS/SRPMS
d.http://distro.ibiblio.org/pub/linux/distributions/caoslinux/centos/3.1/contrib/i386/RPMS/
LVS结构图: eth0=10.3.1.101 eth0:1=10.3.1.254 Load Balance Router eth1=192.168.1.71 eth1:1=192.168.1.1 | | | | Real1 Real2 eth0=192.168.1.68 eth0=192.168.1.67 (eth0 gateway=192.168.1.1) eth1=192.168.0.1---eth1=192.168.0.2 (双机互联线) | | GFS ISCSI Share storage eth0=192.168.1.124
1.Setup ISCSI Server
Server: PIII 1.4,512M, Dell 1650,Redhat 9,IP=192.168.1.124
从http://iscsitarget.sourceforge.net/下载ISCSI TARGET的Source code
(http://sourceforge.net/project/showfiles.php?group_id=108475&package_id=117141)
我选了iscsitarget-0.3.8.tar.gz,要求kernel 2.4.29
从kernel.org下载kernel 2.4.29,解开编译重启后编译安装iscsitarget-0.3.8:
#make KERNELSRC=/usr/src/linux-2.4.29
#make KERNELSRC=/usr/src/linux-2.4.29 install
#cp ietd.conf /etc
#vi /etc/ietd.conf
# Example iscsi target configuration## Everything until the first target definition belongs# to the global configuration.# Right now this is only the user configuration used# during discovery sessions:# Users, who can access this target# (no users means anyone can access the target)User iscsiuser 1234567890abcTarget iqn.2005-04.com.my:storage.disk2.sys1.iraw1 User iscsiuser 1234567890abc Lun 0 /dev/sda5 fileio Alias iraw1Target iqn.2005-04.com.my:storage.disk2.sys1.iraw2 User iscsiuser 1234567890abc Lun 1 /dev/sda6 fileio Alias iraw2Target iqn.2005-04.com.my:storage.disk2.sys2.idisk User iscsiuser 1234567890abc Lun 2 /dev/sda3 fileio Alias idiskTarget iqn.2005-04.com.my:storage.disk2.sys2.icca User iscsiuser 1234567890abc Lun 3 /dev/sda7 fileio Alias icca
说明:password 长度必须不小于12个字符, Alias是别名, 不知为何这个别名在Client端显示不出来.
分区:我只有一个SCSI盘,所以:
IP Virtual Server version 1.0.8 (size=65536)Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConnTCP 10.3.1.254:ftp wlc -> cluster2:ftp Masq 1 0 0 -> cluster1:ftp Masq 1 0 0FWM 100 wlc persistent 60 -> cluster1:0 Masq 1 0 0 -> cluster2:0 Masq 1 0 0
注意:a.Firewall Mark可以不要,我反正是加了,文档说有https的话加上,值我选了100,
b.Virtual IP别加进/etc/hosts,我上过当,80端口时有时无的,
c.eth0:1,eth1:1是piranha产生的,别自己手工设置,我干过这画蛇添足的事,网上有
些帖子没说清,最后是看Redhat的文档才弄清楚的。
d.The LVS router can monitor the load on the various real servers by using
either rup or ruptime. If you select rup from the drop-down menu, each real
server must run the rstatd service. If you select ruptime, each real server
must run the rwhod service.Redhat的原话,就是如选rup的监控模式real server上
都要运行rstatd进程,如选ruptime就要运行rwhod进程。
e.Real Server同Router相联的网卡的Gateway必须是Router的那块网卡的VIP,举本例:
Router的eth1同两个real server的eth0相联,如VIP eth1:1=192.168.1.1,则real
server 的eth0的Gateway=192.168.1.1
echo "1" > /proc/sys/net/ipv4/ip_forward
q:在两台real server上分别
#vi /usr/local/tomcat/conf/tomcat-users.xml
加下面一行,允许页面管理:
r:在两台real server上分别
#service httpd restart
#/usr/local/tomcat/bin/startup.sh
s:打开http://1092.168.1.68:8080和http://1092.168.1.67:8080,选Tomcat Manager,用
manager/tomcat登录,虚拟目录/myjsp和/local应该Start了
在两台机子上分别打开网页http://10.3.1.254,选WEB Local,可以看到一台显示:
"test page on real server 1",另一台为"test page on real server 2",同时在Router上
ipvsadm可以看到每个real server的联接数
8.设置FTP服务
#vi /etc/vsftpd/vsftp.conf,在两台real server上分别加入以下几行: