CentOS上配置LVS DR集群
CentOS上配置LVS DR集群I. 环境3台集群服务器操作系统:CentOS 5.5 x861台客户端操作系统:Windows 2008 x64II. 网络拓扑图LVS集群使用DR模式,1个DS(Director Server),2个RS(Real Server)。路由只有一个,RouteA=RouteB。上图中的GW为网关(GateWay),VIP为LVS中的虚拟IP。III. 服务器配置·
CentOS上配置LVS DR集群
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)
使用命令添加RS主机:
ipvsadm –C
ipvsadm -A -t 192.168.137.137:80 -s rr
ipvsadm -a -t 192.168.137.137:80 -r 192.168.137.102 -g
ipvsadm -a -t 192.168.137.137:80 -r 192.168.137.103 -g
ipvsadm -ln
在测试集群网络是否正确时,使用rr(Round-Robin)的集群模式容易查看集群是否正常工作。如果正常,在RS1和RS2的/var/www/html下放置内容不同的index.html文件,然后从客户端Client访问VIP(192.168.137.137),可以看到在浏览器中会交替显示RS1和RS2上不同的index.html内容。
· RS
修改/etc/sysctl.conf文件:
net.ipv4.ip_forward = 1
# For LVS
net.ipv4.conf.lo.arp_ignore=1
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
通过命令sysctl –p使其生效。
修改/etc/sysconfig/network-scripts/ifcfg-eth0文件:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.137.102
BROADCAST=192.168.137.255
GATEWAY=192.168.137.1
新建或修改/etc/sysconfig/network-scripts/ifcfg-lo:0文件:
DEVICE=lo:0
IPADDR=192.168.137.137
NETMASK=255.255.255.255
ONBOOT=yes
配置后ifconfig命令返回如下结果:
eth0 Link encap:Ethernet HWaddr 08:00:27:E4:DF:02
inet addr:192.168.137.102 Bcast:192.168.137.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee4:df02/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1670284 errors:0 dropped:0 overruns:0 frame:0
TX packets:871829 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:113130561 (107.8 MiB) TX bytes:54181142 (51.6 MiB)
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:25523 errors:0 dropped:0 overruns:0 frame:0
TX packets:25523 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3769820 (3.5 MiB) TX bytes:3769820 (3.5 MiB)
lo:0 Link encap:Local Loopback
inet addr:192.168.137.137 Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1
更多推荐
所有评论(0)