running something different in heartbeat if I'm a failed node!

Juri Haberland juri@koschikode.com
Thu, 15 Feb 2001 19:08:43 +0100


Jeremy Hansen wrote:
> 
> On Wed, 14 Feb 2001, Horms wrote:
> 
> > On Wed, Feb 14, 2001 at 11:09:36AM -0500, Jeremy Hansen wrote:
> > >
> > > I'd like to know if it's possible to spawn applications based on the state
> > > of the node.
> > >
> > > For example, my primary fails, secondary node takes over, runs my
> > > application in haresources.  I'm using nice_fallback, so the secondary is
> > > now the real primary.  What i'd like to see is the ability to run another
> > > application on the original primary depending on the state of the node.
> > >
> > > Oh, I'm now the secondary, I'll run mon.
> > >
> > > Oh, I'm the primary again, I'll run mysql.
> > >
> > > Are ya pickin' up what I'm layin' down?
> > >
> > > Perhaps this is already available?  It would be swell for what I'm trying
> > > to do.
> >
> > Yes
> >
> > The resources specified in the haresources are shell scripts. As such
> > you can used them to start and stop arbiatry programmes on the system.
> > Just define a new resource for each programme you want started
> > and stoped and add the resource to the appropriate haresources line.
> 
> Ok, well help me understand things in this scenerio.  I feel like I'm not
> getting something.
> 
> NODE A which is primary completely die, someone kicks the power, NODE B
> takes over, and in my specific case, haresources starts up mysql when it
> gets the ip, but when NODE A comes back up, how in haresources do I say,
> "ok, we're no longer the master, instead of attempting to start mysql, I
> want to start mon instead.  If we become master again, shut down mon and
> start up mysql."
> 
> Now in cases where the primary node is available, then I could see
> something that rewrites the haresources file depending on who is primary,
> but in a case where the node completely dies, how would this be done.

I would go an easier way:
In any case start mon at system startup. Write a little rc-script which
has the reverse function of the original mon rc-script (if called with
start mon will be stopped). Than put the name of this rc-script in your
haresources file together with the name of the mysql rc-script. If
heartbeat starts and decides to takeover the resource group it will stop
mon and start mysql. If for any reason heartbeat decides to give up the
resource group it will stop mysql and start mon.
That's all.

Juri