In the high load of lvs, the LB node, also known as the DR node, has a single point of failure. Here, keepalived is used to solve the single point of failure and achieve redundancy;
View the image;
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H3Eb-0.jpg "title =" 2.jpg"/>
LB1: eth0: 192.168.182.133 (vip: eth0: 0 192.168.182.200)
LB2: eth0: 192.168.182.138 (vip: eth0: 0 192.168.182.200)
Rs1: eth0: 192.168.182.130 (vip: lo: 0 192.168.182.200)
Rs2: eth0: 192.168.182.129 (vip: lo: 0 192.168.182.200)
The lvs model is DR;
First, perform operations on two rs1 and rs2 servers;
Echo 2>/proc/sys/net/ipv4/conf/all/arp_announceecho 2>/proc/sys/net/ipv4/conf/eth0/arp_announceecho 1>/proc/sys/ net/ipv4/conf/all/arp_ignoreecho 1>/proc/sys/net/ipv4/conf/eth0/arp_ignoreservice network restartifconfig lo: 0 192.168.182.200 netmask 255.255.255.255.255 broadcast 182.16182.200route add-host 192.168.182.200 dev lo: 0yum install httpd-yecho web1>/var/www/html/index.html # rs1 identification web1echo web2>/var/www/html/index.html # rs2 identification web2service httpd start
Perform operations on LB1 and LB2;
yum install ipvsadm keepalived httpd -y
Keepalived configuration file on LB1
! Configuration File for login {icationication_email {coffee_lanshan@sina.com} configure root @ localhost smtp_server 127.0.0.1 route 30 router_id LVS_1} vrrp_instance VI_1 {state MASTER # LB2 is BACKUP interface eth0 limit 51 priority 101 # LB2 is 100 advert_int 1 authentication {auth_type PASS auth_pass lansgg} virtual_ipaddress {192.168.182.200} virtual_server 192.168.182.200 80 {Listen 6 then wrr then dr too far limit 50 protocol TCP real_server 192.168.182.130 80 {weight 2 then {connect_timeout 3} 3 bytes 1 connect_port 80} sorry_server 127.0.0.1 80 real_server 192.168.182.129 80 {weight 2 TCP_CHECK {connect_timeout 3 nb_get_retry 3 delay_before_retry 1 connect_port 80 }}}
LB1:
Echo error: 192.168.182.133>/var/www/html/index.html # This step shows the page for test errors.
LB2:
echo error:192.168.182.138 > /var/www/html/index.html
Start keepalived, httpd, and ipvsadm respectively in LB1 and LB2.
You can see the following in LB1:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H35J1-1.jpg "title =" Photo 1.jpg "/>
It is found that the vip and ipvs rules have been added;
Perform the following tests;
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H3J18-2.jpg "title =" Photo 2.jpg "/>
We stopped the httpd service of rs1.
You will find that the ipvs rule of LB1 changes, and perform a page test;
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H35524-3.jpg "title =" courier 10.jpg "/>
Now you can stop keepalived on LB1, And the vip will automatically drift to LB2; services and related rules will not be affected;
[root@LB1 ~]# /etc/init.d/keepalived stop
You find that the vip is replaced by a priority of 100, that is, LB2.
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H31421-4.jpg "title =" courier 12.jpg "/>
Our business is not affected:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H35Y2-5.jpg "title =" Photo 13.jpg "/>
Then perform the test. When two rs are stopped, check the vip display page;
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/010H32N6-6.jpg "title =" Photo 11.jpg "/>
It is equivalent to the error prompt page of our website;
You are welcome to provide better suggestions and supplements;
This article is from the Coffee _ Blue Mountains blog, please be sure to keep this source http://lansgg.blog.51cto.com/5675165/1238530