Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
dvankempen
Product and Topic Expert
Product and Topic Expert

HDB










In this Under the Hood blog series we explore SAP HANA technical topics that go beyond the documentation but may help to familiarise ourselves with the technology.

The objective is to provide some insights on particular SAP HANA topics. Like a mechanic, look under the hood and take apart a piece to examine its functioning.

Learned something new? Post a comment, share on social media, and/or give a like. Thanks!



Introduction


Last month, I posted the first blog about SAPInit and SAPStartSrv or the mechanism used to automatically start an SAP HANA system at system boot and stop the instance at power off.

The topic of this blog is the HDB start/stop script.

So, how does this work?

Can't wait to Start (or Stop)?


The Start and Stop with HDB tutorial video shows the different options of the HDB script in action.

This video was recorded for the Getting Started with SAP HANA on the Google Cloud Platform series but the start/stop script is the same on all platforms, both cloud and on-premise.

 



Getting Started with SAP HANA on the Google Cloud Platform - Start and Stop with HDB

URL: https://www.youtube.com/watch?v=2bYgIYT3QrU

 

#!/bin/sh


Those familiar with UNIX system administration will certainly recognize the shebang [#!] as an indicator that we are dealing here with a shell script.

Note: Currently, the only operating systems for which SAP HANA is supported are SUSE Linux Enterprise Server (SLES) and Red Hat Enterprise Linux (RHEL). However, for what follows the same would apply to any UNIX system, so when reading UNIX below understand that this also applies to Linux.

Below a common sequence of commands for the UNIX administrator to find out about what type of file we are dealing with:
# where is the file located? 
which <file>

# what type of file is it?
file <file>

# in case of script, show the contents
cat <file>


 

On my SAP HANA express edition system, this returns



cat HDB

 

ASCII text means that it is a plain text file (like Notepad files on Windows). We can see that if we run the command without any arguments, the "usage" is printed to screen, a standard safe script coding practice to keep the novice out of trouble.

Note that the Copyright (c) is from 2002-2003. Why would that be?

You may recall that the release of SAP HANA was back in 2011 (and if you memory is failing you, you can always look it up on the Product Availability Matrix).

So, why would the script be from 2003?



PAM - SAP HANA platform edition 1.0

 

The reason is that the HDB script has been taken pretty much as-is from a predecessor of SAP HANA, the SAP Netweaver Business Intelligence Accelerator (BIA), later renamed to BWA for BW accelerator.

If you are interested, there is a WiKi on the SAP Community that provides additional links [ BWA - Business Warehouse Accelerator (BC-TRX-BIA) ]. You can also look BIA up on the PAM: 7.0 was released in 2005 and 7.2 in 2009, just prior to HANA.

The HDB script was called BIA at the time - and later BWA - and as this implies, you can rename the script to pretty much any name you want: HANA, hdb, etc.  Below, we do a 'mv' to rename the script from HDB to HANA.

Any reason why you want to rename the script? None whatsoever, bad idea! April fools maybe, on a test box (please!). Just to show you that HDB is a regular shell script; no magic.



Rename HDB (not a good idea)

 

Usage


So, let's take a look at the arguments or parameters if you prefer. When you just enter the name of the script as a command, usage information (help) is printed out, showing the different arguments available.



HDB - usage

 

Environment


Each time you run the HDB script, it will source another script file, hdbenv.sh which sets the environment, that is, sets variables like the system identifier (SID), instance number, path to executables, Python settings (and many more, as there are 273 lines in the files).



The hdbenv.sh script checks that it is executed by the <sid>adm user and not by the root user, for example.

As with HDB, the origins of hdbenv.sh script go back some time, here with reference to R/3.

We can also see newdb mentioned here, once the internal name for the in-memory database project. Later this was changed to Hybrid DataBase (HDB) for both row and column store (OLTP and OLAP), and finally, the product was marketed as HANA. If you are interested in the story, you can hear Vishal Sikka talk about the genesis of HAsso's New Architecture in the openSAP course An Introduction to SAP HANA.

Marketing for some time reframed the acronym to the High-performance ANalytical Appliance but this was put to rest once HANA got beyond its appliance phase.



hdbenv.sh



HDB executed as root

 

Timeout


HDB sets default values for start and stop timeout, 45 and 10 minutes respectively.

To me, these safeguards appear more appropriate to an SAP Netweaver Java system than SAP HANA but either way, they can be overridden using the environment variable HDB_START_TIMEOUT. As HDB is a script, you could modify these hard exits but it would be wise to do so in accordance with SAP Support. Editing the HDB script is certainly not a supported activity.



HDB - Timeout

 

Start


The start argument will use the SAPControl executable with function call StartService to startup the service which in turn should startup the instance.

For the SAPStartService, see

The same SAPControl utility is used to keep the prompt and wait for both service and instance to have started to print out the result, before returning the prompt.

SAPcontrol will be the next topic in this series. For now, let's just assume it starts (and stops) the HANA instance.



HDB start) argument

 

You can safely execute the HDB start command when the system is already running, it will just verify that the service is indeed up and running and return the prompt after two times 2 seconds delay (the 2 in the command above).



HDB start command

 

The message Impromptu CCC initialization can be ignored. The SAP Note to see, in fact, is not 1266393 but 2130426 - HDBStart: Impromptu CCC initialization by 'rscpCInit'. Another Netweaver legacy.

 

Stop


The stop argument first parses the different daemon.ini configuration files for the terminationtimeout parameter.

On my system, no host-specific or custom settings was defined, only the default 300 seconds. This means that the daemon service will try to stop HANA processes like hdbindexserver and hdbnameserver within 5 minutes before executing a hard stop on these child processes.

Then, the daemon process itself is stopped and for this, again, SAPControl is used. This time with a timeout of 400 seconds. In other words, the daemon will get an extra 100 seconds to finish up its work (soft or hard) before it will receive a hard stop. For this, another 600 seconds is allocated (the STOP TIMEOUT mentioned above) after which the operating system will step in and switch all lights off.



HDB stop) argument



daemon.ini terminationtimeout



HDB stop command

 

Reconf


The reconf argument will run the hdbdaemon command with the -reconfigure flag. $DAEMON is set to hdbdaemon just above the timeouts section (see above).

Although the hdbdaemon command is not documented publicly, the tool does come with a built-in help function. However, this does not explain the situations where you would want or need to use this. For this reason, the HDB reconf is typically more likely used for support reasons and not in daily operations.



HDB reconf) argument



hdbdaemon -reconfig command

 

Restart


Like reconf, restart calls the hdbdaemon process directly, this time with the -restart flag. If the result is not OK, a regular instance is attempted using SAPControl.



HDB restart) argument



HDB restart command

 

Version


The version argument prints out the version of SAP HANA together with information which could only be of interest to SAP Support and development like branch, git hash, etc. Unless of course, you want to fork your own version of SAP HANA. Make sure that, in this case, your lawyer has worked out the fine print with SAP before attempting such a venture.

The hdbsrvutil tool or utility is not publicly documented but, like hdbdaemon, comes with a built-in help function. It appears to be mainly used - internally, that is, by SAP support and development - to stop individual HANA processes. Softly with SIGTERM or hard with SIGKILL/SIGABRT. See below for the fine print about this killing business.



HDB version) argument



hdbsrvutil -v



hdbsrvutil

 

Info


The info argument prints out the output of the UNIX ps command for the <sid>adm user with options (-o) username, process id, parent process id, percentage CPU, virtual memory size, resident set size and the command (or process name).

The code for this argument clearly comes from an older more generic script as first a variable is set for HP-UX and then the database_file is parsed, all this does not apply to SAP HANA. However, in the spirit of "if it ain't broke, don't fix it", this code is left as-is and if the operating system happens to be Linux (the only one supported), the ps command is executed.



HDB info) argument



HDB info command

 

If we slightly modify the ps command, we can nicely see the parent-child relationships with the sapstart (50196) process starting the hdbdaemon (50204) which, in turn, starts the other HDB processes like hdbnameserver but also three sapjvm_8 SAP Java runtimes which, in turn, start the different java and node processes.



ps command with forest tree

 

Proc


The proc argument is almost identical to the info argument although originally might have served a different purpose.

 

Admin


If a graphical environment is present, that is, X-Windows installed and configured, the admin argument will start the SAP HANA Database Administration tool. This tool, just like the other tools and utilities mentioned in this blog, is not documented and its use is, for this reason, not supported.

Those that have worked with BWA in the past will certainly recognize it as the BWA Admin tool. It is roughly the same tool but it appears to be still under development as, for example, tenant database configuration is supported, a concept which did not exist for BWA.

HDB Admin does not any perform miracles as sometimes is suspected from undocumented tools. In fact, quite the opposite: the tool returns a fair number of Python exception errors while navigating the UI. You can see it as a predecessor of HANA studio but one that does not require any client installation. For this reason, it is sometimes used by SAP support.

However, as the typical Linux system running SAP HANA is a minimum installation hardened for security, it will come without any graphical environment and running the 'HDB admin' command will only return the message:
Environment variable DISPLAY is not set, cannot start HDBAdmin

You can view HDBAdmin in action in the tutorial video for this blog:

 



HDB admin) argument



SAP HANA Database Administration

 

kill | kill-<sig> | term


The ominous sounding kill and term arguments will allow you to stop individual HDB processes; the full list we saw with the HDB info command.

The kill man(ual) pages will explain you exactly, in quite some detail, how this all works and, of course, you will also find this command documented in every UNIX / Linux administration handbook.

There are more ways to kill a process as there are ways to leave your lover: kill -l will list them all.

Soft stop:

  • -1 or SIGHUP (Hang Up signal)

  • -2 or SIGINT (Interrupts signal, equivalent to Control-C)


Hard stop:

  • -6 or SIGABRT (Abort signal)

  • -9 or SIGKILL

  • -15 or SIGTERM (terminal signal, default action if no flag is specified)


The main difference between 6 and 9 is that SIGABRT will attempt to end the process with a core dump, that is, write the memory contents to disks. SIGKILL is like a power off for the process. Any state not persisted is lost.

What happens with SIGTERM will depend on the process (as defined in its header file) and could be either a soft or hard stop, As it is better to be safe than sorry, I will list SIGTERM here as a hard stop.

Note that the 'kill <process id> command will default to this -15 or SIGTERM option whereas an 'HDB kill' has been implemented to perform a 'kill <process id> -9 or SIGKILL.

Fortunately, a relational database management system like SAP HANA will have it savepoint and logging mechanism to be able to recover gracefully from any process crash.  However, it is maybe prudent to repeat the usage output from the HDB command. Certainly in productive systems stay clear of using SIGKILL (-9), SIGABRT (-6) and even SIGTERM (-15).



HDB usage



HDB term | kill



 

64 ways to kill a process

 

Note that the hdbsrvutil command also provides the -15, -6 an -9 flags to stop and start processes.



hdbsrvutil


References


For more information, see:

SAP HANA Academy Video Tutorial



SAP Documentation



SAP Notes



Other References




Learned Something New?  


Post a comment, share on social media, and/or give a like. Thanks.

If you would like to receive updates, connect with me on

Best,

Denys van Kempen












SAP HANA 2.0 - An Introduction


Just getting started with SAP HANA? Or do have a migration to SAP HANA 2.0 coming up? Need a quick update covering business benefits and technology overview. Understand the role of the system administrator, developer, data integrator, security officer, data scientist, data modeler, project manager, and other SAP HANA stakeholders? My latest book about SAP HANA 2.0 covers everything you need to know.

Get it from SAP Press or Amazon:
















For the others posts, see






 
3 Comments