Configure the LVS Dr cluster on centos
I. Environment
Three cluster servers: centos 5.5x86
One client operating system: Windows 2008x64
Ii. Network Topology
The LVS cluster uses the Dr mode, one DS (Director server) and two Rs (Real Server ). There is only one route, routea = routeb. The GW in is the gateway, and the VIP is the virtual IP address in LVS.
Iii. server configuration-Ds
Modify the/etc/sysctl. conf file:
Net. ipv4.ip _ forward = 1
Run the sysctl-p command to make it take effect.
Modify the/etc/sysconfig/network-scripts/ifcfg-eth0 file:
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
Create or modify the/etc/sysconfig/network-scripts/ifcfg-eth0: 0 file:
Device = eth0: 0
Bootproto = static
Onboot = Yes
Netmask = 255.255.255.0
Ipaddr = 192.168.137.20.
Broadcast = 192.168.137.255
Gateway = 192.168.137.1
After configuration, the ifconfig command returns the following results:
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 FIG: 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.20.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)
Run the following command to add an RS Host:
Ipvsadm-C
Ipvsadm-a-t 192.168.137.small: 80-s rr
Ipvsadm-a-t 192.168.137.133: 80-r 192.168.137.102-G
Ipvsadm-a-t 192.168.137.133: 80-r 192.168.137.103-G
Ipvsadm-ln
When you test whether the cluster network is correct, you can use the RR (round-robin) cluster mode to check whether the cluster is working properly. If it is normal, the/var/www/contents in RS1 and rs2.
· Rs
Modify the/etc/sysctl. conf file:
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
Run the sysctl-p command to make it take effect.
Modify the/etc/sysconfig/network-scripts/ifcfg-eth0 file:
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
Create or modify the/etc/sysconfig/network-scripts/ifcfg-Lo: 0 file:
Device = lo: 0
Ipaddr = 192.168.137.20.
Netmask = 255.255.255.255.255
Onboot = Yes
After configuration, the ifconfig command returns the following results:
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 FIG: 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.20.mask: 255.255.255.255
Up loopback running MTU: 16436 Metric: 1