From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96507962922445.tru64-unix-managers.marc@archive.invalid> From: Gregory Dora Date: Mon, 31 Jul 2000 21:40:25 +0000 To: tru64-unix-managers Subject: Summary: cron on ase cluster with oracle X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96507962922445 The Question was: With ase clustering how do you run the cron job on the node that is "active" only? As I log _every_ cron job, I want to avoid 50%+ of logs showing failure. Many thanks to all that responded: Scott Mutchler Ivan Hoe Richard Tame Robert Mulley Danielle Georgette Hoai TRAN Alex Nord Rich Martin Andersson Kris Chandrasekhar Con Tassios Wendy Fong Larry Clegg Ricardo Ramos The answer from 14 of 16 respondents was to run identical crontabs and code the jobs to exit early if they are not running on the active machine. As, I was fishing for a more sophisticated solution, I was happy to get two slick solutions too. But, the testing effort to implement the slick solutions is quite high. So, I think that for the next 6 months or so till we upgrade to 5.1, something like the below will work, when applied identically on both nodes, will work. 0 6 * * * test -d /app/oracle/local/bin && /app/oracle/local/bin/compute_statistics.ksh This implementation only invokes the script if it's directory has been mounted. This is different than simply checking for the script to exist, or the script being executable. Mistakes in spelling and permissions are common user errors, but hopefully directory will exist unless the mount is not on the machine. This seems to me to be a much better solution than I would have had without all the ideas sent in, THANKS to all the contributers! Greg ---------------------------------------------------------------------------- --------------- Con Tassios - I have a cron daemon for each cluster service. The cron binaries and crontabs reside on the shared storage device which is part of that service. The ASE script for the service starts/stop the cron daemon. Therefore the cron daemon for a service moves from one machine to another just like the filesystems. ---------------------------------------------------------------------------- --------------- Danielle Georgette -- We manage this situation by writing two crontabs for root (or any other user). One is the plain crontab that contains all the system housekeeping etc that needs to be done regardless of the node running the cluster service. The other has all the additions required when it is actively running the service. We call them root.cluster and root.standalone, and keep them in /var/spool/crontabs (ie locally) on each machine. The start script for the service copies the root.cluster crontab to be the root crontab. The stop script for the same service copies the root.standalone to be the active root crontab. Then they both grep for the cron pid and send it a hup. Voila, works perfectly and is a very simple solution. Just make sure you make any crontab changes to the relevant root.XXX files and not the running root cron, because they will be lost on the next cluster transition (it happened to us and we were rather annoyed at our silliness). There would probably be a way of keeping the two crontabs in with the cluster info but I havent done that yet - it would remove the only downside, which is having to have local copies of the crontabs on each cluster member. Anyway, hope this helps! Danielle ps Robert Mulley, who is also a member of this list, designed this solution, so some of the kudos go to him for this solution. ---------------------------------------------------------------------------- ------------- Use an environment variable or check a file or mount point to see if Oracle is running on the node...if you don't find it then let the cron job exit otherwise it proceeds and does its thing. When I had an ASE cluster I checked for the mount point since under ASE the disks are not shared...if I didn't find the mount point then the cron job exited. Hope this helps...and get upgraded to V5.0a asap...it is wonderful... ---------------------------------------------------------------------------- ------------- You can still run the cronjob on both machine. Write the cron job as a script. Have the script check for the activemachine. Exit for non-active machine. ---------------------------------------------------------------------------- ------------- Richard Tame The scripts for your cron jobs should be on shared space. All you need to do is check if the script is executable (test -x), if the service is on the other node it won't exist and therefore can't be executed. If you are running a late enough version there is an example of this in the cron table for 'defragcron'. [found it] #1 1 * * * test -x /usr/sbin/defragcron && /usr/sbin/defragcron -p >>/usr/adm/defragcron.log 2>& ---------------------------------------------------------------------------- ------------- In V40x, you can have your script do "asemgr -d" or "asemgr -d -v servicename|grep $nodename" where you got the nodename earlier. Check $? (status) to see if the service is there. In V50A, you can similarly do a "caa_stat" or "caa_stat servicename" and parse the output to determine whether the service is on your node. ---------------------------------------------------------------------------- ------------- I would have the script called by cron to check who is the director. Use: asemgr -d -v and grep for the name of the host. Then you can decide where to run your job. Or, df and grep for the name of the nfs partitions. ---------------------------------------------------------------------------- ------------- You could check on what node the service actually runs on, using asemgr -dv and then grepping for the service name and the hostname. Or you could just check if the oracle filesystems are mounted in the script. ---------------------------------------------------------------------------- ------------- Have the cron job call a "checkaction" script, used with asemgr so that you can tell where the database is at anytime. ---------------------------------------------------------------------------- ------------- Write a simple shell script and check for the mount point where the Oracle database is mounted. If it is not mounted, then you know that the database is not running and simply exit the script. Regards, Hoai ---------------------------------------------------------------------------- ------------- Scott Mutchler there is an entry in /etc/fdmns called db_domain. I write my cron entries something like this: * * * * * [ -d /etc/fdmns/db_domain ] && /usr/local/scriptname Node B has an identical entry, but since the file domain is not present, the script exits. The only caution for using this method is that when you reboot a node - at least in my configuration - entries get made for all the known filesets under /etc/fdmns, so we make sure to relocate services back and forth, thus cleaning up the /etc/fdmns directory. If moving a service is not an option, the entry can safely be removed by hand on the node NOT running the fileset. ---------------------------------------------------------------------------- ------------- Again THANKS to all who responded. All had good ideas. This list is the best! Greg Dora Gregory.dora@citrix.com