Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

You might have seen an SAP Landscape setup that when Unix/Linux server is rebooted, it starts automatically SAP. Additionally when Server is going to shutdown, it safely shutdowns SAP first.

In this blog we will discuss about "How to achieve it"

I have done this setup on Solaris but will try to cover for all flavors of Unix because with slight variation core idea is same.

If you don't mind, lets discuss very briefly the generic boot process of Unix, if you are familiar then you can skip this paragraph.

________________________________________________________________________________________

POST (Power On Self Test): When the system is powered up, if first perform a check of the hardware(memory, keyboard, and network devices etc.) The CPU of the system is aware where the program for POST is stored.

Bootstrap Level-1 : It is a small program, this program resides at generally first few sectors of physical boot disk. Fixed location makes it easy to find and load the program into memory. After few checking like partitions and available boot option, it loads comparatively big program bootstrap Level-2, its name is different based on different OS. If you are getting boot options like from where to boot then its evident that the execution is with Bootstrap Level-1 program.

Bootstrap Level-2 : Unlike level-1 bootstrap program, Level-2 Bootstrap has no compulsion to reside at fixed location or initial location of physical boot disk. They resides at normal location of disk. The main task of bootstrap level-2 program is to load kernel files into memory.

Kernel : When the kernel files get loaded completely they loads some drivers related to interfaces and hardware. In this stage init process is created, for most of the OS init process has PID=1.

init process/phase : In general, init process is the parent or root process of all the processes, it sets environment variable for all descendents processes. Among other initialization files, it reads /etc/inittab file. This files contain the information on which runlevel the OS will be. Runlevel decides which group of processes will exist; missing processes are started and additional are killed. There is slight variation in the number used on different OS but runlevel 0 is used to halt the system and runlevel 6 to reboot.

One can find out what is the runlevel of their system by executing "who -r"

based on runlevel the scripts are executed from location /etc/rc.d/rc2.d for runlevel 2 or /etc/rc.d/rc3.d for runlevel 3 etc.

For the sake of simplicity a common location is used to store all the scripts below are the default location unless your unix administrator does not change them

  • Linux: /etc/init.d/
  • Solaris /etc/init.d/
  • HP-UX (True64): /sbin/init.d/
  • AIX: /etc/rc.d/init.d/

________________________________________________________________________________________

For example:

if a system is on runlevel 2, when you goto /etc/rc.d/rc2.d you will fine some links starting with 'K' and 'S'

# ls -l

total 24

lrwxrwxrwx     1 root     system           27 Sep 20 2011  K98gcstartup -> /etc/init.d/gcstartup

lrwxrwxrwx     1 root     sapinst          25 Aug 19 2011  Ksapinit -> /etc/init.d/sapinit

-r-xr-xr-x         1 root     system          307 Jul 16 2011  Ksshd

-r-x------          1 root     system         2439 Jul 14 2011  Kwpars

lrwxrwxrwx     1 root     system           27 Sep 20 2011  S98gcstartup -> /etc/init.d/gcstartup

lrwxrwxrwx     1 root     sapinst          25 Aug 19 2011  Ssapinit -> /etc/init.d/sapinit

-r-xr-xr-x        1 root     system          308 Jul 16 2011  Ssshd

  • File should be hard linked to the /etc/init.d directory or other as per your Unix.
  • The system looks for only those files beginning with letter K & S , any thing else is ignored. K & S should be in capital letters.

K - Kill a Process

S - Start a Process

Now, lets say we want to start and stop sap in sync with server boot.

We need to create a link in rc2.d or rc3.d as per our OS runlevel

rc2.d:

lrwxrwxrwx   1 root     root          15 Feb 13  2009 K05sap -> /etc/init.d/sap

lrwxrwxrwx   1 root     root          15 Feb 13  2009 S06sap -> /etc/init.d/sap

At least this happen in Solaris that these scripts are executed with argument start and stop, therefore we do not require separate file for start and stop. For your platform I will suggest to check if argument is passed along or not. Otherwise, you can have two separate files, one for start script another for stop script.

/etc/init.d/sap

#!/sbin/sh

#

# Start / stop SAP

case "$1" in

"start")

        su - oraec1 -c "lsnrctl start LISTENER_ECC"

        su - ec1adm -c "startsap"

        su - ec1adm -c "sapccm4x -DCCMS pf=/usr/sap/sapmnt/EC1/profile/EC1_DVEBMGS30_zobsapec1ci"

        su - daaadm -c "startsap"

        ;;

"stop")

        su - daaadm -c "stopsap"

        su - ec1adm -c "sapccm4x -stop pf=/usr/sap/sapmnt/EC1/profile/EC1_DVEBMGS30_zobsapec1ci"

        su - ec1adm -c "stopsap"

        su - oraec1 -c "lsnrctl stop LISTENER_ECC"

        ;;

*)

        echo "Usage: $0 { start|stop }"

        exit 1

        ;;

esac

exit 0

With this script, we are starting/stopping listener, sap application, ccms agent and diagnostic agent.

Similarly, if you want to start content server or just MaxDB you can take help from below script.

/etc/init.d/sapd

#!/sbin/sh

#

# Start / stop contentserver

case "$1" in

"start")

        su - sqdsdb -c "/sapdb/programs/bin/dbmcli -U DEFAULT db_online"

        su - a04cs -c "/usr/sap/home/q04cs/bin/apachectl -k start"

        su - sqdsdb -c "/sapdb/programs/bin/x_server start"

        ;;

"stop")

        su - sqdsdb -c "/sapdb/programs/bin/x_server stop"

        su - a04cs -c "/usr/sap/home/q04cs/bin/apachectl -k stop"

        su - sqdsdb -c "/sapdb/programs/bin/dbmcli -U DEFAULT db_offline"

        ;;

*)

        echo "Usage: $0 { start|stop }"

        exit 1

        ;;

esac

exit 0

My other Blogs, if you have time...

What's new in SAP NetWeaver 7.3 - A Basis perspective Part-I

What's new in SAP NetWeaver 7.3 - A Basis perspective Part-II

Bye bye STRUSTSSO2: New Central Certificate Administration NW7.3

Escaping tough moments of SPAM or SAINT

Multiple/Bulk transports with tp script for Unix (AIX, Solaris, HP-UX, Linux)

Holistic Basis View: BusinessObjects BI 4.0 SP 2 Installation & Configuration

How to Rename the Oracle Listener & Change Listener port for SAP

OSS1 & RFC connections SAPOSS, SAPNET_RFC, SDCC_OSS

Interrelation: SAP work process, OPS$ mechanism, oracle client & oracle shadow process

Install and configure NetWeaver PI 7.3 Decentralize Adapter part-1

Install and configure NetWeaver PI 7.3 Decentralize Adapter part-2

Holistic Basis View: BusinessObjects BI 4.0 SP 2 Installation & Configuration

List of Newly added/converted Dynamic parameter in NetWeaver 7.3

6 Comments