Skip to Content

systemd configuration for starting/stopping SAP

Hello,

We are migrating fro RH6 to RH7.

After the migration of the first server, I am trying basic things.

I am trying to write a script that would start/stop SAP and Oracle Listener

with systemd.

Starting at boot works fine.

But stopping sap during shutdown does not work well.

Systemd kills and umounts needed processes and fs before

letting a chance to stopsap to end :-(

As I am not the only one using SAP on RH7, I guess that you have already written systemd service for that.

If yes, could you provide me your configuration?

If no, how do you proceed to auomatically stop SAP during shutdown? :-)

Thanks in advance for your answers.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Nov 24, 2016 at 12:02 PM

    Hello Benoit

    SAP should be stopped with the commands;

    sapcontrol -nr 01 -function Stop

    sapcontrol -nr 01 -function Start

    assuming your instance is 01, you might receive many options if you check this web; http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60e24f7b-1ba1-2b10-c0a0-e514b855624b?QuickLink=index&overridelayout=true&35665408489838

    another option you might have is to stop sap with /etc/init.d/sapinit like

    "/etc/init.d/sapinit stop", or start,

    this is what SAP uses to control the auto-start or stop of sap instances during boot time.

    If I had to make automatic ations, I would trick the sapinit script.

    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 24, 2016 at 04:18 PM

    Hello,

    After upgrading to RH7, I have faced too many problems

    with the conversion of System V script.

    As far as I am concerned, using a proper systemd service,

    written from scratch is the best option.

    This is why I am interested by systemd script only.

    If you have done the work, could you please share you service definition?

    Thanks in advance for your answers.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 30, 2017 at 08:35 PM

    [Unit] Description= !! SAP Services !!

    After=autofs.service network.target syslog.target local-fs.target remote-fs.target ntpdate.service ntpd.service centrifydc.service sapinit.service netbackup.service systemd-user-sessions.service systemd-logind.service

    Requires=systemd-logind.service systemd-user-sessions.service autofs.service centrifydc.service netbackup.service

    RequiresMountsFor=/sapmnt/S30 /usr/sap /usr/sap/trans /oracle /home /tmp /var/log /var Wants=network.target sshd.service remote-fs.target autofs.service systemd-logind.service systemd-user-sessions.service

    [Service]

    Type=simple

    RemainAfterExit=true

    KillMode=none

    SendSIGKILL=no

    TimeoutSec=5min

    TimeoutStopSec=5min

    User=s30adm

    Group=sapsys

    EnvironmentFile=/home/s30adm/envfile

    ExecStart=/usr/sap/S30/SYS/exe/run/startsap

    ExecStop=/usr/sap/S30/SYS/exe/run/stopsap

    [Install]

    WantedBy=multi-user.target

    Add comment
    10|10000 characters needed characters exceeded

    • Seems that we don't need to use Environment at all. Just run stopsap and startsap utilities as commands of csh with the parameter -m.

      User=s30adm
      ExecStop=csh -m -c "/usr/sap/S30/SYS/exe/run/stopsap"
      ExecStart=csh -m -c "
      /usr/sap/S30/SYS/exe/run/startsap"

  • May 08, 2017 at 09:03 AM

    Good morning Wayne,

    Could you provide the envfile?

    How do you generate this file?

    Do you have script to generate it or do you manually generate it on each of your system?

    Regards,

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Benoit,

      Unless you make your comment directly on Wayne's answer, as I'm doing here with yours, he will not be notified that you responded. If you want him to see this, you need to reply directly to him by clicking Comment on this answer in the footer of his answer.

      Cheers,
      Matt

  • May 14, 2017 at 05:16 PM

    Hi Benoit,

    The definition of "EnvironmentFile" can found on https://www.freedesktop.org/software/systemd/man/systemd.directives.html#

    I used "Environment" with <sid>idm -> env output, converted on single line and paste in

    [Service]
    Type=simple
    RemainAfterExit=true
    KillMode=none
    SendSIGKILL=no
    TimeoutSec=5min
    TimeoutStopSec=5min
    User=idsadm
    Group=sapsys
    Environment="TERM=xterm" "HOME=/home/idsadm" "SHELL=/bin/csh" "USER=idsadm" "LOGNAME=idsadm" "PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/sap/IDS/SYS/exe/uc/linuxx86_64:/usr/sap/IDS/SYS/exe/run:/home/idsadm:." "HOSTTYPE=x86_64-linux" "OSTYPE=linux" "MACHTYPE=x86_64" "SHLVL=1" "GROUP=sapsys" "HOST=idsapps" "MAIL=/var/spool/mail/idsadm" "HOSTNAME=idsapps" "KDEDIRS=/usr" "QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins" "LANG=en_US.UTF-8" "QTDIR=/usr/lib64/qt-3.3" "QTINC=/usr/lib64/qt-3.3/include" "QTLIB=/usr/lib64/qt-3.3/lib" "SAPSYSTEMNAME=IDS" "DIR_LIBRARY=/usr/sap/IDS/SYS/exe/run" "RSEC_SSFS_DATAPATH=/usr/sap/IDS/SYS/global/security/rsecssfs/data" "RSEC_SSFS_KEYPATH=/usr/sap/IDS/SYS/global/security/rsecssfs/key" "rsdb_ssfs_connect=1" "LD_LIBRARY_PATH=/usr/sap/IDS/SYS/exe/run:/usr/sap/IDS/SYS/exe/uc/linuxx86_64:/oracle/client/11x_64/instantclient" "SAPEXE=/usr/sap/IDS/SYS/exe/run" "THREAD=NOPS" "DB_SID=IDS" "dbms_type=ORA" "dbs_ora_tnsname=IDS" "dbs_ora_schema=SAPSR3" "ORACLE_SID=IDS" "TNS_ADMIN=/usr/sap/IDS/SYS/profile/oracle" "NLS_LANG=AMERICAN_AMERICA.UTF8" "SAPDATA_HOME=/oracle/IDS"
    ExecStop=/usr/sap/IDS/SYS/exe/uc/linuxx86_64/stopsap
    ExecStart=/usr/sap/IDS/SYS/exe/uc/linuxx86_64/startsap
    [Install]
    WantedBy=multi-user.target

    EnvironmentFile not work for me,not sure with the arguments, need to work with this further.

    Add comment
    10|10000 characters needed characters exceeded

    • Oracle (tested), Hana (still in progress) on distributed environment.

      [Unit] Description=

      After=autofs.service network.target syslog.target local-fs.target remote-fs.target ntpdate.service ntpd.service sapinit.service netbackup.service systemd-user-sessions.service systemd-logind.service

      Requires=systemd-logind.service systemd-user-sessions.service autofs.service

      RequiresMountsFor=/sapmnt/IDS /usr/sap/IDS /usr/sap/trans /oracle /home /tmp /var/log /var

      Wants=network.target sshd.service remote-fs.target autofs.service systemd-logind.service systemd-user-sessions.service

      [Service] Type=simple

      RemainAfterExit=true

      KillMode=none

      SendSIGKILL=no

      TimeoutSec=5min

      TimeoutStopSec=5min

      User=idsadm

      Group=sapsys

      Environment="TERM=xterm" "HOME=/home/idsadm" "SHELL=/bin/csh" "USER=idsadm" "LOGNAME=idsadm" "PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/sap/IDS/SYS/exe/uc/linuxx86_64:/usr/sap/IDS/SYS/exe/run:/home/idsadm:." "HOSTTYPE=x86_64-linux" "OSTYPE=linux" "MACHTYPE=x86_64" "SHLVL=1" "GROUP=sapsys" "HOST=idsapps" "MAIL=/var/spool/mail/idsadm" "HOSTNAME=idsapps" "KDEDIRS=/usr" "QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins" "LANG=en_US.UTF-8" "QTDIR=/usr/lib64/qt-3.3" "QTINC=/usr/lib64/qt-3.3/include" "QTLIB=/usr/lib64/qt-3.3/lib" "SAPSYSTEMNAME=IDS" "DIR_LIBRARY=/usr/sap/IDS/SYS/exe/run" "RSEC_SSFS_DATAPATH=/usr/sap/IDS/SYS/global/security/rsecssfs/data" "RSEC_SSFS_KEYPATH=/usr/sap/IDS/SYS/global/security/rsecssfs/key" "rsdb_ssfs_connect=1" "LD_LIBRARY_PATH=/usr/sap/IDS/SYS/exe/run:/usr/sap/IDS/SYS/exe/uc/linuxx86_64:/oracle/client/11x_64/instantclient" "SAPEXE=/usr/sap/IDS/SYS/exe/run" "THREAD=NOPS" "DB_SID=IDS" "dbms_type=ORA" "dbs_ora_tnsname=IDS" "dbs_ora_schema=SAPSR3" "ORACLE_SID=IDS" "TNS_ADMIN=/usr/sap/IDS/SYS/profile/oracle" "NLS_LANG=AMERICAN_AMERICA.UTF8" "SAPDATA_HOME=/oracle/IDS" ExecStop=/usr/sap/IDS/SYS/exe/uc/linuxx86_64/stopsap ExecStart=/usr/sap/IDS/SYS/exe/uc/linuxx86_64/startsap

      [Install]

      WantedBy=multi-user.target

      Tried to upload the systemctl status on txt format, it's not allowing.