[prev in list] [next in list] [prev in thread] [next in thread] 

List:       keepalived-devel
Subject:    Re: [Keepalived-devel] vrrp_script, notify_fault, backup/fault state
From:       Paul Hirose <pthirose () ucdavis ! edu>
Date:       2009-11-25 21:30:04
Message-ID: alpine.BSO.2.00.0911251308240.32312 () eacs-pth ! engr ! ucdavis ! edu
[Download RAW message or body]

> Paul Hirose wrote:
> > Keepalived 1.1.19 running on CentOS 5.4 using HAProxy 1.3.22 as the service \
> > traffic load balancer.  This much works fine :)  I have two LBs both running KA, \
> > and it fails over wonderfully when I pull the plug on one LB or the other. 
> > I was trying to use the vrrp_script to watch the haproxy software running on the \
> > active/master load-balancer: vrrp_script chk_haproxy {           # Requires \
> > keepalived-1.1.13 script "killall -0 haproxy"     # cheaper than pidof
> > interval 2                      # check every 2 seconds
> > }
> > track_script {
> > chk_haproxy
> > }
> > I found this works fine as long as haproxy is running on the master.


> Graeme Fowler wrote:
> Try adding a "weight" clause to the vrrp_script stanza, like so:
> 
> vrrp_script check_cgp {
> script "/usr/local/bin/check_cgp"
> interval 10
> weight 10
> }
> 
> Then in the track_script stanza:
> 
> track_script {
> check_cgp weight 20
> }
> 
> That's what we do here, and it works perfectly. The VRRP prio gets
> adjusted according to the weights on test pass/fail, and the backup then
> switches to MASTER.

I made the change and now my Master won't even transition into the Fault state \
anymore.  Incidentally, I did do a iptables -I RH-Firewall-1-INPUT 9 -p vrrp -j \
ACCEPT on both the master and the backup load balancer.  If I physically pull the \
network cable out of the lb1 (the master), then lb2 (the backup) does go to Master \
status.  And if I plug lb1's cable back in, it goes back to Master status (not sure \
if it ever changed actual states while I had the cable pulled) and lb2 switches to \
Backup status.  But just killing keepalived on lb1 doesn't make lb2 become the Master \
status.  Are there more ports I need to open on the local host-based firewall other \
than for protocol vrrp (-p vrrp)?

The /var/log/messages on the Master line at 13:03:38 is when I did a kill -TERM \
haproxy from a different window.  And the line at 13:18:18 is when I restarted \
haproxy manually.

The /var/log/messages on the Master
===================================
Nov 25 13:02:58 lbtest1 Keepalived: Starting VRRP child process, pid=29839
Nov 25 13:02:58 lbtest1 Keepalived_vrrp: Opening file \
                '/opt/keepalived/etc/keepalived.conf'. 
Nov 25 13:02:58 lbtest1 Keepalived_vrrp: Configuration is using : 35162 Bytes
Nov 25 13:02:58 lbtest1 Keepalived_vrrp: Using LinkWatch kernel netlink reflector...
Nov 25 13:02:58 lbtest1 Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), \
                fd(9,10)]
Nov 25 13:02:59 lbtest1 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER \
                STATE
Nov 25 13:03:00 lbtest1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Nov 25 13:03:00 lbtest1 Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Nov 25 13:03:00 lbtest1 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs \
                on eth0 for 128.120.33.211
Nov 25 13:03:00 lbtest1 avahi-daemon[2136]: Registering new address record for \
                128.120.33.211 on eth0.
Nov 25 13:03:05 lbtest1 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs \
                on eth0 for 128.120.33.211
Nov 25 13:03:08 lbtest1 Keepalived_vrrp: VRRP_Script(chk_haproxy) succeeded
Nov 25 13:03:38 lbtest1 Keepalived_vrrp: VRRP_Script(chk_haproxy) failed
Nov 25 13:18:18 lbtest1 Keepalived_vrrp: VRRP_Script(chk_haproxy) succeeded

The /var/log/messages on the Backup
===================================
Nov 25 13:04:05 lbtest2 Keepalived: Starting Keepalived v1.1.19 (11/20,2009) 
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: Registering Kernel netlink reflector
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: Registering Kernel netlink command channel
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: Registering gratutious ARP shared channel
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: Opening file \
                '/opt/keepalived/etc/keepalived.conf'. 
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: Configuration is using : 35160 Bytes
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: Using LinkWatch kernel netlink reflector...
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
Nov 25 13:04:05 lbtest2 Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), \
                fd(9,10)]
Nov 25 13:04:05 lbtest2 Keepalived: Starting VRRP child process, pid=12686


And my keeplalived.conf on the Master
=====================================
vrrp_script chk_haproxy {
 	script "killall -0 haproxy"
 	interval 10
 	weight 10
}
vrrp_instance VI_1 {
 	interface eth0
 	state MASTER
 	virtual_router_id 51
 	priority 100
 	virtual_ipaddress {
 		A.B.C.1
 	}
 	notify_master /opt/keepalived/bin/notify_master.sh
 	notify_backup /opt/keepalived/bin/notify_backup.sh
 	notify_fault /opt/keepalived/bin/notify_backup.sh
 	track_script {
 		chk_haproxy weight 20
 	}
}

And my keeplalived.conf on the Backup
=====================================
vrrp_script chk_haproxy {
 	script "killall -0 haproxy"
 	interval  10
 	weight  10
}
vrrp_instance VI_1 {
 	interface eth0
 	state BACKUP
 	virtual_router_id 51
 	priority 90
 	virtual_ipaddress {
 		A.B.C.2
 	}
 	notify_master /opt/keepalived/bin/notify_master.sh
 	notify_backup /opt/keepalived/bin/notify_backup.sh
 	notify_fault /opt/keepalived/bin/notify_backup.sh
 	track_script {
 		chk_haproxy weight 20
 	}
}

The notify_master.sh script on both Master and Backup
=====================================================
#!/bin/sh
/opt/haproxy/sbin/haproxy -f /opt/haproxy/etc/haproxy.cfg &
exit 0

The notify_backup.sh script on both Master and Backup
=====================================================
#!/bin/sh
/usr/bin/killall -TERM haproxy
exit 0


PH

Paul Hirose          : pthirose@ucdavis.edu : Sysadm Motto: rm -fr /MyLife

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Keepalived-devel mailing list
Keepalived-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/keepalived-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic