[Pacemaker] Oracle 10g Express edition OCF cluster script
Dejan Muhamedagic
dejanmm at fastmail.fm
Tue Jan 18 16:31:43 UTC 2011
Hi,
On Tue, Jan 18, 2011 at 04:02:56PM +0100, Ladislav Jech wrote:
> Hi,
>
> it's already some time ago, when was asked to configure cluster for
> Oracle Database 10g Express Edition. The included scripts for oracle in
> repository didn't work well, so I created my own script and while
Wonderful. It didn't occur to you to ask for advice on this ML
or at linux-ha?
It looks like nowadays everybody and their dog want to write
their own resource/stonith agents. What's up? Nothing better to
do?
Thanks,
Dejan
> playing with pacemaker and corosync application blocks and communicating
> with Andrew Beekhof he told me to share this script with community.
>
> The script is still not finished. There are details which schould be
> done more preciously, but it is works. If someone want to test it and
> use it, please don't hesitate and let me know about what could be done
> in better way.
>
> Hope it will help someone.
>
> The script itself>
> #!/bin/sh
> #
> #
> # Oracle Database Express OCF RA.
> #
> # Copyright (c) 2010 Ladislav Jech
> # All Rights Reserved.
> #
> # This program is free software; you can redistribute it and/or modify
> # it under the terms of version 2 of the GNU General Public License as
> # published by the Free Software Foundation.
> #
> # This program is distributed in the hope that it would be useful, but
> # WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> #
> # Further, this software is distributed without any warranty that it is
> # free of the rightful claim of any third person regarding infringement
> # or the like. Any license provided herein, whether implied or
> # otherwise, applies only to this software file. Patent licenses, if
> # any, provided herein do not apply to combinations of this program with
> # other software, or any other product whatsoever.
> #
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, write the Free Software Foundation,
> # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> #
> ##############################
> #########################################
> # Initialization:
>
> : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
> . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
> # . /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
> # Set up oracle environment variables
> . /ip/oracle/scripts/oracle_env.sh
>
>
> #######################################################################
>
> meta_data() {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="oracle-db-express" version="1.1">
> <version>1.0</version>
>
> <longdesc lang="en">
> This is resource agent used explicitly for Oracle Database Express 10g
> instead of currently implemented 2 agents delivered with Pacemaker.
> </longdesc>
> <shortdesc lang="en">Oracle Database Express agent</shortdesc>
>
> <parameters>
> <parameter name="state" unique="1">
> <longdesc lang="en">
> Location to store the resource state in.
> </longdesc>
> <shortdesc lang="en">State file</shortdesc>
> <content type="string"
> default="${HA_VARRUN}/{OCF_RESOURCE_INSTANCE}.state" />
> </parameter>
> </parameters>
>
> <actions>
> <action name="start" timeout="90" />
> <action name="stop" timeout="100" />
> <action name="monitor" timeout="20" interval="10" depth="0"
> start-delay="30" />
> <action name="meta-data" timeout="5" />
> <action name="validate-all" timeout="30" />
> </actions>
> </resource-agent>
> END
> }
> #######################################################################
>
> # don't exit on TERM, to test that lrmd makes sure that we do exit
> trap sigterm_handler TERM
> sigterm_handler() {
> ocf_log info "They use TERM to bring us down. No such luck."
> return
> }
> oracle_usage() {
> cat <<END
> usage: $0 {start|stop|monitor|validate-all|meta-data}
>
> Expects to have a fully populated OCF RA-compliant environment set.
> END
> }
> #######################################################################
> # ORACLE START UP
> #ca
> oracle_start() {
> su -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/sqlplus -s /nolog @
> $ORACLE_HOME/config/scripts/startdb.sql"
> su -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
> return $OCF_SUCCESS
>
> }
> #######################################################################
> # ORACLE SHUTDOWN
> #
> oracle_stop() {
> su -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/sqlplus -s /nolog @
> $ORACLE_HOME/config/scripts/stopdb.sql"
> su -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
> return $OCF_SUCCESS
> }
> ####################################################################
> # ORACLE MONITORING
> #
> oracle_monitor() {
> # Monitor _MUST!_ differentiate correctly between running
> # (SUCCESS), failed (ERROR) or _cleanly_ stopped (NOT RUNNING).
> # That is THREE states, not just yes/no.
> pmon=`ps -ef | egrep pmon_$ORACLE_SID'\>' | grep -v grep`
> # !!! Here schould appear also the check for running listener !!!
> if [ "$pmon" != "" ]; then
> return $OCF_SUCCESS
> else
> return $OCF_NOT_RUNNING
> fi
> if false ; then
> return $OCF_ERR_GENERIC
> fi
> }
> oracle_validate() {
> # Is the state directory writable?
> state_dir=`dirname "$OCF_RESKEY_state"`
> touch "$state_dir/$$"
> if [ $? != 0 ]; then
> return $OCF_ERR_ARGS
> fi
> rm "$state_dir/$$"
>
> return $OCF_SUCCESS
> }
> : ${OCF_RESKEY_CRM_meta_interval=0}
> : ${OCF_RESKEY_CRM_meta_globally_unique:="true"}
>
> if [ "x$OCF_RESKEY_state" = "x" ]; then
> if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
> state="${HA_VARRUN}/${OCF_RESOURCE_INSTANCE}.state"
>
> # Strip off the trailing clone marker
> OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/`
> else
> OCF_RESKEY_state="${HA_VARRUN}/${OCF_RESOURCE_INSTANCE}.state"
> fi
> fi
>
> case $__OCF_ACTION in
> meta-data)
> meta_data
> exit $OCF_SUCCESS
> ;;
> start)
> oracle_start
> ;;
> stop)
> oracle_stop
> ;;
> monitor)
> oracle_monitor
> ;;
> validate-all)
> oracle_validate
> ;;
> usage|help)
> oracle_usage
> exit $OCF_SUCCESS
> ;;
> *)
> oracle_usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac
> rc=$?
> ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
> exit $rc
>
> Let me know about your proposals to enhance this.
>
> Best regards,
>
> _______________________________________________
> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
More information about the Pacemaker
mailing list