Startskript für SAP Webdispatcher auf Linux Systemen

Spread the info

Heute mal ein Skript, das einen, oder alle installierte SAP Webdisptacher Instanzen auf Linux System startet bzw. restartet.

Das Skript wird als root ausgeführt, was einem das switchen auf den sidadm User erspart.

Weiter stoppt es nicht einfach den Webdispatcher, sondern killt die Prozesse und räumt die IPC Segmente auf.
Einfach aus dem Grund, dass es in der Vergangenheit gelegentlich passiert, das auf Linux Systemen die IPC Segemente hängen bleiben und die SAP Anwendung dann nicht wieder startet.
Wenn sich diese nicht mehr bereinigen lassen, hilft nur ein Neustart des Servers.

Das Skript:

#!/bin/bash # Run as root  # Check if i am root IAM=$(whoami) if [[ $IAM == root ]]; then echo else echo Please run as root exit 0 fi  # Check Parameter show Usage if [ -z $1 ]; then echo Usage: echo "SAPSTART.sh SID  ->  Example: SAPSTART.sh WD1, will (re-)start sapwebdispatcher instance WD1" echo "SAPSTART.sh ALL  ->  Will (Re-)start ALL instances" echo echo Available Instances: $(ls /sapmnt) exit 0  else  # Check if Argument match with installed SID if [ -d /sapmnt/$1 ]; then echo $1 matches with existing Instance else echo $1 does not exist. echo echo Available Instances: $(ls /sapmnt) exit 1 fi  # Kill SID Processes for PROC in $(ps -ef |grep $1 | grep adm | awk '{print $2}'); do     kill -9 $PROC done sleep 1  # delete IPC Segs for a in $(ipcs -s |grep  ${1,,}adm|  awk '{print $1}'); do     ipcrm -S $a done for b in $(ipcs -s |grep  ${1,,}adm|  awk '{print $2}'); do     ipcrm -s $b done PROF=$(ls -1 /sapmnt/$1/profile/WD* |head -1) #Change RW to the name of your SID's. Best case all Instance start with same 2 Character. Example: WD1, WD2, ... IPCNR=$(grep "SAPSYSTEM =" $PROF | awk '{print $3}') su - ${1,,}adm -c "cleanipc $IPCNR remove"  # Start Instance su - ${1,,}adm -c "sapcontrol -nr $IPCNR -function StartService $1" sleep 2 su - ${1,,}adm -c "sapcontrol -nr $IPCNR -function StartSystem"  #Wait a minute echo echo Wait 10 seconds to start... secs=10 while [ $secs -gt 0 ]; do echo -ne "$secs\033[0K\r"    sleep 1    : $((secs--)) done  #Check if webdispatcher is running and try again if necessary DISPSTAT=$(ps -ef |grep ${1,,}adm | grep 'wd\.' | wc -l) if [[ $DISPSTAT = 1 ]]; then echo echo $1 started on first attempt. echo ps -ef | grep $1 exit 0 else echo echo $1 is not running after frist startsap command. echo Try again to start.. echo su - ${1,,}adm -c "sapcontrol -nr $IPCNR -function StartService $1" sleep 2 su - ${1,,}adm -c "sapcontrol -nr $IPCNR -function StartSystem" echo echo Waiting another 10 seconds secs=10 while [ $secs -gt 0 ]; do echo -ne "$secs\033[0K\r"    sleep 1    : $((secs--)) done fi  #Check again is Running DISPSTAT=$(ps -ef |grep ${1,,}adm | grep 'wd\.' | wc -l) if [[ $DISPSTAT = 1 ]]; then echo echo $1 started on second attempt. echo ps -ef | grep $1 exit 0 else echo echo $1 is NOT Running. Please contact your System Adminstrator. fi  fi

 

Der Aufbau ist recht einfach.
Ein Step nach dem anderen.
Wenn Pfade etc. nicht zu ihrer Installation passen, müssen diese natürlich angepasst werden.

 

{jcomments on}

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert