Friday, 3 February 2023

Autostop HANA database when reboot a linux system (with systemd integration)

As a technical sap consultant working for large companies we are facing several challenges concerning big SAP- and HANA-landscapes. There are a lot of automated processes for administrating of these landscapes and this leads to problems in connection with HANA databases. One of these challenges I wan’t to share in the following blog post.

Initial situation


Because of security reason there is a monthly linux patching timeframe which is during night and there is no one that can stop the HANA databases before patching and rebooting the linux servers. Currently the reboot is triggered although HANA is running, so the database has always to recover after restart because there is no ordinary shutdown of the HANA database. When analyzing the traces we always see entries like the following in the startup process after a reboot (without shutdown HANA database before):

[4464]{-1}[-1/-1] 2023-01-04 11:16:03.399284 i Logger RecoveryHandlerImpl.cpp(00417) : Scan of open segment found log end position 0x17bb2598c0 within segment LogSegment[0x0:0x17bb234c80/Writing,ts=2023-01-04 11:02:27.351677][GUID=d0aa515f-003e-20230104-100159-223000000c/PrevGUID=e4e1a93f-003e-20230104-093146-34d000000b/PersGUID=6f3c30be-003e-20220628-080019-068000000e/RestoreGUID=f6039e5c-00af-20200513-081833-074000000f] at file position 0x931000, unused rest 0x3f6cf000

With the systemd integration there seems to be (not official SAP document founded) the possibility to have an ordinary shutdown process of the HANA database during reboot of Linux server.

Activate systemd integration


Prerequisites

◉ SUSE Linux Enterprise Server 15 (systemd version at least 234)

zypper info systemd​

SAP HANA, SAP HANA Database, SAP HANA Tutorial and Materials, SAP HANA Career, SAP HANA Skills, SAP HANA Jobs, SAP HANA Certification

◉ Installation of the polkit package is mandatory

zypper info polkit​

SAP HANA, SAP HANA Database, SAP HANA Tutorial and Materials, SAP HANA Career, SAP HANA Skills, SAP HANA Jobs, SAP HANA Certification

◉ HANA 2.0 SPS06 Revision 66 which is shipped with sapstartsrv 7.53 PL 1030 (at least PL 1011 is required for native systemd integration). At the time of blog writing, the HANA 2.0 SPS05 Revision 59.6 has still sapstartsrv 7.53 PL 1010 which not meet the prerequisites.

Step-by-step guide


Register sapstartsrv for systemd integration:

1. Stop HANA database and the service

sapcontrol -nr <NR> -function Stop
sapcontrol -nr <NR> -function StopService

2. with user root make a new registration of sapstartsrv (you can find these Information in file /usr/sap/sapservices)

export LD_LIBRARY_PATH=/usr/sap/<SID>/HDB<NR>/exe; /usr/sap/<SID>/HDB<NR>/exe/sapstartsrv pf=/usr/sap/<SID>/SYS/profile/<SID>_HDB<NR>_<hostname> -reg​

3. start new systemd Service

systemctl start SAP<SID>_<NR>.service​

4. Start HANA Database (with <sid>adm)

HDB start​

As a result, there is a modified entrie for the HANA instance in sapservices-File:

before:

LD_LIBRARY_PATH=/usr/sap/<SID>/HDB<NR>/exe:$LD_LIBRARY_PATH;export LD_LIBRARY_PATH;/usr/sap/<SID>/HDB<NR>/exe/sapstartsrv pf=/usr/sap/<SID>/SYS/profile/<SID>_HDB<NR>_<HOSTNAME> -D -u <sid>adm

after:

systemctl --no-ask-password start SAP<SID>_<NR> # sapstartsrv pf=/usr/sap/<SID>/SYS/profile/<SID>_HDB<NR>_<hostname>

There is also a new systemd service which is running in SAP.slice:

systemctl cat SAP<SID>_<NR>.service

SAP HANA, SAP HANA Database, SAP HANA Tutorial and Materials, SAP HANA Career, SAP HANA Skills, SAP HANA Jobs, SAP HANA Certification

Now when you trigger a reboot of the linux system, firstly it will ordinary shutdown the HANA database before rebooting the system. When analyzing the traces after such a reboot of the system, I can se an ordinary shutdown of the HANA database (this I couldn’t find before):

[4187]{-1}[-1/-1] 2023-01-04 10:26:35.677882 i Basis HDBConsListener.cpp(00186) : Stopping HDBCons listener
[4270]{-1}[-1/-1] 2023-01-04 10:26:35.677898 i Basis HDBConsListener.cpp(00168) : HDBCons listener stopped
[4187]{-1}[-1/-1] 2023-01-04 10:26:35.685287 i Service_Shutdown TrexService.cpp(00725) : System down

Source: sap.com

No comments:

Post a Comment