|
|
15862b |
From fe55f9b909d81a0093dbfb1f00083706cf5d2cf1 Mon Sep 17 00:00:00 2001
|
|
|
15862b |
From: Alexander Krauth <alexander.krauth@basf.com>
|
|
|
15862b |
Date: Fri, 19 Feb 2016 18:00:58 +0100
|
|
|
15862b |
Subject: [PATCH] High: SAPDatabase: Add support for Oracle 12c
|
|
|
15862b |
|
|
|
15862b |
To work with Oracle 12c the agent needs an option
|
|
|
15862b |
to pass the new Database Username to the resource.
|
|
|
15862b |
|
|
|
15862b |
Example configuration:
|
|
|
15862b |
|
|
|
15862b |
primitive oracle-database SAPDatabase \
|
|
|
15862b |
params \
|
|
|
15862b |
SID=HAO \
|
|
|
15862b |
DBTYPE=ORA \
|
|
|
15862b |
DBOUSER=oracle \
|
|
|
15862b |
STRICT_MONITORING=1 \
|
|
|
15862b |
op monitor interval=120 timeout=60
|
|
|
15862b |
---
|
|
|
15862b |
heartbeat/SAPDatabase | 12 +++++++++++-
|
|
|
15862b |
heartbeat/sapdb.sh | 35 ++++++++++++++++++++++++++---------
|
|
|
15862b |
2 files changed, 37 insertions(+), 10 deletions(-)
|
|
|
15862b |
|
|
|
15862b |
diff --git a/heartbeat/SAPDatabase b/heartbeat/SAPDatabase
|
|
|
15862b |
index de7959f..641bd40 100755
|
|
|
15862b |
--- a/heartbeat/SAPDatabase
|
|
|
15862b |
+++ b/heartbeat/SAPDatabase
|
|
|
15862b |
@@ -18,6 +18,7 @@
|
|
|
15862b |
# OCF_RESKEY_DIR_EXECUTABLE (optional, well known directories will be searched by default)
|
|
|
15862b |
# OCF_RESKEY_DBTYPE (mandatory, one of the following values: ORA,ADA,DB6,SYB,HDB)
|
|
|
15862b |
# OCF_RESKEY_DBINSTANCE (optional, Database instance name, if not equal to SID)
|
|
|
15862b |
+# OCF_RESKEY_DBOSUSER (optional, the Linux user that owns the database processes on operating system level)
|
|
|
15862b |
# OCF_RESKEY_STRICT_MONITORING (optional, activate application level monitoring - with Oracle a failover will occur in case of an archiver stuck)
|
|
|
15862b |
# OCF_RESKEY_AUTOMATIC_RECOVER (optional, automatic startup recovery, default is false)
|
|
|
15862b |
# OCF_RESKEY_MONITOR_SERVICES (optional, default is to monitor all database services)
|
|
|
15862b |
@@ -69,7 +70,7 @@ meta_data() {
|
|
|
15862b |
|
|
|
15862b |
|
|
|
15862b |
<resource-agent name="SAPDatabase">
|
|
|
15862b |
-<version>2.06</version>
|
|
|
15862b |
+<version>2.14</version>
|
|
|
15862b |
|
|
|
15862b |
<shortdesc lang="en">Manages a SAP database instance as an HA resource.</shortdesc>
|
|
|
15862b |
<longdesc lang="en">
|
|
|
15862b |
@@ -115,6 +116,11 @@ Usually you can leave this empty. Then the default: /usr/sap/hostctrl/exe is use
|
|
|
15862b |
<shortdesc lang="en">Database instance name, if not equal to SID</shortdesc>
|
|
|
15862b |
<content type="string" default="" />
|
|
|
15862b |
</parameter>
|
|
|
15862b |
+ <parameter name="DBOSUSER" unique="1" required="0">
|
|
|
15862b |
+ <longdesc lang="en">The parameter can be set, if the database processes on operating system level are not executed with the default user of the used database type. Defaults: ADA=taken from /etc/opt/sdb, DB6=db2SID, ORA=oraSID and oracle, SYB=sybSID, HDB=SIDadm</longdesc>
|
|
|
15862b |
+ <shortdesc lang="en">the Linux user that owns the database processes on operating system level</shortdesc>
|
|
|
15862b |
+ <content type="string" default="" />
|
|
|
15862b |
+ </parameter>
|
|
|
15862b |
<parameter name="NETSERVICENAME" unique="0" required="0">
|
|
|
15862b |
<longdesc lang="en">Deprecated - do not use anymore. This parameter will be deleted in one of the next releases.</longdesc>
|
|
|
15862b |
<shortdesc lang="en">deprecated - do not use anymore</shortdesc>
|
|
|
15862b |
@@ -305,6 +311,10 @@ DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr '[:lower:]' '[:upper:]'`
|
|
|
15862b |
if saphostctrl_installed; then
|
|
|
15862b |
. ${OCF_FUNCTIONS_DIR}/sapdb.sh
|
|
|
15862b |
else
|
|
|
15862b |
+ if [ -n "${OCF_RESKEY_DBOSUSER}" ]; then
|
|
|
15862b |
+ ocf_exit_reason "Usage of parameter OCF_RESKEY_DBOSUSER is not possible without having SAP Host-Agent installed"
|
|
|
15862b |
+ exit $OCF_ERR_ARGS
|
|
|
15862b |
+ fi
|
|
|
15862b |
. ${OCF_FUNCTIONS_DIR}/sapdb-nosha.sh
|
|
|
15862b |
fi
|
|
|
15862b |
sapdatabase_init
|
|
|
15862b |
diff --git a/heartbeat/sapdb.sh b/heartbeat/sapdb.sh
|
|
|
15862b |
index 7edb4b8..33d2033 100755
|
|
|
15862b |
--- a/heartbeat/sapdb.sh
|
|
|
15862b |
+++ b/heartbeat/sapdb.sh
|
|
|
15862b |
@@ -210,7 +210,11 @@ sapdatabase_monitor() {
|
|
|
15862b |
then
|
|
|
15862b |
DBINST="-dbinstance $OCF_RESKEY_DBINSTANCE "
|
|
|
15862b |
fi
|
|
|
15862b |
- output=`$SAPHOSTCTRL -function GetDatabaseStatus -dbname $SID -dbtype $DBTYPE $DBINST`
|
|
|
15862b |
+ if [ -n "$OCF_RESKEY_DBOSUSER" ]
|
|
|
15862b |
+ then
|
|
|
15862b |
+ DBOSUSER="-dbuser $OCF_RESKEY_DBOSUSER "
|
|
|
15862b |
+ fi
|
|
|
15862b |
+ output=`$SAPHOSTCTRL -function GetDatabaseStatus -dbname $SID -dbtype $DBTYPE $DBINST $DBOSUSER`
|
|
|
15862b |
|
|
|
15862b |
# we have to parse the output, because the returncode doesn't tell anything about the instance status
|
|
|
15862b |
for SERVICE in `echo "$output" | grep -i 'Component[ ]*Name *[:=] [A-Za-z][A-Za-z0-9_]* (' | sed 's/^.*Component[ ]*Name *[:=] *\([A-Za-z][A-Za-z0-9_]*\).*$/\1/i'`
|
|
|
15862b |
@@ -255,30 +259,43 @@ sapdatabase_monitor() {
|
|
|
15862b |
# sapdatabase_status: Are there any database processes on this host ?
|
|
|
15862b |
#
|
|
|
15862b |
sapdatabase_status() {
|
|
|
15862b |
+ sid=`echo $SID | tr '[:upper:]' '[:lower:]'`
|
|
|
15862b |
+
|
|
|
15862b |
+ SUSER=${OCF_RESKEY_DBOSUSER:-""}
|
|
|
15862b |
+
|
|
|
15862b |
case $DBTYPE in
|
|
|
15862b |
ADA) SEARCH="$SID/db/pgm/kernel"
|
|
|
15862b |
- SUSER=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
|
|
|
15862b |
+ [ -z "$SUSER" ] && SUSER=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
|
|
|
15862b |
SNUM=2
|
|
|
15862b |
;;
|
|
|
15862b |
- ORA) SEARCH="ora_[a-z][a-z][a-z][a-z]_"
|
|
|
15862b |
- SUSER="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
|
|
|
15862b |
- SNUM=4
|
|
|
15862b |
+ ORA) DBINST=${OCF_RESKEY_DBINSTANCE}
|
|
|
15862b |
+ DBINST=${OCF_RESKEY_DBINSTANCE:-${SID}}
|
|
|
15862b |
+ SEARCH="ora_[a-z][a-z][a-z][a-z]_$DBINST"
|
|
|
15862b |
+
|
|
|
15862b |
+ if [ -z "$SUSER" ]; then
|
|
|
15862b |
+ id "oracle" > /dev/null 2> /dev/null && SUSER="oracle"
|
|
|
15862b |
+ id "ora${sid}" > /dev/null 2> /dev/null && SUSER="${SUSER:+${SUSER},}ora${sid}"
|
|
|
15862b |
+ fi
|
|
|
15862b |
+
|
|
|
15862b |
+ SNUM=4
|
|
|
15862b |
;;
|
|
|
15862b |
DB6) SEARCH="db2[a-z][a-z][a-z]"
|
|
|
15862b |
- SUSER="db2`echo $SID | tr '[:upper:]' '[:lower:]'`"
|
|
|
15862b |
+ [ -z "$SUSER" ] && SUSER="db2${sid}"
|
|
|
15862b |
SNUM=2
|
|
|
15862b |
;;
|
|
|
15862b |
SYB) SEARCH="dataserver"
|
|
|
15862b |
- SUSER="syb`echo $SID | tr '[:upper:]' '[:lower:]'`"
|
|
|
15862b |
+ [ -z "$SUSER" ] && SUSER="syb${sid}"
|
|
|
15862b |
SNUM=1
|
|
|
15862b |
;;
|
|
|
15862b |
HDB) SEARCH="hdb[a-z]*server"
|
|
|
15862b |
- SUSER="`echo $SID | tr '[:upper:]' '[:lower:]'`adm"
|
|
|
15862b |
+ [ -z "$SUSER" ] && SUSER="${sid}adm"
|
|
|
15862b |
SNUM=1
|
|
|
15862b |
;;
|
|
|
15862b |
esac
|
|
|
15862b |
|
|
|
15862b |
- cnt=`ps -u $SUSER -o args 2> /dev/null | grep -c $SEARCH`
|
|
|
15862b |
+ [ -z "$SUSER" ] && return $OCF_ERR_INSTALLED
|
|
|
15862b |
+
|
|
|
15862b |
+ cnt=`ps -u $SUSER -o args 2> /dev/null | grep -v grep | grep -c $SEARCH`
|
|
|
15862b |
[ $cnt -ge $SNUM ] && return $OCF_SUCCESS
|
|
|
15862b |
return $OCF_NOT_RUNNING
|
|
|
15862b |
}
|