一集群和linux上的集群解决方案
Java
Asp
PHP
.Net
XML
C/C++
CGI
VB
Jsp
J2ee
J2se
J2me
EJB
Servlet
Tomcat
Resin
Struts
Weblogic
Eclipse
ANT
GUI
JMS
Web servise
IDEA
Webphere
Hibernate
Spring
Jboss
Applet
Swing
Socket
Javamail
Perl
Ajax
P2P
安全
模式
框架
测试
开源
游戏
Windows XP
Windows 2000
Windows 2003
Windows Me
Windows 9.x
Linux
UNIX
注册表
操作系统
服务器
应用服务器
集群系统(cluster)主要解决下面几个问题:
高可靠性(ha)。利用集群管理软件,当主服务器故障时,备份服务器能够自动接管主服务器的工作,并及时切换过去,以实现对用户的不间断服务。
高性能计算(hp)。即充分利用集群中的每一台计算机的资源,实现复杂运算的并行处理,通常用于科学计算领域,比如基因分析,化学分析等。
负载平衡。即把负载压力根据某种算法合理分配到集群中的每一台计算机上,以减轻主服务器的压力,降低对主服务器的硬件和软件要求。
在实际应用中,最常见的情况是利用集群解决负载平衡问题,比如用于提供www服务。在这里主要展示如何使用lvs(linux virtial server)来实现实用的www负载平衡集群系统。
二 lvs简介
lvs是章文嵩博士发起和领导的优秀的集群解决方案,许多商业的集群产品,比如redhat的piranha,turbolinux公司的turbo cluster等,都是基于lvs的核心代码的。在现实的应用中,lvs得到了大量的部署,请参考http: //www.linuxvirtualserver.org/deployment.html
关于linux lvs的工作原理和更详细的信息,请参考http://www.linuxvirtualserver.org。
三 lvs配置实例
通过linux lvs,实现www,te.net服务的负载平衡。这里实现te.net集群服务仅为了测试上的方便。
lvs有三种负载平衡方式,nat.network address translation),dr(direct routing),ip tunneling。其中,最为常用的是dr方式,因此这里只说明dr(direct routing)方式的lvs负载平衡。
1。网络拓扑结构。
如图1所示,为测试方便,4台机器处于同一网段内,通过一交换机或者集线器相连。实际的应用中,最好能够将虚拟服务器vs1和真实服务器rs1, rs2置于于不同的网段上,即提高了性能,也加强了整个集群系统的安全性。
2。服务器的软硬件配置
首先说明,虽然本文的测试环境中用的是3台相同配置的服务器,但lvs并不要求集群中的服务器规格划一,相反,可以根据服务器的不同配置和负载情况,调整负载分配策略,充分利用集群环境中的每一台服务器。
这3台服务器中,vs1作为虚拟服务器(即负载平衡服务器),负责将用户的访问请求转发到集群内部的rs1,rs2,然后由rs1,rs2分别处理。
client为客户端测试机器,可以为任意操作系统。
4台服务器的操作系统和网络配置分别为:
vs1: redhat 6.2, kernel 2.2.19
vs1: eth0 192.168.0.1
vs1: eth0:101 192.168.0.101
rs1: redhat 6.2, kernel 2.2.14
rs1: eth0 192.168.0.3
rs1: dummy0 192.168.0.101
rs2: redhat 6.2, kernel 2.2.14
rs2: eth0 192.168.0.4
rs2: dummy0 192.168.0.101
client: windows 2000
client: eth0 192.168.0.200
其中,192.168.0.101是允许用户访问的ip。
虚拟服务器的集群配置
大部分的集群配置工作都在虚拟服务器vs1上面,需要下面的几个步骤:
重新编译内核。
首先,下载最新的linux内核,版本号为2.2.19,下载地址为:http://www.kernel.org/,解压缩后置于/usr/src/linux目录下。
其次需要下载lvs的内核补丁,地址为:http://www.linuxvirtualserver.org/software/ipvs- 1.0.6-2.2.19.tar.gz。这里注意,如果你用的linux内核不是2.2.19版本的,请下载相应版本的lvs内核补丁。将ipvs- 1.0.6-2.2.19.tar.gz解压缩后置于/usr/src/linux目录下。
然后,对内核打补丁,如下操作:
[root@vs2 /root]# cd /usr/src/linux
[root@vs2 linux]# patch -p1 < ipvs-1.0.6-2.2.19/ipvs-1.0.6-2.2.19.patch
下面就是重新配置和编译linux的内核。特别注意以下选项:
1 code maturity level options--->
* [*]prompt for development and/or incomplete code/drivers
2.networking部分:
[*] kernel/user.netlink socket
[*] routing messages
<*>.netlink device emulation
* [*].network firewalls
[*] socket filtering
<*> unix domain sockets
* [*] tcp/ip.networking
[*] ip: multicasting
[*] ip: advanced router
[ ] ip: policy routing
[ ] ip: equal cost multipath
[ ] ip: use tos value as routing key
[ ] ip: verbose route monitoring
[ ] ip: large routing tables
[ ] ip: kernel level autoconfiguration
* [*] ip: firewalling
[ ] ip: firewall packet.netlink device
* [*] ip: transparent proxy support
* [*] ip: masquerading
--- protocol-specific masquerading support will be built as modules.
* [*] ip: icmp masquerading
--- protocol-specific masquerading support will be built as modules.
* [*] ip: masquerading special modules support
*
*
*
* [*] ip: masquerading virtual server support (experimental)(new)
[*] ip virtual server debugging (new) <--最好选择此项,以便观察lvs的调试信息
* (12) ip masquerading vs table size (the nth power of 2) (new)
*
*
*
*
*
*
* [*] ip: optimize as router not host
*
[*] ip: broadcast gre over ip
[*] ip: multicast routing
[*] ip: pim-sm version 1 support
[*] ip: pim-sm version 2 support
* [*] ip: aliasing support
[ ] ip: arp daemon support (experimental)
* [*] ip: tcp syncookie support (not enabled per default)
--- (it is safe to leave these untouched)
< > ip: reverse arp
[*] ip: allow large windows (not recommended if <16mb of memory)
< > the ipv6 protocol (experimental)
关键字 本文所属关键字
相关 与本文相关文章
分类 所有文章关键字导航
源码编程相关
操作系统/服务器相关
标准 网站致力的规范