on 09-25-2018 10:06 PM
Hi,
I'm trying to create a systemd service script on RHEL7 to shutdown/startup the SAP app automatically if the server gets rebooted. I saw already some forums that talk about it, but didn't find a solution that works for my script.
Below, is the systemd service script that I'm using and it works for the startup of the SAP app, but not for the shutdown... As soon as I try to reboot the server, all the services are killed immediately without running the "ExecStop" command on the script.
Could you give me some light on how to solve this issue?
[Unit]
Description=SAP.service
After=local-fs.target network.target network-online.target
[Service]
Type=simple
RemainAfterExit=true
Environment="SID1=SID" "DAA=DAA"
KillMode=none
SendSIGKILL=no
ExecStart=/usr/bin/python /usr/sap/scripts/SAPstart.py
ExecStop=/usr/bin/python /usr/sap/scripts/SAPstop.py
TimeoutSec=60
[Install]
WantedBy=multi-user.target
Thanks in advance,
Carlos
In some cases, To work around:
We added one line to abrt-ccpp.service
ExecStop=/usr/bin/sleep 90
after that execute systemctl daemon-reload systemctl daemon-reexec and rebooted several time,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Did you find a way to create a script or some kind of process for this? I do not have anymore an issue to startup the SAP application automatically, but can't find a way to shutdown the SAP applications in a gracefully manner on RHEL 7 except shut them down manually which is not an option for me. I think that SAP should provide a way to makes this possible. I tried a lot of different systemd scripts, but no one works correctly..., when the operating system gets rebooted, it just kill all the processes plus unmount all the file systems, so the systemd scripts never works.
If you found already a way to make this possible, please advise.
Thanks,
Carlos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good afternoon,
From the documentation I have read SAP does not provide systemd settings for the system they provide.
This is all the most surprising as systemd is mandatory in RH 7, which has been available for several years.
As it has been mentioned, the most important issue is that system does crash the DB because of switchuser (su -) issue or if it has not been started by systemd.
I also would like to insist on the fact that the Suse workaround does not solve the following problem.
If SAP or DB is not restarted by systemd, even with the KBA a manual start of the system implies that systemd would make it crash when we shutdown the machine.
This really a dirty way of managing a system.
Have a nice day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Carlos,
We are still straggling with this issue .
I opened an incident with SAP here is their reply
"with system, the sapinit script (and processes started by it) are placed in user slice. Normally system allows only a 90 seconds for these processes to stop before killing them.
SUSE provides a workaround for such situation: https://www.suse.com/de-de/support/kb/doc/?id=7022671
The KBA is described in the context of HA cluster, but it can be applied in the same way for standalone systems as well. I recommend you to try it first in a test environment"
We have implemented the SUSE KBA but still the stopsap (sapinit stop) is not triggered at reboot
You can try and see, maybe you will have sucess. Please report if you did
Thanks
Moti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Moti,
Not yet . I'm still having issues to shutdown SAP with systemd. I tried already different things, but no luck. If you find a solution, please let me know. I will do the same if I figure it out how to solve it.
Thanks,
Carlos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Carlos,
facing the same problem !!
Did you overcome ? if yes then how
Thanks
Moti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Carlos
1. Sleep written on stopsap, not sure how you stopping SAP. If you are calling it internally (i.e. execute stopsap and inside SAPstart.py) sysmd may not wait and marked service as down and proceed with restart.
2. systmectl should start the SAP e.g. you started SAP using command startsap and you trying to stop using systemctl it may fail as the service status inactive. Service should be completed and active status before you try with systemctl <service> stop. Please check the below link for more details
If possible use separate service to stop the other things.
Let me know if it worked for you !
Thanks & Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasanta,
Thanks for helping me on this issue.
I tried with using the "stopsap" directly instead my "SAPstart.py" script and the same issue occurs. As soon as I run the command "systemctl reboot", my service gets killed. It calls the "ExecStop" command, but it doesn't wait for the necessary amount of time to shutdown the SAP application completely. Below is the "stopsap_J00.log" for your reference.
cat stopsap_J00.log
Trace of system startup/check of SAP System SID on Thu Oct 4 11:24:23 EDT 2018
Called command: /sapmnt/SID/exe/uc/linuxx86_64/stopsap stop
-------------------------------------------
11:24:23
stopping the SAP instance J00
-------------------------------------------
11:24:23
Shutdown-Log is written to /home/sidadm/stopsap_J00.log
-------------------------------------------
11:24:23
Instance J00 was not running!
On my SAP.service, I tried to use "TimeoutStopSec", "ExecStop=/usr/bin/sleep 60", etc... to give more time for the service to run, but it seems that it ignore those commands. Not sure why... This is how I have it now:
[Unit]
Description=SAP.service
After=network.target syslog.target local-fs.target systemd-user-sessions.service systemd-logind.service
Requires=systemd-logind.service systemd-user-sessions.service
RequiresMountsFor=/sapmnt/SID /usr/sap/SID /usr/sap/trans /home /tmp /var/log /var
Wants=network.target systemd-logind.service systemd-user-sessions.service
[Service]
Type=simple
RemainAfterExit=true
Environment="SAPSYSTEMNAME=SID"
KillMode=none
SendSIGKILL=no
TimeoutSec=5min
TimeoutStopSec=5min
User=sidadm
Group=sapsys
ExecStart=/usr/sap/SID/SYS/exe/uc/linuxx86_64/startsap
ExecStop=/usr/sap/SID/SYS/exe/uc/linuxx86_64/stopsap
ExecStop=/usr/bin/sleep 60
[Install]
WantedBy=multi-user.target
Hi Prasanta,
Thanks for your answer. I just verified the service and it is enabled.
In my case I can't use just the "stopsap" command because I need to start/stop other things in the server, reason why I have a custom script for it.
I just saw that when rebooting the server with the command "sudo systemctl reboot", the "ExecStop" on my service is called, but it is not able to shutdown the application completely because the "sudo systemctl reboot" kills all the services/process immediately. It seems that it is not taking in consideration the "Timeout" parameters that I'm putting on the service below.
This is how I have my service now. If you have any new ideas, please let me know. Thank you!!
[Unit]
Description=SAP.service
After=local-fs.target network.target network-online.target
[Service]
Type=simple
RemainAfterExit=true
Environment="SID1=SID" "DAA=DAA"
KillMode=none
SendSIGKILL=no
TimeoutSec=2min
TimeoutStopSec=2min
ExecStart=/usr/bin/python /usr/sap/scripts/SAPstart.py
ExecStop=/usr/bin/python /usr/sap/scripts/SAPstop.py
[Install]
WantedBy=multi-user.target
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check your service with systemctl command, also check if the service enable.
# systemctl <your service> stop
I called stopsap on "ExecStop" after calling <sid>adm user environment and it worked for me.
Check the below answer as well as
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.