lost and found ( for me ? )

ubuntu 12.04 : ipvsadm , keepalived


Here's an explanation of how to configure ipvsadm and keepalived.

client
 |
 | VIP 192.168.10.112 , real ip : 192.168.10.111
LVS
 | real ip : 192.168.30.111
 |
Web*2 ( 192.168.30.10 , 192.168.30.20 )

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
# uname -ri
3.2.0-39-generic x86_64

install
# apt-get install -y ipvsadm keepalived

start ipvsadm.
at this time , there are no Virtual seervers and nodes.
# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
 -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

configure keepalived.conf ( /etc/keepalived/keepalived.conf )
# cat /etc/keepalived/keepalived.conf
virtual_server_group HTTP 100 {
       192.168.10.112 80
}

virtual_server group HTTP 100 {
       delay_loop 3
       lvs_sched rr
       lvs_method NAT
       protocol TCP
       virtualhost foo.bar
       sory_server 192.168.30.30 80
       real_server 192.168.30.10 80 {
       weight 1
       inhibit_on_failure
       HTTP_GET {
               url {
                       path /index.html
                       status_code 200
               }
               connect_timeout 3
       }
}
       real_server 192.168.30.20 80 {
       weight 1
       inhibit_on_failure
       HTTP_GET {
               url {
                       path /index.html
                       status_code 200
               }
               connect_timeout 3
       }
}
}

start keepalived
# /etc/init.d/keepalived start
* Starting keepalived keepalived                                        [ OK ]

the virtual server is added
# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
 -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.10.112:80 rr
 -> 192.168.30.10:80             Masq    1      0          0
 -> 192.168.30.20:80             Masq    1      0          0

# curl http://192.168.10.112
centos6-3
# curl http://192.168.10.112
centos6-4

cap data on the web server. the following is heal check packets from LVS to Real server.
192.168.30.111 : LVS’s IP , 192.168.30.10 : Real Server’s IP
# tshark -i eth0 port 80 -R '(ip.addr==192.168.30.111)' | grep -i get
Capturing on eth0
 0.000546 192.168.30.111 -> 192.168.30.10 HTTP GET /index.html HTTP/1.0
 3.002883 192.168.30.111 -> 192.168.30.10 HTTP GET /index.html HTTP/1.0
 6.005483 192.168.30.111 -> 192.168.30.10 HTTP GET /index.html HTTP/1.0
 9.008175 192.168.30.111 -> 192.168.30.10 HTTP GET /index.html HTTP/1.0

when the apache goes down.
/var/log/syslog ( LVS )
Apr  2 20:23:38 ubuntu-lvs Keepalived_healthcheckers: Error connecting server [192.168.30.10]:80.
Apr  2 20:23:38 ubuntu-lvs Keepalived_healthcheckers: Disabling service [192.168.30.10]:80 from VS [HTTP]:0

when the apache goes up
/var/log/syslog ( LVS )
Apr  2 20:26:32 ubuntu-lvs Keepalived_healthcheckers: HTTP status code success to [192.168.30.10]:80 url(1).
Apr  2 20:26:35 ubuntu-lvs Keepalived_healthcheckers: Remote Web server [192.168.30.10]:80 succeed on service.
Apr  2 20:26:35 ubuntu-lvs Keepalived_healthcheckers: Enabling service [192.168.30.10]:80 to VS [HTTP]:0

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.