I'm trying to found solution how run script before shutdown/reboot is initiated in RedHat7. I need to correctly shutdown SAP database when I'm shuting down or rebooting server.
Script for SAP shutdown take 3-4minutes, but shutdown of system is very quick -it mean that RedHat kill all proceses imediatly...
my
systemd sap.service is:
[Unit]
Description=Shutdown SAP
Before=shutdown.target reboot.target halt.target
[Service]
ExecStart=/bin/true
ExecStop=/usr/sap/stopsap
RemainAfterExit=true
KillMode=none
[Install]
WantedBy=multi-user.target
As I see in shutdown log - database wasnt shutted down correctly:
Checking ADA Database
-------------------------------------------
setTrace: false
J2EE Database is not available
Can you help me?
Thank you
Ivo
Edit 21.10.2015:
I moved to next step - it is working better, but still not correctly:
[Unit] Description=SAP sluzba
After=network.target sshd.target Wants=network.target sshd.service
[Service] Type=simple RemainAfterExit=true
Environment="SAPSYSTEMNAME=RH7" "HOST=cz-brn1-rh7" "HOME=/home/rh7adm"
"PATH=/sapdb/clients/RH7/bin:/sapdb/programs/bin:/usr/lib64/qt-.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/sap/RH7/SYS/exe/uc/linuxx86_64:/usr/sap/RH7/SYS/exe/run:/home/rh7adm:."
"DIR_LIBRARY=/usr/sap/RH7/SYS/exe/run"
"LD_LIBRARY_PATH=/usr/sap/RH7/SYS/exe/run:/usr/sap/RH7/SYS/exe/uc/linuxx86_64:/sapdb/clients/RH7/lib"
"RSEC_SSFS_DATAPATH=/usr/sap/RH7/SYS/global/security/rsecssfs/data"
"RSEC_SSFS_KEYPATH=/usr/sap/RH7/SYS/global/security/rsecssfs/key"
KillMode=none SendSIGKILL=no TimeoutSec=5min TimeoutStopSec=5min
User=rh7adm Group=sapsys
ExecStart=/usr/sap/startsap
ExecStop=/usr/sap/stopsap
[Install] WantedBy=graphical.target
Here is stopsap script:
#!/bin/bash
date >> /usr/sap/stopsap.log; /usr/sap/RH7/SYS/exe/uc/linuxx86_64/stopsap >> /usr/sap/stopsap.log 2>&1; whoami >> /usr/sap/stopsap.log;
J2EE Database is running
See logfile /home/rh7adm/JdbcCon.log
stopping the SAP instance J28
Shutdown-Log is written to /home/rh7adm/stopsap_J28.log
/usr/sap/RH7/J28/exe/sapcontrol -prot NI_HTTP -nr 28 -function Stop
Instance on host cz-brn1-rh7 stopped
Waiting for cleanup of resources..................................................................................................................................................
and here it stuck for that 5 minutes.. Shutdown script never finish:(
Can I trace how gone shutting down of my sap. service?
Thank you..
ExecStart=/bin/true
. How do you start your database?ExecStart=cmd-to-start
and removeBefore=
. UnlessDefaultDependencies=
is set to false, service units will implicitly have dependencies of typeRequires=
andAfter=
onbasic.target
as well as dependencies of typeConflicts=
andBefore=
on shutdown.target. These ensure that normal service units pull in basic system initialization, and are terminated cleanly prior to system shutdown.Before
and withExecStart=/usr/sap/startsap
but without success.su[715]: (to rh7adm) root on none Oct 09 11:26:19 cz-brn1-rh7 su[715]: pam_systemd(su-l:session): Failed to create session: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
scripts for startsap or stopsap cannot be run as root but as sapadm (in this case rh7adm) also tried withDefaultDependencies=false
still without success.../usr/sap/startsap
a shell script? can you post it?