Starting and Stopping SAP HANA

Objective

After completing this lesson, you will be able to use different tools to start and stop SAP HANA

SAP HANA Start Sequence

In-Memory Computing Security

SAP HANA In-Memory DB

The SAP HANA in-memory database holds the bulk of its data in-memory for maximum performance. However, it still uses persistent storage to provide a fallback in case of failure. Data and undo log information (part of data) are automatically saved to disk at regular savepoints. The log captures all changes as redo logs, which are continuously and synchronously saved to disk after each COMMIT done by database transactions (waiting for end of disk write operation).

After a power failure, the database can be restarted like a disk-based database.

Start of SAP HANA Database

The SAP HANA system restart sequence restores the system to a fully operational state quickly.

Note

After a system restart, by default, not all tables are loaded into the main memory immediately.

  • The system is normally restarted ("lazy" reloading of tables to keep the restart time short)

  • The system returns to its last consistent state (by replaying the redo log since the last savepoint)

Restart Process

During a database restart (for example, after a crash), the data from the last completed savepoint can be read from the data volumes. In addition, the redo log entries written since the last savepoint are read from the log volumes.

When restarting, the system is restored from the savepoint versions of the data pages. In this way, all data changes written since the last savepoint, are automatically rolled back. After the savepoint is restored, the log is replayed to restore the most recent committed state.

During startup, the uncommitted changes that were stored as part of the last savepoint also need to be rolled back. To undo these changes, undo information is stored as part of the savepoint. This is done by the undo manager, which provides an interface for writing undo records. The undo information is written to one virtual undo file per transaction. The undo virtual files consist of data pages, which are persisted in the data volume. This means that the undo entries first go through the page buffer and are persisted no later than the next savepoint.

Startup Process: Persistence Layer Activities

Note

The time needed for a restart of a complete SAP HANA system or an individual tenant database highly depends on the quantity and type of store (row store and columnar store), the way the system or tenant database was stopped, and further influencing factors (see Important Factors for the Startup Performance in the next section).

Note

A regular shutdown writes a savepoint, so there will be no replay log entries to be processed after a regular shutdown.

While the row store is always loaded entirely, only those columns of essential column tables are loaded into memory. The other columns are loaded, if requested.

For example, if a query only uses some of the fields (columns) of a table, only those fields are loaded into the memory at the time of query execution. All row-based tables (usually system tables) are available in the main memory. Their size significantly influences the time required to start the database. Other factors that influence start-up time are mentioned in the figure, SAP HANA Startup Process.

Startup Process

Important Factors for the Startup Performance

Multiple factors influence the time that amounts when starting an SAP HANA system with integrated in-memory databases. The following list should help to identify the most important factors:

  • Amount of logs to be replayed (roll forward)

  • Amount of changes by uncommitted transactions (roll back)

  • Read performance of the log volumes (disks)

  • Read/write performance of the data volumes (disks)

  • Layout design: separate log and data disk areas (physically, not only logically)

Startup Process: Tables

During the normal operation, SAP HANA tracks a list of column tables that are currently loaded (once per day). This list is now the basis of loading the necessary tables into main memory during restart. Reloading column tables in this way restores the database to a fully operational state more quickly. However, it does create performance overhead, and may not be necessary in non-productive systems. You can deactivate the reload feature in the indexserver.ini file by setting the reload_tables parameter in the sql section to false. In addition, you can configure the number of tables whose attributes are loaded in parallel using the tables_preloaded_in_parallel parameter in the parallel section of indexserver.ini.

Note

You can mark individual columns as well as entire column tables for preload.

When the Preload checkbox is selected, tables are loaded into memory automatically after an index server start. The current status of the Preload checkbox is visible in the system table TABLES in the PRELOAD column. Possible values are FULL, PARTIALLY, and NO. Also, in the system table TABLE_COLUMNS in the PRELOAD column, the possible values are TRUE and FALSE.

Note

When fields of large column tables are not in the main memory, the first access to the table might be significantly slower. This is because all requested columns are loaded to the main memory before the query can be executed. This applies even if a single record is selected.

  • Show information about the list of tables to be preloaded (not the preload flag related columns):
    Code Snippet
    1
    hdbcons "tablepreload i"
  • Show full content (list of tables):
    Code Snippet
    1
    hdbcons "tablepreload c -f"
  • Write additional preload information to a virtual file in data volumes:
    Code Snippet
    1
    hdbcons "tablepreload w -s"
  • Show a full list of help:
    Code Snippet
    1
    hdbcons help[Enter]

    Show hdbcons help on specific command:

    Code Snippet
    1
    hdbcons "help tablepreload"

Caution

Simply selecting all tables for preload in order to accelerate initial queries can slow down start-up time considerably. The Preload checkbox is a tuning option and should be used carefully, depending on the individual scenario and requirements.

Tools to Start and Stop SAP HANA

Depending on the situation, you might need to stop or start a part of the SAP HANA database. Which tool to use is determined by the SAP HANA component that needs to be stopped or started. The figure, Which Tool to Use, shows the usage areas of the different tools.

The following list shows the parts of the SAP HANA database system that can be stopped and started separately and the tools that can be used:

  • The whole database system – SAP HANA Cockpit and SAPControl
  • One or more tenants – SAP HANA Cockpit and SQL (SQL console or hdbsql)
  • One or more hosts in a scale-out scenario – HDB and SAPControl
  • SAP HANA services – SAP HANA Cockpit and SQL (SQL console or hdbsql)

Depending on the tool used, you need different credentials. The table, Required Credentials, shows the credentials needed per tool.

Required Credentials

ToolRoot<sid>admCockpit UserDatabase User
SAP HANA CockpitNoYesYesYes
SAPControlYesYesNoNo
HDBNoYesNoNo
SQL via SAP HANA CockpitNoNoYesYes
SQL via HDBSQLNoYesNoYes

Note

To use SAPControl, you must be logged on to the SAP system host as user <sid>adm or as a user with root permissions.

SAP recommends that you do not use the SYSTEM user for day-to-day activities in production environments. Instead, use the SYSTEM user to create personal database users with the minimum privilege set required for their daily duties.

If your corporate security policies recommend the use of personal operating system users, instead of the <sid>adm user, to perform database administration tasks, the SAP instance profile can be used for the respective configuration. See the following reference for details:SAP Note 1881622 – SAP HANA DB: Access to trace files via sapstartsrv.

Caution

SAP HANA studio can also be used to start and stop the SAP HANA database system. However, it is not shown in this lesson because SAP HANA studio is deprecated.

Starting and Stopping the SAP HANA Database System

The database administrator can use the browser-based SAP HANA cockpit or the command-line tool SAPControl to stop and start an SAP HANA database system. Both methods require the credentials of the <sid>adm operating system user. If the SAP HANA cockpit is used, additional credentials of an SAP HANA cockpit user are required.

Note

Using SAP HANA cockpit or the SAPControl functions StopSystem and StartSystem, the entire SAP HANA database system will be stopped. This is valid for both single-host systems, as well as multi-host (scale-out) systems.

Both the SAP HANA cockpit and SAPControl as a command-line program use the SAP start service (sapstartsrv) to stop and start the SAP HANA database system in a controlled way. The SAP HANA daemon and all necessary operating system services are started by sapstartsrv. In turn, the SAP HANA daemon starts all required SAP HANA services, such as the name server, the index server, and, for example, also the preprocessor service or the compile server.

SAP HANA Cockpit: Stop and Start the SAP HANA Database System

  1. From the SAP HANA cockpit home screen, open the Database Directory app, and choose the system database from the SAP HANA database system that you want to stop or start.
  2. In the Database Overview screen, search for the Services card and select it.

In the Manage Services screen, you see an overview of all the running services of the SAP HANA database system.

Note

If only the Daemon service is shown, the SAP HANA database system is stopped.

Depending on the given status of the SAP HANA database system, there is a Stop Database or a Start Database button in the upper-right area of the SAP HANA cockpit.

When stopping an SAP HANA database system, you have the option After all running statements finish executing or Immediately after open transactions are aborted and rolled back. The following table lists the differences using these options:

Database System Stop Options

OptionDescription
After all running statements finish executingThe system is stopped after all running statements have finished. If the system doesn't stop before the specified timeout, it is stopped immediately. The default timeout is five minutes.
Immediately after open transactions are aborted and rolled backThe system does not wait for any statement to finish. It stops immediately after open transactions are aborted and rolled back.

SAPControl: Stop and Start the SAP HANA Database System

You need to open an ssh terminal session to stop and start the SAP HANA database system from the command line using SAPControl. As a database system administrator, you can stop or start the SAP HANA database system using the following SAPControl commands:

  • sapcontrol –nr <instance number> -function StopSystem

  • sapcontrol –nr <instance number> -function StartSystem

To get an overview of the SAP HANA database system services on the local host, execute the following command from the command line:

Code Snippet
1
sapcontrol –nr <instance number> -function GetProsessList

To get an overview of the status of the hosts belonging to a scale-out SAP HANA database system, execute the following command from the command line:

Code Snippet
1
sapcontrol –nr <instance number> -function GetSystemInstanceList

Restarting the complete SAP HANA database system means that all of the data stored in memory needs to be reloaded. This is a time-consuming operation. For example, loading the row store is often a main contributor to SAP HANA startup times. Typically 10 to 20 GB of row store is loaded per minute. Depending on the cause of the restart, reloading the row store is not necessary and should be skipped so that the row store is kept in memory. How to accomplish this is explained in SAP Note 2159435 – How-To: Keeping SAP HANA Row Store in Memory when restarting.

Starting and Stopping Individual Tenants

With the introduction of multi-tenant database containers in the SAP HANA database, the database administrator mostly stops and starts individual tenants instead of stopping and starting the whole SAP HANA database system. Any SAP HANA database systems running version SAP HANA 2.0 SPS 01, or later, are set in multiple-container mode, so it is more likely that only an individual tenant needs to be stopped or started. SAP HANA cockpit supports stopping and starting of individual tenant databases.

Note

SAP HANA studio does not support starting and stopping of individual tenants.

SAP HANA Cockpit: Stop and Start Tenants

  1. From the SAP HANA cockpit home screen, open the Database Directory app and choose the system database that belongs to the tenant that you want to stop or start.
  2. In the Database Overview screen, choose the Database Management link.

In the Database Management screen, there is an overview of all the tenants that are part of the SAP HANA database system. Depending on the status of a tenant, there is a Stop or a Start button.

When stopping a tenant, you are presented with the options After running statements finish executing and Immediately after open transactions are aborted and rolled back. The following table explains the differences:

Tenant Stop Options

OptionDescription
After running statements finish executingWaits until all statements and transactions finish and then proceeds the stop operation.
Immediately after open transactions are aborted and rolled backImmediately stops the database without waiting for a regular shutdown.

SQL: Stop and Start Tenants

You need to use the SQL Console from the SAP HANA cockpit, or use the HDBSQL command-line tool, to stop and start tenants. As a database system administrator, you can stop or start tenant databases individually using the following SQL commands:

  • ALTER SYSTEM STOP DATABASE <tenant_name>

  • ALTER SYSTEM START DATABASE <tenant_name>

Note

If you stop a tenant database individually, you can only start it again individually. You cannot start it with a full system restart.

Starting and Stopping Individual SAP HANA Instances

In an SAP HANA scale-out system, it might be necessary to stop or start a single instance instead of the whole SAP HANA database system. This scenario might occur when a host from the scale-out system has failed and the hardware needs to be repaired.

As operating system user <sid>adm, the commands HDB and SAPControl can be used to stop and start individual instances:

  • In a single-host system, this results in a shutdown of the complete SAP HANA database system

  • In a high-available scale-out system, this results in triggering a host failover to the standby system

Caution

In a non-high-available scale-out setup, the shutdown of an instance results in an SAP HANA database system failure.

Starting and Stopping Individual SAP HANA Database Services

You can stop and start some of the SAP HANA database services. From the system database, it is possible to stop the following services:

  • Name server

    Note

    Stopping the name server results in a temporary connection loss, but as soon as the name server is restarted, the connection is reestablished again. The other services have not been restarted.

  • Preprocessor
  • Web dispatcher
  • Compile server

From a tenant database, it is possible to stop the following services:

  • Index server

    Note

    Stopping the tenant's index server results in a reload of the in-memory data of the tenant.

  • XS Engine

To stop, kill, reconfigure, or start missing database services, you must have the system privilege SERVICE ADMIN or DATABASE ADMIN.

To stop or kill services of a tenant database, either from the system database or the tenant, you must have the system privilege RESOURCE ADMIN.

The following are examples of situations where you have to restart an individual database service:

  • A host in a distributed system failed and a standby host took over. However, the services of the failed host remain inactive even after the host is available again. In this case, you need to restart the services manually.

  • After an update of SAP HANA extended application services, you need to restart the XS Engine service.

Options for Stopping and Starting Database Services

Options for Stopping and Starting Database Services

OptionDescription
Stop ServiceThe service stops normally and then typically restarts.
Kill ServiceThe service stops immediately and then typically restarts. The Kill Service feature is only active for tenant services that can be stopped as well.
Start Missing ServicesAny inactive services start.

Note

The SAP HANA database provides several features in support of high availability, one of which is the service auto-restart. In the event of a failure or an intentional intervention by an administrator that disables one of the SAP HANA services, the service auto-restart function automatically detects the failure, and restarts the stopped service.

Log in to track your progress & complete quizzes