From owner-freebsd-questions@FreeBSD.ORG Fri Nov 4 23:26:36 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7E8116A420 for ; Fri, 4 Nov 2005 23:26:36 +0000 (GMT) (envelope-from djh@nebcorp.com) Received: from ratchet.nebcorp.com (ratchet.nebcorp.com [205.217.153.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6698143D45 for ; Fri, 4 Nov 2005 23:26:36 +0000 (GMT) (envelope-from djh@nebcorp.com) Received: by ratchet.nebcorp.com (Postfix, from userid 1014) id 02638D982E; Fri, 4 Nov 2005 15:26:35 -0800 (PST) Date: Fri, 4 Nov 2005 15:26:35 -0800 From: Danny Howard To: DAve Message-ID: <20051104232635.GT18563@ratchet.nebcorp.com> References: <435D5303.3030906@pixelhammer.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <435D5303.3030906@pixelhammer.com> User-Agent: Mutt/1.4.2.1i X-Loop: djhoward@uiuc.edu Cc: freebsd-questions@freebsd.org Subject: Re: Carp and Apache X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2005 23:26:37 -0000 Dave, Yes. The trick with CARP is that it is an IP-level heartbeat, so if you are running Apache, you want to "carp up" after you start apache, and "carp down" before you stop Apache. >From some test boxes, web0: ifconfig_fxp1="inet 192.168.1.210 netmask 255.255.255.0" defaultrouter="192.168.1.1" cloned_interfaces="carp0 carp1" Then, web0 application config file: export CARP_PASS="mekmitasdigoat" # MASTER export CARP_carp0_IP=192.168.1.206 export CARP_carp0_VHID=1 # SLAVE export CARP_carp1_IP=192.168.1.207 export CARP_carp1_VHID=2 export CARP_carp1_SKEW=100 Next, the Application "control" script: # CARP carp_ifs=`ifconfig -l | tr ' ' '\n' | grep carp` # Set up CARP for carp_if in $carp_ifs; do eval carp_ip=\$CARP_${carp_if}_IP eval carp_vhid=\$CARP_${carp_if}_VHID eval carp_skew=\$CARP_${carp_if}_SKEW if [ -n "$carp_vhid" ]; then carp_vhid="vhid $carp_vhid" fi if [ -n "$carp_skew" ]; then carp_skew="advskew $carp_skew" fi if [ -n "${carp_ip}" -a -n "${carp_vhid}" ]; then ifconfig $carp_if pass "$CARP_PASS" $carp_vhid $carp_skew $carp_ip ifconfig $carp_if down else echo "WARNING: $carp_if but missing CARP_${carp_if}_IP or CARP_${carp_if}_VHID!" fi done [... later ...] if [ $status -eq 0 ]; then echo "Apache successfully ${cmd}ed" echo "Ready to CARP UP!" if [ -n "${carp_ifs}" ]; then for carp_if in $carp_ifs; do eval carp_ip=\$CARP_${carp_if}_IP eval carp_vhid=\$CARP_${carp_if}_VHID if [ -n "${carp_ip}" -a -n "${carp_vhid}" ]; then ifconfig $carp_if up fi done sysctl net.inet.carp.preempt=1 fi else echo "Apache failed to $cmd" exit 2 fi Okay, so that's really quite a mess, but basically: * Set cloned_interfaces in rc.conf to create carp at boot. * One IP alias and VHID per CARP IP. * Set up the backup server with higher advskew. * For availability, teach you apachectl script to ifconfig the carp interfaces, ifconfig down, start apache, ifconfig up, and ifconfig down before stopping / restarting apache. Cheers, -danny -- http://dannyman.toldme.com/