# @(#)19 1.3 src/43haes/usr/sbin/cluster/sa/oracle/sbin/DBConfig.sh, hacmp.assist.oracle, 61haes_r714 11/28/11 15:21:45 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/sa/oracle/sbin/DBConfig.sh 1.3 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2006,2011 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG #----------------------------------------------------------------------------- # Global Definitions: #----------------------------------------------------------------------------- . /usr/es/sbin/cluster/sa/oracle/sbin/IO . /usr/es/sbin/cluster/sa/oracle/sbin/DBUtilities #----------------------------------------------------------------------------- # Function: # osaGetListeners # # Purpose: # Get Oracle DB Listeners defined by HACMP. # # Arguments: # (1) Application ID for App Discovery # (2) SID or -none- # # Returns: # List of HACMP-defined listeners # # function osaGetListeners { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset id=$1 typeset sid if [[ -n $2 ]]; then sid=$2 else sid=$ORACLE_SID fi typeset -i i=0 #In PHA 7.1 the attibute names are capitalized in KLIB_UTIL_parse_arguments #which is used in sapsa_common file causing this regression #To fix this, first try with 'listener' then try 'LISTENER' typeset value attribute value=$(clquerysaapp -a $id listener 2>/dev/null) [[ -z $value ]] && { attribute="LISTENER" } || { attribute="listener" } # SID-listener-host combo being read via App Discovery frmwk typeset rsid lisn host # Look up listeners for a given SID and populate `allDBListeners' with it. clquerysaapp -a $id $attribute | sed 's/[Ll][Ii][Ss][Tt][Ee][Nn][Ee][Rr]=//' | while read rsid lisn host do if [[ $sid == $rsid ]]; then allDBListeners[$i]=$sid" "$lisn" "$host (( i += 1 )) fi done } #----------------------------------------------------------------------------- # Function: # osaDBDumpCfg # # Purpose: # Dump the application discovery HACMPsa_metadata entries for this # DB instance (dumps all allDBListeners) # # Arguments: # (1) application id # # Output: # List of instances # # Returns: # n/a # function osaDBDumpCfg { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset id=$1 typeset -i i for i in ${!allDBListeners[*]}; do log_msg "Adding "$i claddsaapp -a $id instance=$ORACLE_SID listener="${allDBListeners[$i]}" done } #---------------------------------------------------------------------------- # Function: # osaDBGetConfiguredInstances # # Purpose: # Output a list of already configured to HACMP RDBMS instances # # Arguments: # n/a # # Returns: # 0 on success # function osaDBGetConfiguredInstances { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset -n dbinsts=$1 typeset -i index=0 /usr/bin/odmget -q "name=DATABASE" HACMPsa_metadata | while IFS='=' read name value; do name=$(echo $name) [[ "$name" == "value" ]] && { value=$(echo $value) dbinsts[$index]=${value//\"/} (( index += 1 )) } done return 0 } #---------------------------------------------------------------------------- # Function: # osaDBGetUnconfiguredInstances # # Purpose: # Get a list of the DBs that are not already defined to the HACMP # cluster configuration # Assumes the caller has already called # osaGetDBEnvs $ORACLE_HOME # # Returns: # 0 on success # 1 on failure # function osaDBGetUnconfiguredInstances { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset -n dbinsts=$1 typeset -A allDBInstances defDBInstances typeset dbA dbB typeset -i found=0 typeset -i index=0 osaFindDBInstances allDBInstances osaDBGetConfiguredInstances defDBInstances for dbA in ${allDBInstances[*]}; do found=0 for dbB in ${defDBInstances[*]}; do [[ "$dbA" == "$dbB" ]] && { found=1 } done (( $found == 0 )) && { dbinsts[$index]=$dbA (( index += 1 )) } done return 0 }