I. 环境
3台集群服务器操作系统:CentOS 5.5 x86
1台客户端操作系统:Windows 2008 x64
II. 网络拓扑图
LVS集群使用DR模式,1个DS(Director Server),2个RS(Real Server)。路由只有一个,RouteA=RouteB。上图中的GW为网关(GateWay),VIP为LVS中的虚拟IP。
III. 服务器配置
· DS
修改/etc/sysctl.conf文件:
net.ipv4.ip_forward = 1
通过命令sysctl –p使其生效。
修改/etc/sysconfig/network-scripts/ifcfg-eth0文件:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.137.101
BROADCAST=192.168.137.255
GATEWAY=192.168.137.1
新建或修改/etc/sysconfig/network-scripts/ifcfg-eth0:0文件:
DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.137.137
BROADCAST=192.168.137.255
GATEWAY=192.168.137.1
配置后ifconfig命令返回如下结果:
eth0 Link encap:Ethernet HWaddr 08:00:27:25:39:D9
inet addr:192.168.137.101 Bcast:192.168.137.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe25:39d9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3757711 errors:0 dropped:0 overruns:0 frame:0
TX packets:2475767 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:250120448 (238.5 MiB) TX bytes:159666117 (152.2 MiB)
eth0:0 Link encap:Ethernet HWaddr 08:00:27:25:39:D9
inet addr:192.168.137.137 Bcast:192.168.137.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:25241 errors:0 dropped:0 overruns:0 frame:0
TX packets:25241 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3785187 (3.6 MiB) TX bytes:3785187 (3.6 MiB)