TweetFollow Us on Twitter

OSX IP Failover, Part 2

Volume Number: 23 (2007)
Issue Number: 04
Column Tag: Network Administration

OSX IP Failover, A Beginners Guide (Part 2)

Giving IP Failover a Real Job

By Ben Greisler

Introduction

In the previous article, we looked at the general concepts involved with IP failover on OSX and how to set it up. At this point if you set up a pair of machines and tried out the failover process you would have simply had one machine take the IP address of the other. While that is certainly nice, it doesn't really do anything productive for us. In this article we will look at making IP failover do some real work and start to become productive.

NOTE: In Part 1 of this article, there was a small terminology error: The line, "Within that folder can be 4 subfolders: PreAcq, PostAcq, PreRel and PostRel." Should read, "Within that folder can be 4 scripts: PreAcq, PostAcq, PreRel and PostRel." Instead of 'subfolders', it's 'scripts'. I apologize for any confusion.

IP Failover Considerations

At its core, IP failover describes one machine taking the IP of another. Unless we tell the machines otherwise, this is all that will happen. We need to take a few additional steps for the secondary machine to be able to take on the personality of the failed primary server.

We first need to determine what services need to be running on the primary machine so we can make sure they are available on the backup machine when failover occurs. Is it a web server? A file server? An application server? Are there ancillary services running that support the primary function such as a database that feeds a web server? Everything that is running on the primary server needs to run on the secondary.

If you need authentication services for the secondary server in an Open Directory system, consider making the secondary server a replica of the OD master. This gives you built-in and automatic failover for OD.

Another consideration is how do we get the data that the primary server uses over to the secondary server. For static content such as web pages, it may be appropriate to make a copy of the data on the secondary server and be done with it. The problem with that is if the data changes at any point, you have to remember to update it on both machines. If you don't,

you will end up with old data being served by the secondary server. This indicates the need for shared data between the two servers where if it is updated or changed, it is automatically updated on both.

So what are our choices for synchronized data? If the amount of data is relatively small, we could write a script to copy the data from the primary server to the secondary server on a regular basis. This may be appropriate for web pages or content that doesn't change that much. If we have data that is constantly changing, we may want to look into shared storage such as an XSan volume. Another choice is to use external storage that gets mounted on demand when the failover occurs.

Action Scripts

Part of the process of IP failover is the server checking the /Library/IPFailover/<IP address> folder on the secondary server for various scripts. The scripts need to be prefaced with PreAcq, PostAcq, PreRel or PostRel. If there are multiple scripts of one of the 4 types, they will be performed in alphabetical order (i.e.: PostAcq_a, PostAcq_b, etc.).

A script with the PreAcq prefix is run before the network interface on the secondary server takes on the IP of the primary server during failover.

A script with the PostAcq prefix is run after the network interface on the secondary server takes on the IP of the primary server during failover.

A script with the PreRel prefix is run before the network interface on the secondary server releases the IP of the primary server during failback. A script with the PostRel prefix is run after the network interface on the secondary server releases the IP of the primary server during failback. The scripts can be written to perform just about any action you may need to occur during each part of the process. You may want to include writing out to a log or maybe send informational emails. You may need the scripts to start or stop services and mount or unmount volumes.

For example, we might need to mount a volume on the secondary server since we don't want to have the same volume mounted on both servers at the same time, assuming we don't have them as part of a SAN. By the way, a SAN is a great idea for this situation as we can avoid many of the pitfalls of having to mount and unmount volumes. The fstab entry for preventing the mounting of a volume will look something like this:

UUID=2B228FFC-B727-2910-A3B9-917CBAD7134F       none   hfs   rw,noauto

We will need a PreAcq script that may look like this:

diskutil list | grep webstuff | awk ' {print $6 } ' >> /tmp/XRAID_1
diskutil mount $(cat /tmp/XRAID_1)
mount -uw /Volumes/webstuff

This PreAcq script mounts the volume named "webstuff" and mounting the volume would be required if we had edited fstab to prevent mounting of the volume on startup of the secondary server. Once we have mounted the volume and the secondary server has taken over the IP of the primary server, we need to start the services on the secondary server. We might use a PostAcq script that looks like this:

sudo serveradmin start web

or

sudo serveradmin start afp

Once we have the secondary server up and running we are in good shape. While I recommend not directly failing a server back, you might decide that this is fine for your needs. In this case we need to look into the Pre and Post Release scripts. As we know that the services are about to be reassigned to the primary server, we need to stop the services on the secondary server. The PreRel script might look like this:

sudo serveradmin stop web

or

sudo serveradmin stop afp

Then, as part of the same script or possibly another PreRel script, remembering to name them in the order you want them acted on, you will need to unmount the volume that will be picked back up by the primary server:

sudo diskutil unmount /Volumes/webstuff

Once the secondary server has relinquished the primary servers IP the final script is run and that is the PostRel script or scripts. You might want to put an email notification script together or simply log the event:

logger "Completed failback"

AFP Special Considerations

One of the obvious uses of IP failover is to provide seamless protection for file sharing. While IP failover can be used for AFP file servers, AFP has an interesting twist; AFP uses a special cache at /etc/AFP.conf to determine if incoming connections are new or reconnects. The Finder on a client machine disconnected during failover will try to reconnect and is expecting a reconnect. However, if the secondary server has picked up AFP duties from the primary server, it won't know that the client is trying for a reconnect and not a new connection.

Hmm, so what do we do about this? By providing a place for AFP.conf to live on some shared storage is the key. This might be an Xserve RAID volume that both machines can see at the same time. I know that we try to avoid the situation where more than one server can write to a volume, but we have to do that in this case. We also need to point the reconnectKeyLocation key that lives in the /Library/Preferences/com.apple.AppleFileServer.plist to point to the shared location:

<key>reconnectKeyLocation</key>
<string>/Volumes/AFPToken/AFP.conf</string>

And while it is tempting to do so, I can't recommend using IP failover for network home folders. Try it if you want, but I suspect you will find that the clients will have issues with it, even with automatic reconnect.

Conclusion

IP failover can be a powerful tool when it is well thought out and matched to the appropriate need. It is not the end all, be all of high availability, but it can help us add an occasional extra "9" to our uptime percentages. The intention of this article was to give you the most basic tools needed to implement IP failover and to give you a jumping off point. Take these tools and examples and try it out on your own.


Ben has worked Apple based technology integration projects from Maine to Japan while learning all the way. When not collecting frequent flyer miles he spends his favorite time with his wife and 2.5 year old daughter at their home outside of Philadelphia. He can be reached at magikben@mac.com.

 
AAPL
$524.94
Apple Inc.
+5.93
MSFT
$40.01
Microsoft Corpora
-0.39
GOOG
$536.10
Google Inc.
-20.44

MacTech Search:
Community Search:

Software Updates via MacUpdate

Tweetbot 1.5.1 - Popular iOS twitter cli...
Tweetbot is a full-featured OS X Twitter client with a lot of personality. Whether it's the meticulously-crafted interface, sounds and animation, or features like multiple timelines and column views... Read more
Mac DVDRipper Pro 4.1.7 - Copy, backup,...
Mac DVDRipper Pro is the DVD backup solution that lets you protect your DVDs from scratches, save your batteries by reading your movies from your hard disk, manage your collection with just a few... Read more
PDFpenPro 6.2 - Advanced PDF toolkit for...
PDFpenPro allows users to edit PDF's easily. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Create... Read more
PDFpen 6.2 - Edit and annotate PDFs with...
PDFpen allows users to easily edit PDF's. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Features... Read more
Monolingual 1.5.9 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
Starcraft II: Wings of Liberty 1.1.1.180...
Download the patch by launching the Starcraft II game and downloading it through the Battle.net connection within the app. Starcraft II: Wings of Liberty is a strategy game played in real-time. You... Read more
Sibelius 7.5.0 - Music notation solution...
Sibelius is the world's best-selling music notation software for Mac. It is as intuitive to use as a pen, yet so powerful that it does most things in less than the blink of an eye. The demo includes... Read more
Typinator 5.9 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
MYStuff Pro 2.0.16 - Create inventories...
MYStuff Pro is the most flexible way to create detail-rich inventories for your home or small business. Add items to MYStuff by dragging and dropping existing information, uploading new images, or... Read more

Latest Forum Discussions

See All

Have a Special Dead Trigger 2 Easter Bas...
Have a Special Dead Trigger 2 Easter Basket Full of Goodies, Courtesy of Madfinger Games Posted by Rob Rich on April 18th, 2014 [ permalink ] Dead Trigger 2 | Read more »
Zynga Launches Brand New Farmville Exper...
Zynga Launches Brand New Farmville Experience with Farmville 2: Country Escape Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
David. Review
David. Review By Cata Modorcea on April 18th, 2014 Our Rating: :: MINIMALISTIC IN A DIFFERENT WAYUniversal App - Designed for iPhone and iPad David is a minimalistic game wrapped inside of a soothing atmosphere in which the hero... | Read more »
Eyefi Unveils New Eyefi Cloud Service Th...
Eyefi Unveils New Eyefi Cloud Service That Allows Users to Share Media Across Personal Devices Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
Tales from the Dragon Mountain: The Lair...
Tales from the Dragon Mountain: The Lair Review By Jennifer Allen on April 18th, 2014 Our Rating: :: STEADY ADVENTURINGiPad Only App - Designed for the iPad Treading a safe path, Tales from the Dragon Mountain: The Lair is a... | Read more »
Yahoo Updates Flickr App with Advanced E...
Yahoo Updates Flickr App with Advanced Editing Features and More Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
My Incredible Body - A Kid's App to...
My Incredible Body - A Kid's App to Learn about the Human Body 1.1.00 Device: iOS Universal Category: Education Price: $2.99, Version: 1.1.00 (iTunes) Description: Wouldn’t it be cool to look inside yourself and see what was going on... | Read more »
Trials Frontier Review
Trials Frontier Review By Carter Dotson on April 18th, 2014 Our Rating: :: A ROUGH LANDINGUniversal App - Designed for iPhone and iPad Trials Frontier finally brings the famed stunt racing franchise to mobile, but how much does its... | Read more »
Evernote Business Notebook by Moleskin I...
Evernote Business Notebook by Moleskin Introduced – Support Available in Evernote for iOS Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
Sparkle Unleashed Review
Sparkle Unleashed Review By Jennifer Allen on April 18th, 2014 Our Rating: :: CLASSY MARBLE FLINGINGUniversal App - Designed for iPhone and iPad It’s a concept we’ve seen before, but Sparkle Unleashed is a solidly enjoyable orb... | Read more »

Price Scanner via MacPrices.net

iMacs on sale for up to $160 off MSRP this we...
Best Buy has iMacs on sale for up to $160 off MSRP for a limited time. Choose free home shipping or free instant local store pickup (if available). Prices are valid for online orders only, in-store... Read more
iPad Airs on sale this weekend for up to $100...
Best Buy has WiFi iPad Airs on sale for $50 off MSRP and WiFi + Cellular iPad Airs on sale for $100 off MSRP on their online store for a limited time, with prices now starting at $449. Choose free... Read more
Apple restocks refurbished Mac minis starting...
The Apple Store has restocked Apple Certified Refurbished Mac minis for up to $150 off the cost of new models. Apple’s one-year warranty is included with each mini, and shipping is free: - 2.5GHz Mac... Read more
Hyundai Brings Apple CarPlay To The 2015 Sona...
Hyundai Motor America has announced it will bring Apple CarPlay functionality to the 2015 Sonata. CarPlay is pitched as a smarter, safer and easier way to use iPhone in the car and gives iPhone users... Read more
Updated iPads Coming Sooner Than We Had Thoug...
MacRumors, cites KGI securities analyst Ming Chi Kuo, well-respected as an Apple product prognisticator, saying that Apple will introduce an upgraded iPad Air and iPad mini in 2014/Q3, meaning the... Read more
Toshiba Unveils New High And Low End Laptop M...
Toshiba has announced new laptop models covering both the high-end and low-end of the notebook computer spectrum. Toshiba 4K Ultra HD Laptop Toshiba’s new Satellite P55t features one of the world’s... Read more
Save up to $270 with Apple refurbished 13-inc...
The Apple Store has Apple Certified Refurbished October 2013 13″ Retina MacBook Pros available starting at $1099, with models up to $270 off MSRP. Apple’s one-year warranty is standard, and shipping... Read more
Apple now offering refurbished iPad mini with...
The Apple Store has Certified Refurbished 2nd generation iPad minis with Retina Displays now available starting at $339. Apple’s one-year warranty is included with each model, and shipping is free.... Read more
Microsoft Blinks – Drops Microsoft Office 365...
Microsoft has dropped the annual subscription fee for Microsoft Office 365 Personal – which is needed in order to create and edit documents in Microsoft Office for iPad. However, Apple’s iOS and OS X... Read more
New AVG Vault Apps for iOS and Android Help K...
AVG Technologies N.V. an online security company for 177 million active users, has announced the launch of its latest mobile application, AVG Vault. The free app introduces an innovative user... Read more

Jobs Board

*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Retail - Manager - Holyoke - Apple I...
Job Summary Keeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you’re a master of them all. In the store’s fast-paced, Read more
*Apple* Retail - Manager - Apple (United Sta...
Job SummaryKeeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you're a master of them all. In the store's fast-paced, dynamic Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Retail - Market Leader - Cincinnati...
…challenges of developing individuals, building teams, and affecting growth across Apple Stores. You demonstrate successful leadership ability - focusing on excellence Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.