#!/usr/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/sa/hswizard/etc/lccluster.sh 1.7 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2011,2012 # 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 # @(#) 71c643f 43haes/usr/sbin/cluster/sa/hswizard/etc/lccluster.sh, 726, 2147A_aha726, May 26 2021 10:50 PM . /usr/es/sbin/cluster/sa/maxdb/sbin/LCutilities . /usr/es/sbin/cluster/sa/maxdb/sbin/DBUtilities . /usr/es/sbin/cluster/sa/maxdb/sbin/DBGlobals [[ "$VERBOSE_LOGGING" == "high" ]] && set -x ##VARS --> Do not Edit typeset OP=$1 # passed by bsmsrv start or stop typeset STATUS=$2 # passed by bsmsrv ok, error, req ## Please Do not Edit following Paramters typeset INSTANCE="PRIMARY" typeset RC_FOR_FAILED_MASTER_db_online=0 typeset CONFIG_FILE="/usr/es/sbin/cluster/sa/hswizard/etc/LCHSenv.cfg" typeset SAPHA_SCRIPT_DIR="/usr/es/sbin/cluster/sa/maxdb/sbin" typeset LOG_FILE="/tmp/lccluster.log" ##setup environment { Do not Edit } STEP="LiveCache_${SID}_LC10control" # Edit the following values manually OR include $CONFIG file # /usr/es/sbin/cluster/sa/maxdb/etc/LCHSenv.cfg typeset SID="" # typeset LCADM="" # typeset LCSERVER=" " # typeset TAKEOVER=" " # typeset LCSERVER_IP=" " #LC service IP label > typeset LCSERVER_DB_IP=" " # typeset STANDBY_DB_IP=" " # typeset CONTROL_LOGIN=" " # typeset LOCKFILE_DIR=" " # typeset MAXDB_PROGRAM_PATH=" " # typeset DBMCLI_COMMAND=" " #/bin/dbmcli typeset LCBIN="" #/bin RC_FOR_FAILED_MASTER_db_online=0 # The following file will be created by SAP liveCache Hot StandbyConfiguration Wizard # Please Do not modify. [[ -f $CONFIG_FILE ]] && { . $CONFIG_FILE ;} typeset DBM_XUSER=${CONTROL_LOGIN} typeset CONTROL_LOGIN="-U ${DBM_XUSER}" ######## # MAIN # ######## # call lc_set_remote_host what will automatically set REMOTE_HOST to the host to un the SLAVE and LOCAL_HOST to the hostinformation running the MASTER lc_set_remote_host #set HOME variable for LCADM for XUSER enablement typeset myUsr=$(whoami) export HOME=$(lsuser -a home ${myUsr} | cut -d= -f2) [[ $OP == "starting" ]] && { case $STATUS in req ) ;; ok ) # Give application monitors and startscripts allowance to keep the service active echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 48 "Write LC10.start \n" >> $LOG_FILE touch $LOCKFILE_DIR/LC10.start chmod 777 $LOCKFILE_DIR/LC10.start # release lock locally and remote here to avoid race conditions in locking. This ensures we have never an undifined locking state echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 49 "Remove LC10.stop \n" >> $LOG_FILE rm -f $LOCKFILE_DIR/LC10.stop echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 90 "The PowerHA application monitors for the Primary and Auxiliary resource group is brought into active state.\n" >> $LOG_FILE # make STANDBY Active (as alternative we could wait till the Application Monitor activates it) echo $(date) >> $LOG_FILE lc_start_slave_remote [[ $? == 0 ]] && { echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 84 "APO started service of the Primary and Auxiliary instance. \n" >> $LOG_FILE } exit 0 ;; error ) echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 85 "The SAP APO transaction of SAP System \"%1\$s\" failed to start the Primary instance. Please contact your APO administrator \n" ${SID} >> $LOG_FILE exit 0 ;; * ) echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 54 "SAP Kernel Error. The script lccluster was called with unexpected parameters. Please contact your SAP Administrator. \n" >> $LOG_FILE exit 0 ;; esac exit 0 } [[ $OP == "stopping" ]] && { case $STATUS in req ) # Disarm application monitors echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 55 "Write LC10.stop \n" >> $LOG_FILE touch $LOCKFILE_DIR/LC10.stop chmod 777 $LOCKFILE_DIR/LC10.stop # release start lock. Do it exactly here to avoid race conditions! echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 56 "Remove LC10.start. \n" >> $LOG_FILE rm -f $LOCKFILE_DIR/LC10.start echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 91 "The PowerHA application monitors for the Primary and Auxiliary resource group is brought into passive state. \n" >> $LOG_FILE exit 0 ;; ok ) # stop slave resource group echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 58 "Stop STANDBY on \"%1\$s\" \n" ${REMOTE_HOST} $LCBIN/dbmcli -n $REMOTE_HOST -d $SID -U $DBM_XUSER db_offline [[ $? == 0 ]] || { echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 86 "ERROR:SAP APO transaction LC10 stoppped the Primary instance successfully but Standby instance stopping failed \n" >> $LOG_FILE; dspmsg -s 70 maxdbsa.cat 60 "Bring Slave Resource group down manually to allow a restart by LC10 later! \n" >> $LOG_FILE; } echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 87 "APO successfully stopped Primary and Auxiliary service. \n" >> $LOG_FILE exit 0 ;; error ) echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 88 "ERROR: The SAP APO transaction of SAP System \"%1\$s\" failed to stop the Primary instance. Please contact your APO administrator. \n" ${SID} >> $LOG_FILE exit 0 ;; * ) echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 63 "ERROR: SAP Kernel Error. The script lccluster was called with unexpected parameters from lcinit or dbmsrv. Please contact your SAP Administrator \n" >> $LOG_FILE exit 0 ;; esac exit 0 } echo $(date) >> $LOG_FILE dspmsg -s 70 maxdbsa.cat 64 "ERROR: lccluster called with invalid operation \"%1\$s\" . lccluster expects either starting or stopping. \n" ${OP} >> $LOG_FILE exit 1