How to Start and Stop an Instance of SAP HANA: A Guide

How to Start And Stop an Instance Of SAP HANA

If you’re working with SAP HANA, knowing how to start and stop an instance is essential for proper management.
This guide will walk you through the steps to start, stop, and restart an SAP HANA instance using different methods. We’ll also cover advanced topics like managing tenant databases and the SAP start service.

Methods to Start and Stop an SAP HANA Instance

There are two main ways to manage an SAP HANA instance:

  • Using the Command Line
  • Using SAP HANA Studio

SAP documentation also mentions using the SAP HANA Cockpit, but in many cases, it might not be available. So, we’ll focus on the command line and SAP HANA Studio for now.

Starting and Stopping SAP HANA via Command Line

To start, stop, or restart the SAP HANA instance from the command line, you use the HDB command. Here are the basic commands:

Start SAP HANA:

HDB start

Stop SAP HANA:

HDB stop

Restart SAP HANA:

HDB restart (This will stop and start the system automatically)

These commands keep the terminal session busy until the operation finishes, so if you need to monitor other things, like logs, you’ll need to open a separate terminal session. The system will show a progress update while stopping, with a message saying that it will wait up to 300 seconds (5 minutes) for all services to finish. You might even notice a reference to “NewDB”—this is just a historical name for SAP HANA used during its development.

Starting and Stopping SAP HANA via SAP HANA Studio

SAP HANA Studio provides a graphical interface to manage your instance. Here’s how to do it:

Start the System:

Right-click on the system database in SAP HANA Studio, and choose “Start System” from the menu. You’ll see a popup window confirming that you want to start the system. The services will slowly change from yellow to green, indicating the system is up and running.

Stop the System:

Right-click on the system database and select “Stop System.” You can choose between two types of shutdowns:

  • Soft shutdown: This waits for all active sessions to close.
  • Hard shutdown: This ends all sessions and rolls back current transactions.

A soft shutdown comes with a 10-minute timeout by default. After this period, it will switch to a hard shutdown if there are still open sessions.

Restart the System:

The restart option works like a combination of the start and stop processes. You can choose between a soft and hard shutdown before the restart.

Managing Tenant Databases

SAP HANA instances usually come with tenant databases, which can be started and stopped individually. By default, tenant databases start automatically when the SAP HANA instance starts, but you can change this behavior.

To stop a specific tenant database, use the following command in SQL:

ALTER DATABASE <DB> NO RESTART;

To allow it to restart automatically, use this command:

ALTER DATABASE <DB> DEFAULT RESTART;

You can also start or stop a tenant database manually using:

ALTER SYSTEM START DATABASE <DB>;
ALTER SYSTEM STOP DATABASE <DB>;

Checking the Status of SAP HANA Instances

To check whether the instance is running, use the following command in the command line:

HDB info

If the instance is active, you will see processes like hdbdaemon and hdbindexserver, indicating that both the system and tenant databases are running. You can also check the status of all databases by running this SQL query:

SELECT * FROM M_DATABASES;

If a tenant is down, the ACTIVE_STATUS column will show “NO,” along with the reason, such as manual shutdown or disabled autorestart.

The SAP Start Service

The SAP start service (sapstartsrv) is a small process that runs even when SAP HANA is stopped. It doesn’t use many system resources and is important because it allows you to manage the SAP HANA instance.
To manage this service, use the sapcontrol command:

Stop the service:

sapcontrol -nr <xx> StopService

Start the service:

sapcontrol -nr <xx> StartService <HSID>

You can also restart the service using:

sapcontrol -nr <xx> RestartService

Useful Commands for Monitoring

Here are a few more sapcontrol commands you may find helpful:

Check the status of processes:

sapcontrol -nr $TINSTANCE GetProcessList

View the log of the SAP start service:

sapcontrol -nr $TINSTANCE GetTraceFile

Check the environment settings of the service:

sapcontrol -nr $TINSTANCE GetEnvironment

Conclusion

Managing an SAP HANA instance is straightforward once you know the commands and tools available, like the command line and SAP HANA Studio. While the SAP start service runs even when the instance is down, you can manage it separately using sapcontrol.
Whether using SAP HANA for small applications or enterprise-level databases, these methods will help you keep everything running smoothly. For those interested in SAP S/4 HANA services, this knowledge can also support broader infrastructure management.

Let's talk

If you want to get a free consultation without any obligations, fill in the form below and we'll get in touch with you.