-----The LVS cluster to build Dr Mode-----
--client----------LVS-----------WEB1
2.2.2.100 eth0:2.2.2.10 eth0:2.2.2.20
Sub-interface eth0:0:2.2.2.2 lo:0:2.2.2.2
------------WEB2---------
eth0:2.2.2.30
lo:0:2.2.2.2
I. Configuring the LVS Scheduler
1. Configure IP and VIP
[Email protected] ~]# vim/etc/sysconfig/networkscripts/
Ifcfg-eth0
2) Configure VIP
[Email protected] ~]# cd/etc/sysconfig/network-scripts/
[[Email protected] ~] #cp ifcfg-eth0 ifcfg-eth0:0
Add to:
device=eth0:0
Onboot=yes
ipaddr=2.2.2.2
netmask=255.0.0.0 content is consistent with these four lines and the rest is deleted
[Email protected] ~]# service network restart
2. Adjust the response parameters
[Email protected] ~]# vim/etc/sysctl.conf
Add to:
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
The meaning of the parameter is send redirect, 0 means turn off this feature.
[Email protected] ~]# sysctl-p
3. Install and configure Ipvsadm
Yum installation will prompt you not to find the package, you need to install it manually in RPM, directly to the mount point
[Email protected] ~]# RPM-IHV/mount point/packages/ipvsadm-1.26-
2.el6.x86_64.rpm
[[Email protected] ~]# service Ipvsadm stop//clear Original
Have a policy
[[email protected] ~]# ipvsadm-a-t 2.2.2.2:80-s RR
-A: Add Virtual server-T: Specifies the VIP address and port number-s Specifies the load scheduling algorithm RR: represents rotation
[[email protected] ~]# ipvsadm-a-T 2.2.2.2:80-r 2.2.2.20-g-W 1
-A: Add Real server-t:↑-r: Specify RIP Address (backend Web server address) and port
-G: Represented as Dr Mode (-M for Nat mode,-I tun Mode)-W weight
[Email protected] ~]# ipvsadm-a-t 2.2.2.2:80-r 2.2.2.30
-g-w 1
[[Email protected] ~]# service Ipvsadm Save//Save Policy
Slightly. You will see it saved in the real location in/etc/sysconfig/ipvsadm you can cat a look
[Email protected] ~]# chkconfig--add ipvsadm
[Email protected] ~]# chkconfig ipvsadm on
[[Email protected] ~]# service Ipvsadm start
Second, configure the Web node server
1. Configure IP Address
1) Set IP
[Email protected] ~]# vim/etc/sysconfig/networkscripts/
Ifcfg-eth0
2) Set VIP
[email protected] ~]# CP Ifcfg-lo ifcfg-lo:0
[Email protected] ~]# vim ifcfg-lo:0
Modify:
device=lo:0
ipaddr=2.2.2.2
netmask=255.255.255.255
Onboot=yes
[Email protected] ~]# service network Reload
3) Add route
[[email protected] ~]# route add-host 2.2.2.2 Dev lo:0//-host marked as a single host
[Email protected] ~]# echo "Route add-host 2.2.2.2 Dev lo:0" >>/etc/rc.local
2. Adjust the response parameters
[Email protected] ~]# vim/etc/sysctl.conf
Add to:
Net.ipv4.conf.all.arp_ignore = 1
Arp_ignore: Defines the response level of the NIC in response to an external ARP request
0: The default value, regardless of which Nic received the ARP request, as soon as found that this Mac has been given a response
1: Always use the most appropriate network card to respond, a host has a number of network cards, one of the network card received ARP please
Request, found that the requested Mac is another NIC of the computer, this time to receive the ARP request of this network card on a
Will not respond, only the Mac that found the request is its own.
Net.ipv4.conf.all.arp_announce = 2
Net.ipv4.conf.default.arp_ignore = 1
Net.ipv4.conf.default.arp_announce = 2
Net.ipv4.conf.lo.arp_ignore = 1
Net.ipv4.conf.lo.arp_announce = 2
arp_announce defines the level of the network card when it declares its mac-ip to the outside.
There are three values:
0: The default value, regardless of which Nic received the ARP request, as soon as found that this Mac has been given a response
1: Try to avoid responding to ARP requests in the MAC is not the network card, a host has more than one NIC, one of the network card connected
An ARP request was received and the requested Mac was found to be a different NIC on this computer, and this time the ARP request was received
This network card will try to avoid the response
2: Always use the most appropriate network card to respond, a host has a number of network cards, one of the network card received ARP please
Request, found that the requested Mac is another NIC of the computer, this time to receive the ARP request of this network card on a
Will not respond, only the Mac that found the request is its own.
[Email protected] ~]# sysctl-p
3. Configuring the HTTP Service
[Email protected] ~]# echo "Welcome to 2.2.2.20 Web
Server ">/var/www/html/index.html
[Email protected] ~]# service httpd restart
Another web to do the opposite action
Third, verify:
1. Client Access:
[Email protected] ~]# http://2.2.2.2/
2, on the LVS view:
[Email protected] ~]# IPVSADM-LNC
[Email protected] ~]# IPVSADM-LN
Nat mode relative to simpler multi-↓↓
-----The LVS cluster to build NAT mode-----
-----client---------LVS----------------WEB1-----------WEB2-----------NFS--------
2.2.2.100 eth0:2.2.2.1 192.168.1.10 192.168.1.20 192.168.1.200
eth1:192.168.1.1
First, the preparatory work
1. Add Module
[Email protected] ~]# modprobe Ip_vs
[Email protected] ~]# Cat/proc/net/ip_vs
2. Turn on the routing function
[Email protected] ~]# vim/etc/sysctl.conf
Modified: Net.ipv4.ip_forward = 1 approximately on line seventh
[Email protected] ~]# sysctl-p
3. Set Snat
[Email protected] ~]# iptables-t nat-a postrouting-s 192.168.1.0/24-o eth0-j SNAT--to-source 2.2.2.1
4. Installing IPVSADM Software
[Email protected] ~]# RPM-IVH/mount point/packages/ipvsadm-1.26-2.el6.x86_64.rpm
Second, set the load scheduler
1. Set the Load allocation policy
[[Email protected] ~]# service Ipvsadm stop
[[email protected] ~]# ipvsadm-a-t 2.2.2.1:80-s RR
[[email protected] ~]# ipvsadm-a-T 2.2.2.1:80-r 192.168.1.10:80-m-W 1
[[email protected] ~]# ipvsadm-a-T 2.2.2.1:80-r 192.168.1.20:80-m-W 1
[[Email protected] ~]# service Ipvsadm Save
[Email protected] ~]# chkconfig ipvsadm on
[[Email protected] ~]# service Ipvsadm start
Third, set up the node server
1. Configuring the WEB-1 Server
[Email protected] ~]# echo "Welcome to 192.168.1.10 Web Server" >
/var/www/html/index.html
[Email protected] ~]# service httpd restart
2. Configuring the Web-2 Server
[Email protected] ~]# echo "Welcome to 192.168.1.20 Web Server" >
/var/www/html/index.html
[Email protected] ~]# service httpd restart
Iv. Client Authentication:
1, on the client access:
Http://2.2.2.1/
2, in the LVS virtual server view:
[Email protected] ~]# IPVSADM-LN
[Email protected] ~]# IPVSADM-LNC
V. Configuring Server for NFS
1. Configuring NFS
[Email protected] ~]# mkdir/www
[Email protected] ~]# echo "Welcome to XIN LANG Web
Server ">/www/index.html
[Email protected] ~]# Vim/etc/exports
Add to:
/www 192.168.1.10 (rw) 192.168.1.20 (RO)
[[Email protected] ~]# Service NFS Restart
[Email protected] ~]# SHOWMOUNT-E
2. Configure on the Web server:
[Email protected] ~]# SHOWMOUNT-E 192.168.1.200
[email protected] ~]# Mount 192.168.1.200:/www/var/www/html/
[Email protected] ~]# Vim/etc/fstab
Add to:
192.168.1.200:/www/var/www/html NFS Defaults 0 0
3. Verification:
1, on the client access:
Http://2.2.2.1/
2, in the LVS virtual server view:
[Email protected] ~]# IPVSADM-LN
3, close a web, in the LVS virtual server view:
[Email protected] ~]# IPVSADM-LN
This article is from the "11000174" blog, please be sure to keep this source http://11010174.blog.51cto.com/11000174/1891780
LVS cluster (Dr/nat) two modes of configuration