Lvs+keepalived realize lb hot standby to achieve high availability of web sites

Source: Internet
Author: User

In the LVS high load, the LB node (that is, the usual DR) has a single point of problem; Here the keepalived is used to solve the single point problem;

Look at the picture operation;

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 in two rs1, rs2 on the operation;

Echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce
echo 2 >/proc/sys/net/ipv4/conf/eth0/arp_announce
echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 >/proc/sys/net/ipv4/conf/eth0/arp_ignore
Service Network restart
ifconfig lo:0 192.168.182.200 netmask 255.255.255.255 broadcast 182.168.182.200 Route add-host 192.168.182.200
Dev lo:0
yum Install httpd-y
echo web1 >/var/www/html/index.html    #rs1标识web1
echo web2 >/var/www/html/ index.html    #rs2标识web2
service httpd start

LB1, LB2 on the operation;

Yum Install Ipvsadm keepalived httpd-y

keepalived configuration file on the LB1

! Configuration File for keepalived global_defs {notification_email {coffee_lanshan@sina.com} notification_e
    Mail_from root@localhost smtp_server 127.0.0.1 smtp_connect_timeout router_id lvs_1} vrrp_instance VI_1 {
    State MASTER #LB2为BACKUP Interface eth0 virtual_router_id Wuyi priority #LB2为100 Advert_int 1 
    Authentication {Auth_type pass Auth_pass Lansgg} virtual_ipaddress {192.168.182.200
    } virtual_server 192.168.182.200 {delay_loop 6 lb_algo wrr lb_kind DR nat_mask 255.255.255.0
            Persistence_timeout protocol TCP real_server 192.168.182.130 {weight 2 Tcp_check {
    Connect_timeout 3 nb_get_retry 3 delay_before_retry 1 connect_port 80} Sorry_server 127.0.0.1 real_server 192.168.182.129 {weight 2 Tcp_check {conn
       Ect_timeout 3     Nb_get_retry 3 delay_before_retry 1 connect_port 80}}} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.