[Linux-ha-dev] Can HB control conjob-like tasks?

Max Hofer max.hofer at apus.co.at
Tue May 22 02:55:25 MDT 2007


On Monday 21 May 2007, Knight, Doug wrote:
> Is it possible to configure heartbeat to trigger a job that would
> normally be triggered as a cronjob? For instance, I have a database
> maintenance script that only runs once a night during a non-peak period.
> It assumes that it is running on a server where the database is
> available. What I'd like to be able to do is configure heartbeat to
> trigger this job once a day, just like crontab is currently doing, but
> ONLY on the server where the database is currently running and managed
> by heartbeat. I plan on modifying the crontab script to become an
> LSB/OCF type script accessible by heartbeat.
> 
> Doug Knight
> WSI, Inc.
> Andover, MA
> 
We had the same need of such a functionality. I spent some time thinking
of a solution and came to following conclusion:

a) write a normal cron script and install it on all nodes where it should run. 
This script needs to check if the desried resource (in your case the DB) 
runs on the node, and if this is the case do something (start a cleanup 
script). If it is not the case, do nothing.

----- Pseudocode on -----
log start cleanup service
if crm_resource -W db_resource == `hostname` then
   log starting cleanup on `hostname`for resource db_resource
   rc = ""start cleanup"
   if rc == OK then
      log cleanup successful
  else
      log cleanup interrupted wirh error code rc
  fi
else
   log skipping cleanup - reosurce not running on this node
fi
----- Pseudocode off -----

b) integrate following functioanity into HB:
- a hook for a resource which is called at a certrain time period


Now some thoughts (applying for both cases):
1. the cleanup script will under no circumstances screw up data when
it is interrupted (if this is not the case you are in trouble)
2. what happens when the resource (which is used by the cleanup
script) fails over when your cleanup script is called?

1. is a pre-condition 

For 2. i see follwowing spolutions:
i) don't bother about the interrupt and make the cleanup on the next
cleanup period
ii) start cleanup on the other node again as soon the resource is up again

Since i sticked for solution i) cron does pretty well if you make your cleanup
script as described in a). 

Solution b) is only needed if you really need ii). 





More information about the Linux-HA-Dev mailing list