Saturday 11 March 2023

Data and Log Volumes & Persistent Data Storage in the SAP HANA Database

1: why do we need persistent data storage?

We all know hana is an in-memory database. This means major operations get executed in-memory to reduce execution time or HANA is in-memory database. Then we need to store data at disk level or database level or OS level.

As per my understanding, reasons are simple like

1: risk of memory failure.

       to keep data at persistent data storage is to Protect data from risk. By saving data at persistent we save all changed data from memory to the data volumes, this operation is called Savepoints.

 2: to restore the database to its most recent committed state

Similarly when data changes and certain transaction events are saved regularly to disk in the form of logs. So to restore the database to its most recent committed state, changes to data in the database which is in memory are periodically copied to disk can use.

two storage types operate in a similar way but there are some essential differences as per use and operations.

The two types are

1: Data volumes

2: Log volumes

 

2: Which media type are we can use?

We can use different media types like traditional hard disk storage, and non-volatile RAM.

 

Directory Hierarchy for Data and Log Storage

 

●/usr/sap/<SID>/SYS/global/hdb/data

●/usr/sap/<SID>/SYS/global/hdb/log

 

two directories are created by default as the storage locations for data and log volume during the installation of the HANA database. But we know data  get stored in

/hana/data

/hana/log

 

We can see some the path in the parameter file ( global.ini) persistence

1: basepath_datavolumes

2: basepath_logvolmes

These directories contain a series of sub-directories to store data for each of the following

( show in HANA studio)

 

Do you know in the HANA database there are services that persist data and therefore have volumes

Like

Index server

Nameserver

xsengine (if running as a separate service)

 



 







What is data volume?

 

By default, each data volume contains one file (datavolume_0000.dat) in which data is organized into pages, ranging in size from 4KB to 16MB (page size class). Data is written to and loaded from the data volume page-wise.

Over time, pages are created, changed, overwritten, and deleted. As per requirement size of the data file is automatically increased as more space is required.

 However, it is not automatically decreased when less space is required.

it simply means that the amount of data in the file is currently less than at some point in the past (for example, after a large data load).

We can see the Total Size and the Fill Ratio values in the monitoring view M_DATA_VOLUME_STATISTICS

 

We can manually shrink the data volume to free space is needed. If size of data file is excessively then i would suggest take help from SAP support to analyze your situation.

 

what is log volume? 

Each log volume contains the file logsegment_<partition_ID>_directory.dat and one or more log segment files (logsegment_<partition_ID>_<segment_number>.dat). only one log partition is supported for each service, so the default file names are logsegment_000_directory.dat and logsegment_000_00000000.dat, logsegment_000_00000001.dat, logsegment_000_00000002.dat and so on. Log segment files are cyclically overwritten depending on the log mode. The log mode determines how logs are backed up. Log volumes only grow if there are no more segment files available for overwriting. Log segment files that are available for overwriting have been backed up and are not required for a database restart. If necessary you can remove these files to free up space in your file system by executing the SQL statement ALTER SYSTEM RECLAIM LOG. Note that new log segment files will need to be created later and this will affect performance. Only log segment files with state Free can be reused. Log segment files have a fixed size although the size can vary per service. (For example, indexserver=1024MB; xsengine=8MB).