SAP HANA DB Autostop at Reboot/Shutdown

Hi Community,

i want to stop HANA DB automatically at reboot or shutdown on SLES12 SP5.

I created a systemd Service for stopping Hana DB but nothing happend.

Systemd Service:
[Unit]
Description=saphana
After=remote-fs.target user.slice sapinit.service multi-user.target
Requires=user.slice

[Service]
KillMode=none
Type=oneshot
ExecStart=/bin/true
ExecStop=/hana/source/scripts/stophanadb
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Script for stophanadb:
#!/bin/bash

su - SIDadm /usr/sap/SID/HDB00/HDB stop

Have anyone the same problem.

Best Regards
Gunnar

[QUOTE=btcbtc;59234]Hi Community,

i want to stop HANA DB automatically at reboot or shutdown on SLES12 SP5.

I created a systemd Service for stopping Hana DB but nothing happend.

Systemd Service:
[Unit]
Description=saphana
After=remote-fs.target user.slice sapinit.service multi-user.target
Requires=user.slice

[Service]
KillMode=none
Type=oneshot
ExecStart=/bin/true
ExecStop=/hana/source/scripts/stophanadb
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Script for stophanadb:
#!/bin/bash

su - SIDadm /usr/sap/SID/HDB00/HDB stop

Have anyone the same problem.

Best Regards
Gunnar[/QUOTE]
Hi and welcome to the Forum :slight_smile:
You want to ExecStart the script, but you can define the user as well so no need to execute a script, use direct…

#
# /etc/systemd/system/saphana.service
#
[Unit]
Description=Shutdown SAP HANA
After=remote-fs.target user.slice sapinit.service multi-user.target
Requires=user.slice

[Service]
KillMode=none
Type=oneshot
User=SIDadm
ExecStart=/usr/sap/SID/HDB00/HDB stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Hi,

/usr/sap/SID/HDB00/HDB has to be started as adm due to some checks and dependencies, so this approach should create a reaction at least.

The SAP HANA instance is running in scope in user slice (sapstartsrv is creating a PAM session for su), which have a fixed timeout of 90s at shutdown. This might be to short for some big HANAs.

There is no easy solution for this. Moving the processes into a service slice or creating an After= dependency to the scope in question.