High availability of LVS using the KeepAlive implementation

Source: Internet
Author: User



Configuration keepalived:

1. Using Dr Mode:

Environment Description:

192.168.2.205 node1.sky.com Keepalived+lvs server DIP

192.168.2.206 node2.sky.com Keepalived+lvs server DIP

192.168.2.220 LVs VIP

192.168.2.207 web1.sky.com Apache Server

192.168.2.208 web2.sky.com Apache Server

192.168.2.100 Window Client

Start with time synchronization


Configuration Description:

Global_defs {
Notification_email {
[Email protected]
}
Notification_email_from [email protected]
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
router_id node1.sky.com
Vrrp_mcast_group4 224.0.0.28
}


Vrrp_script Chk_mantaince_down {
Script "[[[-f/etc/keepalived/down]] && Exit 1 | | Exit 0 "
Interval 1
Weight-20
}

Vrrp_instance LVs {
State MASTER
Interface eth0
VIRTUAL_ROUTER_ID 51
Track_interface {
Eth0 Weight 5
Eth1 weight-20
}
Priority 110
Advert_int 2
Authentication {
Auth_type PASS
Auth_pass 1111
}
virtual_ipaddress {
192.168.2.220/32 Dev eth0 label eth0:0
}
Track_script {
Chk_mantaince_down
}
Notify_backup "/usr/local/keepalived/bin/show.sh http Backup"
Notify_master "/usr/local/keepalived/bin/show.sh http Master"
Notify_fault "/usr/local/keepalived/bin/show.sh http Fault"
Smtp_alert
}

Virtual_server 192.168.2.220 80 {
Delay_loop 3
Lb_algo RR
Lb_kind DR
Persistence_timeout 10
Protocol TCP

Real_server 192.168.2.207 80 {
Weight 1
Http_get {
URL {
Path/status
Status_code 200
}
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}

Real_server 192.168.2.208 80 {
Weight 1
Http_get {
URL {
Path/status
Status_code 200
}
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}

}

If the backend httpd service monitoring port is 8080, port forwarding can be done with iptables on the Web server

Iptables-t nat-a prerouting-p tcp--dport 80-j DNAT--to-destination:8080


2. Using NAT mode

Environment Description:

192.168.2.205 node1.sky.com Keepalived+lvs server DIP

192.168.2.206 node2.sky.com Keepalived+lvs server DIP

192.168.2.220 LVs VIP

192.168.2.207 (Management IP) 172.16.2.207 (VIP) web1.sky.com Apache Server

192.168.2.208 (Management IP) 172.16.2.208 (VIP) web2.sky.com Apache Server

192.168.2.100 Window Client


Configuration Description:

Global_defs {
Notification_email {
[Email protected]
}
Notification_email_from [email protected]
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
router_id node1.sky.com
Vrrp_mcast_group4 224.0.0.28
}


Vrrp_script Chk_mantaince_down {
Script "[[[-f/etc/keepalived/down]] && Exit 1 | | Exit 0 "
Interval 1
Weight-20
}

Vrrp_instance LVs {
State MASTER
Interface eth0
VIRTUAL_ROUTER_ID 51
Track_interface {
Eth0 Weight 5
Eth1 weight-20
}
Priority 110
Advert_int 2
Authentication {
Auth_type PASS
Auth_pass 1111
}
virtual_ipaddress {
192.168.2.220/24 brd 192.168.2.255 dev eth0 label eth0:0
172.16.2.220/24 BRD 172.16.2.255 Dev eth1 label eth1:0

}
Track_script {
Chk_mantaince_down
}
Notify_backup "/usr/local/keepalived/bin/show.sh http Backup"
Notify_master "/usr/local/keepalived/bin/show.sh http Master"
Notify_fault "/usr/local/keepalived/bin/show.sh http Fault"
Smtp_alert
}

Virtual_server 192.168.2.220 80 {
Delay_loop 3
Lb_algo RR
Lb_kind NAT
Persistence_timeout 10
Nat
Protocol TCP

Real_server 172.16.2.207 8080 {
Weight 1
Http_get {
URL {
Path/status
Status_code 200
}
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}

Real_server 172.16.2.208 8080 {
Weight 1
Http_get {
URL {
Path/status
Status_code 200
}
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}

}


Attention:

1, two LVS server open port forwarding

2. two Web server gateways point to 172.16.2.220

echo "101 Rip" >>/etc/iproute2/rt_tables

IP route add default via 172.16.2.220 dev eth1 tablerip

IP rule Add from 172.16.2.207 (208) Table RIP




This article is from the "Autumn Fairy tale" blog, please be sure to keep this source http://wushank.blog.51cto.com/3489095/1708430

High availability of LVS using the KeepAlive implementation

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.