Linux系统中集群技术及其配置实例
2006-08-26 10:49:38 来源:WEB开发网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: ipautofw masq support (EXPERIMENTAL)(NEW)
* IP: ipportfw masq support (EXPERIMENTAL)(NEW)
* IP: ip fwmark masq-forwarding support (EXPERIMENTAL)(NEW)
* [*] 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)
* IPVS: round-robin scheduling (NEW)
* IPVS: weighted round-robin scheduling (NEW)
* IPVS: least-connection scheduling (NEW)
* IPVS: weighted least-connection scheduling (NEW)
* IPVS: locality-based least-connection scheduling (NEW)
* IPVS: locality-based least-connection with replication scheduling (NEW)
* [*] IP: optimize as router not host
* IP: tunneling
IP: GRE tunnels over IP
[*] 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)
更多精彩
赞助商链接