5
# Description: Manages any type of SAP supported database instance
6
# as a High-Availability OCF compliant resource.
8
# Author: Alexander Krauth, October 2006
9
# Support: linux@sap.com
10
# License: GNU General Public License (GPL)
11
# Copyright: (c) 2006, 2007 Alexander Krauth
14
# See usage() function below for more details...
16
# OCF instance parameters:
18
# OCF_RESKEY_DIR_EXECUTABLE (optional, well known directories will be searched by default)
20
# OCF_RESKEY_NETSERVICENAME (optional, non standard name of Oracle Listener)
21
# OCF_RESKEY_DBJ2EE_ONLY (optional, default is false)
22
# OCF_RESKEY_JAVA_HOME (optional, only needed if DBJ2EE_ONLY is true and JAVA_HOME enviroment variable is not set)
23
# OCF_RESKEY_STRICT_MONITORING (optional, activate application level monitoring - with Oracle a failover will occur in case of an archiver stuck)
24
# OCF_RESKEY_AUTOMATIC_RECOVER (optional, automatic startup recovery, default is false)
25
# OCF_RESKEY_DIR_BOOTSTRAP (optional, if non standard J2EE server directory)
26
# OCF_RESKEY_DIR_SECSTORE (optional, if non standard J2EE secure store directory)
27
# OCF_RESKEY_DB_JARS (optional, if maintained in bootstrap.properties, mandatory for WebAS Java 7.10)
28
# OCF_RESKEY_PRE_START_USEREXIT (optional, lists a script which can be executed before the resource is started)
29
# OCF_RESKEY_POST_START_USEREXIT (optional, lists a script which can be executed after the resource is started)
30
# OCF_RESKEY_PRE_STOP_USEREXIT (optional, lists a script which can be executed before the resource is stopped)
31
# OCF_RESKEY_POST_STOP_USEREXIT (optional, lists a script which can be executed after the resource is stopped)
34
# Remove all the database dependend stuff from the agent and use
35
# saphostcontrol daemon as soon as SAP will release it.
37
#######################################################################
40
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
41
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
43
#######################################################################
48
methods=`sapdatabase_methods`
49
methods=`echo $methods | tr ' ' '|'`
53
$0 manages a SAP database of any type as an HA resource.
54
Currently Oracle, MaxDB and DB/2 UDB are supported.
55
ABAP databases as well as JAVA only databases are supported.
57
The 'start' operation starts the instance.
58
The 'stop' operation stops the instance.
59
The 'status' operation reports whether the instance is running
60
The 'monitor' operation reports whether the instance seems to be working
61
The 'recover' operation tries to recover the instance after a crash (instance will be stopped first!)
62
The 'validate-all' operation reports whether the parameters are valid
63
The 'methods' operation reports on the methods $0 supports
71
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
72
<resource-agent name="SAPDatabase">
73
<version>1.93</version>
76
Resource script for SAP databases. It manages a SAP database of any type as an HA resource.
78
<shortdesc lang="en">Manages any SAP database (based on Oracle, MaxDB, or DB2)</shortdesc>
81
<parameter name="SID" unique="1" required="1">
82
<longdesc lang="en">The unique SAP system identifier. e.g. P01</longdesc>
83
<shortdesc lang="en">SAP system ID</shortdesc>
84
<content type="string" default="" />
86
<parameter name="DIR_EXECUTABLE" unique="1" required="0">
87
<longdesc lang="en">The full qualified path where to find sapstartsrv and sapcontrol.</longdesc>
88
<shortdesc lang="en">path of sapstartsrv and sapcontrol</shortdesc>
89
<content type="string" default="" />
91
<parameter name="DBTYPE" unique="1" required="1">
92
<longdesc lang="en">The name of the database vendor you use. Set either: ORA,DB6,ADA</longdesc>
93
<shortdesc lang="en">database vendor</shortdesc>
94
<content type="string" default="" />
96
<parameter name="NETSERVICENAME" unique="1" required="0">
97
<longdesc lang="en">The Oracle TNS listener name.</longdesc>
98
<shortdesc lang="en">listener name</shortdesc>
99
<content type="string" default="" />
101
<parameter name="DBJ2EE_ONLY" unique="1" required="0">
102
<longdesc lang="en">If you do not have a ABAP stack installed in the SAP database, set this to TRUE</longdesc>
103
<shortdesc lang="en">only JAVA stack installed</shortdesc>
104
<content type="boolean" default="false"/>
106
<parameter name="JAVA_HOME" unique="1" required="0">
107
<longdesc lang="en">This is only needed if the DBJ2EE_ONLY parameter is set to true. Enter the path to the Java SDK which is used by the SAP WebAS Java</longdesc>
108
<shortdesc lang="en">Path to Java SDK</shortdesc>
109
<content type="string" default=""/>
111
<parameter name="STRICT_MONITORING" unique="1" required="0">
112
<longdesc lang="en">This controls how the resource agent monitors the database. If set to true, it will use SAP tools to test the connect to the database. Do not use with Oracle, because it will result in unwanted failovers in case of an archiver stuck</longdesc>
113
<shortdesc lang="en">Activates application level monitoring</shortdesc>
114
<content type="boolean" default="false"/>
116
<parameter name="AUTOMATIC_RECOVER" unique="1" required="0">
117
<longdesc lang="en">The SAPDatabase resource agent tries to recover a failed start attempt automatically one time. This is done by running a forced abort of the RDBMS and/or executing recovery commands.</longdesc>
118
<shortdesc lang="en">Enable or disable automatic startup recovery</shortdesc>
119
<content type="boolean" default="false"/>
121
<parameter name="DIR_BOOTSTRAP" unique="1" required="0">
122
<longdesc lang="en">The full qualified path where to find the J2EE instance bootstrap directory. e.g. /usr/sap/P01/J00/j2ee/cluster/bootstrap</longdesc>
123
<shortdesc lang="en">path to j2ee bootstrap directory</shortdesc>
124
<content type="string" default="" />
126
<parameter name="DIR_SECSTORE" unique="1" required="0">
127
<longdesc lang="en">The full qualified path where to find the J2EE security store directory. e.g. /usr/sap/P01/SYS/global/security/lib/tools</longdesc>
128
<shortdesc lang="en">path to j2ee secure store directory</shortdesc>
129
<content type="string" default="" />
131
<parameter name="DB_JARS" unique="1" required="0">
132
<longdesc lang="en">The full qualified filename of the jdbc driver for the database connection test. It will be automatically read from the bootstrap.properties file in Java engine 6.40 and 7.00. For Java engine 7.10 and higher the parameter is mandatory.</longdesc>
133
<shortdesc lang="en">file name of the jdbc driver</shortdesc>
134
<content type="string" default="" />
136
<parameter name="PRE_START_USEREXIT" unique="1" required="0">
137
<longdesc lang="en">The full qualified path where to find a script or program which should be executed before this resource gets started.</longdesc>
138
<shortdesc lang="en">path to a pre-start script</shortdesc>
139
<content type="string" default="" />
141
<parameter name="POST_START_USEREXIT" unique="1" required="0">
142
<longdesc lang="en">The full qualified path where to find a script or program which should be executed after this resource got started.</longdesc>
143
<shortdesc lang="en">path to a post-start script</shortdesc>
144
<content type="string" default="" />
146
<parameter name="PRE_STOP_USEREXIT" unique="1" required="0">
147
<longdesc lang="en">The full qualified path where to find a script or program which should be executed before this resource gets stopped.</longdesc>
148
<shortdesc lang="en">path to a pre-start script</shortdesc>
149
<content type="string" default="" />
151
<parameter name="POST_STOP_USEREXIT" unique="1" required="0">
152
<longdesc lang="en">The full qualified path where to find a script or program which should be executed after this resource got stopped.</longdesc>
153
<shortdesc lang="en">path to a post-start script</shortdesc>
154
<content type="string" default="" />
159
<action name="start" timeout="1800" />
160
<action name="stop" timeout="1800" />
161
<action name="status" timeout="60" />
162
<action name="monitor" depth="0" timeout="60" interval="120" />
163
<action name="validate-all" timeout="5" />
164
<action name="meta-data" timeout="5" />
165
<action name="methods" timeout="5" />
173
exit $OCF_ERR_GENERIC
178
# listener_start: Start the given listener
181
local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
182
local lrc=$OCF_SUCCESS
184
output=`echo "lsnrctl start $NETSERVICENAME" | su - $orasid 2>&1`
187
ocf_log info "Oracle Listener $NETSERVICENAME started: $output"
190
ocf_log err "Oracle Listener $NETSERVICENAME start failed: $output"
197
# listener_stop: Stop the given listener
200
local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
201
local lrc=$OCF_SUCCESS
205
: listener is running, trying to stop it later...
210
output=`echo "lsnrctl stop $NETSERVICENAME" | su - $orasid 2>&1`
213
ocf_log info "Oracle Listener $NETSERVICENAME stopped: $output"
215
ocf_log err "Oracle Listener $NETSERVICENAME stop failed: $output"
222
# listener_status: is the given listener running?
225
local lrc=$OCF_SUCCESS
226
local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
227
# Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
228
# as the output might be to long.
229
local cnt=`ps efo args --user $orasid | grep $NETSERVICENAME | grep -c tnslsnr`
234
ocf_log info "listener process not running for $NETSERVICENAME for $SID"
241
# x_server_start: Start the given x_server
244
local rc=$OCF_SUCCESS
246
output=`echo "x_server start" | su - $sidadm 2>&1`
249
ocf_log info "MaxDB x_server start: $output"
252
ocf_log err "MaxDB x_server start failed: $output"
259
# x_server_stop: Stop the x_server
262
local lrc=$OCF_SUCCESS
264
output=`echo "x_server stop" | su - $sidadm 2>&1`
267
ocf_log info "MaxDB x_server stop: $output"
269
ocf_log err "MaxDB x_server stop failed: $output"
276
# x_server_status: is the x_server running?
279
local lrc=$OCF_SUCCESS
280
local sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
281
# Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
282
# as the output might be to long.
283
local cnt=`ps efo args --user $sdbuser | grep -c vserver`
288
ocf_log info "x_server process not running"
295
# oracle_stop: Stop the Oracle database without any condition
302
if [ -x "${ORACLE_HOME}/bin/sqlplus" ]
304
SRVMGRDBA_EXE="${ORACLE_HOME}/bin/sqlplus"
306
echo "Can not find executable sqlplus" >> $LOG
310
$SRVMGRDBA_EXE /NOLOG >> $LOG << !
317
exit $rc' > $TEMPFILE
320
chown $sidadm $TEMPFILE
322
su - $sidadm -c $TEMPFILE
326
if [ $retcode -eq 0 ]; then
328
if [ $? -ne $OCF_NOT_RUNNING ]; then
337
# maxdb_stop: Stop the MaxDB database without any condition
341
# x_Server must be running to stop database
343
if [ $? -ne $OCF_SUCCESS ]; then x_server_start; fi
345
if [ $DBJ2EE_ONLY -eq 1 ]; then
352
LOG=\$HOME/stopdb.log
354
echo \"Stop database with xuserkey >$userkey<\" >> \$LOG
355
dbmcli -U ${userkey} db_offline >> \$LOG 2>&1
356
exit \$?" > $TEMPFILE
359
chown $sidadm $TEMPFILE
361
su - $sidadm -c $TEMPFILE
365
if [ $retcode -eq 0 ]; then
367
if [ $? -ne $OCF_NOT_RUNNING ]; then
376
# db6udb_stop: Stop the DB2/UDB database without any condition
382
echo "Shut down the database" >> $LOG
383
$INSTHOME/sqllib/bin/db2 deactivate database $DB2DBDFT |tee -a $LOG 2>&1
384
$INSTHOME/sqllib/adm/db2stop force |tee -a $LOG 2>&1
388
chown $sidadm $TEMPFILE
390
su - $sidadm -c $TEMPFILE
394
if [ $retcode -eq 0 ]; then
396
if [ $? -ne $OCF_NOT_RUNNING ]; then
405
# oracle_recover: try to clean up oracle after a crash
409
LOG=$HOME/recover.log
411
echo "Logfile written by heartbeat SAPDatabase resource agent" >> $LOG
413
if [ -x "${ORACLE_HOME}/bin/sqlplus" ]
415
SRVMGRDBA_EXE="${ORACLE_HOME}/bin/sqlplus"
417
echo "Can not find executable sqlplus" >> $LOG
421
$SRVMGRDBA_EXE /NOLOG >> $LOG << !
425
alter database end backup;
431
exit $rc' > $TEMPFILE
434
chown $sidadm $TEMPFILE
436
su - $sidadm -c $TEMPFILE
444
# maxdb_recover: try to clean up MaxDB after a crash
447
# x_Server must be running to stop database
449
if [ $? -ne $OCF_SUCCESS ]; then x_server_start; fi
451
if [ $DBJ2EE_ONLY -eq 1 ]; then
458
LOG=\$HOME/recover.log
460
echo \"Logfile written by heartbeat SAPDatabase resource agent\" >> \$LOG
461
echo \"Cleanup database with xuserkey >$userkey<\" >> \$LOG
462
echo \"db_stop\" >> \$LOG 2>&1
463
dbmcli -U ${userkey} db_stop >> \$LOG 2>&1
464
echo \"db_clear\" >> \$LOG 2>&1
465
dbmcli -U ${userkey} db_clear >> \$LOG 2>&1
466
echo \"db_online\" >> \$LOG 2>&1
467
dbmcli -U ${userkey} db_online >> \$LOG 2>&1
470
exit \$rc" > $TEMPFILE
473
chown $sidadm $TEMPFILE
475
su - $sidadm -c $TEMPFILE
483
# db6udb_recover: try to recover DB/2 after a crash
486
db2sid="db2`echo $SID | tr '[:upper:]' '[:lower:]'`"
489
LOG=$HOME/recover.log
491
echo "Logfile written by heartbeat SAPDatabase resource agent" >> $LOG
492
$INSTHOME/sqllib/bin/db2_kill >> $LOG 2>&1
493
$INSTHOME/sqllib/adm/db2start >> $LOG 2>&1
494
$INSTHOME/sqllib/bin/db2 activate database $DB2DBDFT >> $LOG 2>&1
497
exit $rc' > $TEMPFILE
500
chown $db2sid $TEMPFILE
502
su - $db2sid -c $TEMPFILE
510
# methods: What methods/operations do we support?
512
sapdatabase_methods() {
528
# sapuserexit : Many SAP customers need some additional processes/tools to run their SAP systems.
529
# This specialties do not allow a totally generic SAP cluster resource agent.
530
# Someone should write a resource agent for each additional process you need, if it
531
# is required to monitor that process within the cluster manager. To enable
532
# you to extent this resource agent without developing a new one, this user exit
543
ocf_log info "Calling userexit ${NAME} with customer script file ${VALUE}"
544
"$VALUE" >/dev/null 2>&1
545
ocf_log info "Exiting userexit ${NAME} with customer script file ${VALUE}, returncode: $?"
547
ocf_log warn "Attribute ${NAME} is set to ${VALUE}, but this file is not executable"
555
# sapdatabase_start : Start the SAP database
557
sapdatabase_start() {
558
sapuserexit PRE_START_USEREXIT "$OCF_RESKEY_PRE_START_USEREXIT"
567
output=`su - $sidadm -c $SAPSTARTDB`
570
if [ $DBJ2EE_ONLY -eq 1 ]
572
sapdatabase_monitor 1
576
if [ $rc -ne 0 -a $OCF_RESKEY_AUTOMATIC_RECOVER -eq 1 ]
578
ocf_log warn "SAP database $SID start failed: $output"
579
ocf_log warn "Try to recover database $SID"
588
ocf_log info "SAP database $SID started: $output"
590
sapuserexit POST_START_USEREXIT "$OCF_RESKEY_POST_START_USEREXIT"
592
ocf_log err "SAP database $SID start failed: $output"
600
# sapdatabase_stop: Stop the SAP database
604
sapuserexit PRE_STOP_USEREXIT "$OCF_RESKEY_PRE_STOP_USEREXIT"
606
# use of the stopdb kernel script is not possible, because there are to may checks in that
607
# script. We want to stop the database regardless of anything.
608
#output=`su - $sidadm -c $SAPSTOPDB`
611
ORA) output=`oracle_stop`
613
ADA) output=`maxdb_stop`
615
DB6) output=`db6udb_stop`
621
ocf_log info "SAP database $SID stopped: $output"
624
ocf_log err "SAP database $SID stop failed: $output"
635
sapuserexit POST_STOP_USEREXIT "$OCF_RESKEY_POST_STOP_USEREXIT"
642
# sapdatabase_monitor: Can the given database instance do anything useful?
644
sapdatabase_monitor() {
649
if [ $rc -ne $OCF_SUCCESS ]; then
655
if [ $? -ne $OCF_SUCCESS ]; then x_server_start; fi
658
if [ $? -ne $OCF_SUCCESS ]; then listener_start; fi
666
if [ $DBJ2EE_ONLY -eq 0 ]
668
output=`echo "$SAPDBCONNECT -d -w /dev/null" | su $sidadm 2>&1`
679
# WebAS Java 6.40+7.00
680
IAIK_JCE="$SECSTORE"/iaik_jce.jar
681
IAIK_JCE_EXPORT="$SECSTORE"/iaik_jce_export.jar
682
EXCEPTION="$BOOTSTRAP"/exception.jar
683
LOGGING="$BOOTSTRAP"/logging.jar
684
OPENSQLSTA="$BOOTSTRAP"/opensqlsta.jar
685
TC_SEC_SECSTOREFS="$BOOTSTRAP"/tc_sec_secstorefs.jar
686
JDDI="$BOOTSTRAP"/../server0/bin/ext/jdbdictionary/jddi.jar
687
ANTLR="$BOOTSTRAP"/../server0/bin/ext/antlr/antlr.jar
688
FRAME="$BOOTSTRAP"/../server0/bin/system/frame.jar
690
# only start jdbcconnect when all jars available
691
if [ -f "$EXCEPTION" -a -f "$LOGGING" -a -f "$OPENSQLSTA" -a -f "$TC_SEC_SECSTOREFS" -a -f "$JDDI" -a -f "$ANTLR" -a -f "$FRAME" -a -f "$SAPDBCONNECT" ]
693
MYCP=".:$FRAME:$ANTLR:$JDDI:$IAIK_JCE_EXPORT:$IAIK_JCE:$EXCEPTION:$LOGGING:$OPENSQLSTA:$TC_SEC_SECSTOREFS:$DB_JARS:$SAPDBCONNECT"
694
EXECMD="com.sap.inst.jdbc.connect.JdbcCon -sec $SID:$SID"
697
LAUNCHER=${BOOTSTRAP}/sap.com~tc~bl~offline_launcher~impl.jar
699
if [ -f "$DB_JARS" -a -f "$SAPDBCONNECT" -a -f "$LAUNCHER" ]
702
EXECMD="com.sap.engine.offline.OfflineToolStart com.sap.inst.jdbc.connect.JdbcCon ${SAPDBCONNECT}:${SECSTORE}:${DB_JARS}:${BOOTSTRAP} -sec $SID:$SID"
708
output=`${JAVA_HOME}/bin/java -cp $MYCP $EXECMD 2> /dev/null`
716
output="Cannot find all jar files needed for database monitoring."
722
if [ $rc -ne $OCF_SUCCESS ]
724
ocf_log err "The SAP database $SID ist not running: $output"
731
# sapdatabase_status: Are there any database processes on this host ?
733
sapdatabase_status() {
735
ADA) SEARCH="$SID/db/pgm/kernel"
736
SUSER=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
739
ORA) SEARCH="ora_[a-z][a-z][a-z][a-z]_"
740
SUSER="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
743
DB6) SEARCH="db2[a-z][a-z][a-z]"
744
SUSER="db2`echo $SID | tr '[:upper:]' '[:lower:]'`"
749
# Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
750
# as the output might be to long.
751
cnt=`ps efo args --user $SUSER 2> /dev/null | grep -c "$SEARCH"`
752
if [ $cnt -ge $SNUM ]
756
# ocf_log info "Database Instance $SID is not running on `hostname`"
764
# sapdatabase_recover:
766
sapdatabase_recover() {
769
ORA) recoutput=`oracle_recover`
771
ADA) recoutput=`maxdb_recover`
773
DB6) recoutput=`db6udb_recover`
777
sapdatabase_monitor 1
780
if [ $retcode -eq $OCF_SUCCESS ]
782
ocf_log info "Recover of SAP database $SID was successful: $recoutput"
784
ocf_log err "Recover of SAP database $SID failed: $recoutput"
792
# sapdatabase_validate: Check the symantic of the input parameters
794
sapdatabase_validate() {
796
if [ `echo "$SID" | grep -c '^[A-Z][A-Z0-9][A-Z0-9]$'` -ne 1 ]
798
ocf_log err "Parsing parameter SID: '$SID' is not a valid system ID!"
804
*) ocf_log err "Parsing parameter DBTYPE: '$DBTYPE' is not a supported database type!"
813
# 'main' starts here...
823
# Set a tempfile and make sure to clean it up again
824
TEMPFILE="/tmp/SAPDatabase.$$.tmp"
825
trap trap_handler INT TERM
827
# These operations don't require OCF instance parameters to be set
835
methods) sapdatabase_methods
846
ocf_log err "$0 must be run as root"
850
# mandatory parameter check
851
if [ -z "$OCF_RESKEY_SID" ]; then
852
ocf_log err "Please set OCF_RESKEY_SID to the SAP system id!"
855
SID=`echo "$OCF_RESKEY_SID"`
857
if [ -z "$OCF_RESKEY_DBTYPE" ]; then
858
ocf_log err "Please set OCF_RESKEY_DBTYPE to the database vendor specific tag (ORA,ADA,DB6)!"
861
DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr "[a-z]" "[A-Z]"`
863
# optional OCF parameters, we try to guess which directories are correct
866
EXEDBCONNECT="R3trans"
867
if [ -z "$OCF_RESKEY_DBJ2EE_ONLY" ]; then
870
case "$OCF_RESKEY_DBJ2EE_ONLY" in
871
1|true|TRUE|yes|YES) DBJ2EE_ONLY=1
872
EXESTARTDB="startj2eedb"
873
EXESTOPDB="stopj2eedb"
874
EXEDBCONNECT="jdbcconnect.jar"
876
0|false|FALSE|no|NO) DBJ2EE_ONLY=0;;
877
*) ocf_log err "Parsing parameter DBJ2EE_ONLY: '$DBJ2EE_ONLY' is not a boolean value!"
878
exit $OCF_ERR_ARGS ;;
882
if [ -z "$OCF_RESKEY_NETSERVICENAME" ]; then
884
ORA|ora) NETSERVICENAME="LISTENER";;
885
*) NETSERVICENAME="";;
888
NETSERVICENAME="$OCF_RESKEY_NETSERVICENAME"
891
if [ -z "$OCF_RESKEY_STRICT_MONITORING" ]; then
892
OCF_RESKEY_STRICT_MONITORING=0
894
case "$OCF_RESKEY_STRICT_MONITORING" in
895
1|true|TRUE|yes|YES) OCF_RESKEY_STRICT_MONITORING=1;;
896
0|false|FALSE|no|NO) OCF_RESKEY_STRICT_MONITORING=0;;
897
*) ocf_log err "Parsing parameter STRICT_MONITORING: '$OCF_RESKEY_STRICT_MONITORING' is not a boolean value!"
898
exit $OCF_ERR_ARGS ;;
903
$OCF_RESKEY_DIR_EXECUTABLE
905
/usr/sap/$SID/SYS/exe/run
909
for EXEPATH in $PATHLIST
911
if [ -x $EXEPATH/$EXESTARTDB -a -x $EXEPATH/$EXESTOPDB -a -x $EXEPATH/$EXEDBCONNECT ]
913
DIR_EXECUTABLE=$EXEPATH
914
SAPSTARTDB=$EXEPATH/$EXESTARTDB
915
SAPSTOPDB=$EXEPATH/$EXESTOPDB
916
SAPDBCONNECT=$EXEPATH/$EXEDBCONNECT
920
if [ -z "$DIR_EXECUTABLE" ]
922
ocf_log warn "Cannot find $EXESTARTDB,$EXESTOPDB and $EXEDBCONNECT executable, please set DIR_EXECUTABLE parameter!"
923
exit $OCF_NOT_RUNNING
926
if [ $DBJ2EE_ONLY -eq 1 ]
928
if [ -n "$OCF_RESKEY_DIR_BOOTSTRAP" ]
930
BOOTSTRAP="$OCF_RESKEY_DIR_BOOTSTRAP"
932
BOOTSTRAP=`ls -1d /usr/sap/$SID/*/j2ee/cluster/bootstrap | head -1`
935
if [ -n "$OCF_RESKEY_DIR_SECSTORE" ]
937
SECSTORE="$OCF_RESKEY_DIR_SECSTORE"
939
SECSTORE=/usr/sap/$SID/SYS/global/security/lib/tools
942
if [ -n "$OCF_RESKEY_JAVA_HOME" ]
944
JAVA_HOME="$OCF_RESKEY_JAVA_HOME"
945
PATH=$JAVA_HOME/bin:$PATH
947
if [ -n "$JAVA_HOME" ]
949
PATH=$JAVA_HOME/bin:$PATH
951
ocf_log err "Cannot find JAVA_HOME directory, please set JAVA_HOME parameter!"
952
exit $OCF_NOT_RUNNING
956
if [ -n "$OCF_RESKEY_DB_JARS" ]
958
DB_JARS=$OCF_RESKEY_DB_JARS
960
if [ -f "$BOOTSTRAP"/bootstrap.properties ]; then
961
DB_JARS=`cat $BOOTSTRAP/bootstrap.properties | grep -i rdbms.driverLocation | sed -e 's/\\\:/:/g' | awk -F= '{print $2}'`
966
if [ -z "$OCF_RESKEY_AUTOMATIC_RECOVER" ]
968
OCF_RESKEY_AUTOMATIC_RECOVER=0
970
case "$OCF_RESKEY_AUTOMATIC_RECOVER" in
971
1|true|TRUE|yes|YES) OCF_RESKEY_AUTOMATIC_RECOVER=1;;
972
0|false|FALSE|no|NO) OCF_RESKEY_AUTOMATIC_RECOVER=0;;
976
# as root user we need the library path to the SAP kernel to be able to call executables
977
if [ `echo $LD_LIBRARY_PATH | grep -c "^$DIR_EXECUTABLE\>"` -eq 0 ]; then
978
LD_LIBRARY_PATH=$DIR_EXECUTABLE${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
979
export LD_LIBRARY_PATH
981
sidadm="`echo $SID | tr '[:upper:]' '[:lower:]'`adm"
983
# What kind of method was invoked?
986
start) sapdatabase_start
989
stop) sapdatabase_stop
993
sapdatabase_monitor $OCF_RESKEY_STRICT_MONITORING
1000
recover) sapdatabase_recover
1003
validate-all) sapdatabase_validate
1006
*) sapdatabase_methods
1007
exit $OCF_ERR_UNIMPLEMENTED;;