I've been planning to create a Hana Command Line and Administrator's Reference
for a long long time.
During my studies for HanaTec Certification I noticed that anybody interested in
Hana Administration is missing a one stop shop location and reference for the
Hana Command Line tools and Administrator's SQL queries.
There are pieces of documentation on Hana Command Line tools spread across
a wealth of locations including, SCN Discussions, Experience Hana documentation ,
Tech-Ed documentation, Hana Administration guides, OSS Notes, KB Articles, but
there's not one location giving a live list of Hana Command Line tools with references
back to supporting documentation.
Selfishly, I've wanted to create that list for my own benefit. But, for the Administrator,
what is more luxurious than one location containing all Hana Command Line tools
known to man (or woman), and why to be selfish, why not to share this wealth with the
world :-)
And so this blog was born.
The Blog's goals are:
- . Create a Living List 0f all Known Hana Command Line and SQL Tools
- . Invoke discussion between techicians on the different tools and
their possibilities and uses, tips and tricks - . Give an intro to the Command Line Tools including example usage
On top of this list of Hana Command Line Tools, and useful SQL's, there are a
wealth of really useful Hana Administration related OSS Notes and KB Articles out
there and the Experience Hana Website .
Bill Ramos, has catalogued the OSS Notes nicely
in The Ultimate Set of Hana Related Links from SAP,
and the
SAP NetWeaver Basis Administrator's Toolbox...
contains the longest list of Hana Administration OSS Notes available in one place
on the Internet.
Another useful source as Lars Breddemann has pointed out in other blogs is the
help option on the command line, <HanaCommand> -h. Lars has authored a whole
host of excellent Hana Administration blogs, click on Lar's User and then click
on his Content to look through his blogs.
Furthermore, a useful read for those new to Linux would be Bill Ramos's blog:
Linux challenged no problem - check out the linux essentials for the windows admin .
As ever, have fun and enjoy learning.
All the best,
Andy.
p.s. something interesting would be to produce a similar resource detailing the navigation
steps in the Hana Studio for Basis Administrator's tasks, would somebody else like to lead
that ?
Contents: SAP Hana Command Line Tools and SQL Reference Examples for NetWeaver Basis Administrators
- 1) HDB stop & StopSystem HDB
- 2) HDB start & StartSystem HDB
- 7) Install Permanent License Using SQL
- 8) M_VOLUME_IO_STATISTICS
- Total Memory Consumption of All Columnar Tables
- Total Memory Consumption of All Row Tables
- Total Memory Consumption of All Columnar Tables by Schema
- List All Columnar Tables of Schema 'SYSTEM'
- Available Physical Memory
- 9) Activating Emergency User with hdbnameserver & hdbindexserver
- 10) Renaming an SAP HANA System with a GUI using hanaconfig.sh
- 11) Location of Configuration Files
- 13) Testing the ODBC Installation
- 16) Collecting System Information for Support
- 18) To run sql queries using hdbsql
- 19) Performing a Database Backup Using SQL Commands
- 20) Setting Up a Data Backup Using Cron
- 21) Canceling a Running Data Backup
- 22) Canceling Other Running Data Backups
- 23) To check the state of the data backup
- 24) hdblogdiag & Recovery
- 25) Restore when log backups are missing
- 28) Sizing Hana Basic Calculations
- 29) HANA SSO with Kerberos and Active Directory
- 30) Row Store Reorganisation
- 31) How to generate a runtime dump on SAP HANA saphostagent/sapdbctrl for Hana
- 32) DBSL hints for SAP HANA
- 35) hdbsrvutil - Example Usage
- 36) Show Hana Processes HDB proc & HDB info
SAP Hana Command Line Tools and SQL Reference Examples for NetWeaver Basis Administrators
./HDB stop
/usr/sap/hostctrl/exe/sapcontrol -nr <instance-nr> -function StopSystem HDB
./HDB start
/usr/sap/hostctrl/exe/sapcontrol -nr <instance-nr> -function StartSystem HDB
- 3) Query the current status of all hosts
/usr/sap/hostctrl/exe/sapcontrol -nr <instance-nr> -function GetSystemInstanceList
- 4) Start the name server:
/usr/sap/<SID>/HDB<instance>/hdbenv.sh
/usr/sap/<SID>/HDB<instance>/exe/hdbnameserver
- 5) Start an index server in a new console:
/usr/sap/<SID>/HDB<instance>/hdbenv.sh
/usr/sap/<SID>/HDB<instance>/exe/hdbindexserver -console
Create a user key in the user store and store the password under this user key:
hdbuserstore SET <user_key> <env> <user_name> <password>
For example:
hdbuserstore SET millerj localhost:30115 JohnMiller 2wsx$RF
List all available user keys (passwords are not displayed):
hdbuserstore LIST <user_key>
For example:
hdbuserstore LIST millerj
The following information is displayed
:KEY: millerjENV: localhost:30115USER: JohnMiller?
Call hdbsql with the user key:
hdbsql -U <user_key>
For example:
hdbsql -U millerj
hdbuserstore Example of User Creation while solving saphostagent/sapdbctrl for Hana issue
Ref: SAP Note 1625203 - saphostagent/sapdbctrl for newdb
The saphostagent functions for querying the database status and for
starting and stopping the database are now also available for the Hana.
If you want to use the connect without a password, the following
prerequisites must be met:
a. To query information from the database, you require a database user with
the monitoring role.
You can create a database user with the Hana studio. Connect as the SYSTEM
user and execute the following SQL commands:
CREATE USER SAPDBCTRL PASSWORD x<password>x
GRANT MONITORING TO SAPDBCTRL
Then logon to the Hana studio under the username <username> and execute
the following command:
ALTER USER SAPDBCTRL PASSWORD <password>
b. As the OS user <sid>adm, you must provide the user key <SID>SAPDBCTRL in
hdbuserstore on the database server. You can check the existence of the
user key with the following command:
hdbuserstore LIST <SID>SAPDBCTRL
If the user key does not exist, you can create it as follows:
hdbuserstore SET <SID>SAPDBCTRL <dbhost>:<port> SAPDBCTRL <password>
The tool hdbuserstore is installed under the following paths:
/usr/sap/hdbclient
or
/usr/sap/<SID>/hdbclient
c. To check whether the sapdbctrl queries without passwords work, execute
the following command as OS user <sid>:
/usr/sap/hostctrl/exe/saphostctrl -function GetDatabaseStatus -dbname
<SID> -dbtype hdb
If sapdbctrl responds with the following error text:
ERROR: Database user authentication failed: SQLDriverConnect: Connect with
userkey failed! then you must check the connect data in hdbuserstore again.
- 7) Install Permanent License Using SQL
Execute the following SQL command:
SET SYSTEM LICENSE ‘<license file content>’
You can delete all installed license keys by executing the following SQL command
UNSET SYSTEM LICENSE ALL
To Install the license key
SET SYSTEM LICENSE LicenseFile
More info: the Experience Hana Cookbook
- 8) The monitoring view M_VOLUME_IO_STATISTICS
Show the Total Read Size and the the Total Write Size for each Volume since the Service
in question was last started.
The SQL command
ALTER SYSTEM RESET MONITORING VIEW SYS.M_VOLUME_TO_STATISTICS_RESET
initialises the statistics shown by this view
The monitoring view
M_VOLUME_IO_STATISTICS_RESET
now shows the statistics since the reset time
You can use the M_SERVICE_MEMORY view to explore the amount of SAP HANA
Used Memory as follows:
Total Memory Used
SELECT
round(sum(TOTAL_MEMORY_USED_SIZE/1024/1024)) AS
"Total Used MB" FROM SYS.M_SERVICE_MEMORY;
Code and Stack Size
SELECT round(sum(CODE_SIZE+STACK_SIZE)/1024/1024)
AS "Code+stack MB" FROM SYS.M_SERVICE_MEMORY;
Total Memory Consumption of All Columnar Tables
SELECT round(sum(MEMORY_SIZE_IN_TOTAL)/1024/1024)
AS "Column Tables MB" FROM M_CS_TABLES;
Total Memory Consumption of All Row Tables
SELECT round(sum(USED_FIXED_PART_SIZE +
USED_VARIABLE_PART_SIZE)/1024/1024) AS "Row
Tables MB" FROM M_RS_TABLES;
Total Memory Consumption of All Columnar Tables by Schema
SELECT SCHEMA_NAME AS "Schema",
round(sum(MEMORY_SIZE_IN_TOTAL) /1024/1024) AS
"MB" FROM M_CS_TABLES GROUP BY SCHEMA_NAME ORDER
BY "MB" DESC;
List All Columnar Tables of Schema 'SYSTEM'
SELECT TABLE_NAME AS "Table",
round(MEMORY_SIZE_IN_TOTAL/1024/1024, 2) as "MB" FROM
M_CS_TABLES WHERE SCHEMA_NAME = 'SYSTEM' ORDER BY "MB"
DESC;
Available Physical Memory
select round((USED_PHYSICAL_MEMORY + FREE_PHYSICAL_MEMORY) /1024/1024/1024, 2)
as "Physical Memory GB" from
PUBLIC.M_HOST_RESOURCE_UTILIZATION;
Execute the Linux command cat /proc/meminfo | grep MemTotal
Free Physical Memory
Execute the SQL query:
select round(FREE_PHYSICAL_MEMORY/1024/1024/1024, 2)
as "Free Physical GB" from
PUBLIC.M_HOST_RESOURCE_UTILIZATION;
Execute the Linux command:
awk 'BEGIN {sum = 0};
/^(MemFree|Buffers|Cached):/ {sum = sum + $2};
END {print sum}' /proc/meminfo
- 9) Activating Emergency User with hdbnameserver & hdbindexserver
If the SYSTEM user’s password is lost, you can use the SAP system user
to reset the password.
To recover an SAP HANA instance where the SYSTEM user’s password is lost,
you need to have <sid>adm access to the instance where SAP HANA's master
index server is running.
Open a command line interface, and log on to the server on which
the instance of the SAP HANA master index server is running.
Shut down the instance.
Start the name server:
/usr/sap/<SID>/HDB<instance>/hdbenv.sh
/usr/sap/<SID>/HDB<instance>/exe/hdbnameserver
Start an index server in a new console:
/usr/sap/<SID>/HDB<instance>/hdbenv.sh
/usr/sap/<SID>/HDB<instance>/exe/hdbindexserver -console
You will see the output of a starting index server.
When the service has started, you have a console to the SAP HANA
instance where you are logged on as a SYSTEM user.
Reset the SYSTEM user's password and store the new password in a
secure location with the following SQL command:
ALTER USER SYSTEM password <new password>
Note: Because you are logged on as a SYSTEM user in this console,
you do not have to change this password after the next logon, regardless \
of what your password setting policy.
- 10) Renaming an SAP HANA System with a GUI using hanaconfig.sh
In GUI mode, you will be prompted to enter the required parameters.
Use the following instructions to complete this task.
Note: If you specify the host name, make sure that it is fully qualified, such as
myhost.sap.com (i.e., not just myhost).
Connect to the system with an X server client to enable GUI system access.
Open a root shell and go to the directory where you mounted the SAP HANA DVD,
by entering a command such as the following:
cd /mnt/<HANA_DVD>/DATA_UNITS/HANA_IM_LINUX__X86_64
Call the script in GUI mode to perform the rename:
./hanaconfig.sh --gui
Select Rename HANA System
Select Next
Specify the required entries.
Leave the root shell after the rename is complete.
hanaconfig.sh gui can also be used for other tasks including installing and de-installing
SMD Agents
https://cookbook.experiencesaphana.com/bw/deploying-bw-on-hana/preparation/prepare-hana-hardware/
- 11) Location of Configuration Files
The configuration files (.ini files) are located by default in the following directories
$DIR_INSTANCE/../SYS/global/hdb
custom/config global.ini
indexserver.ini
nameserver.ini
For host-specific configuration settings
$SAP_RETRIEVAL_PATH
sapprofile.ini
daemon.ini
trace files can be found here:
/usr/sap/<SID>/HDB<system number>/<hostname>/trace
- 13) Testing the ODBC Installation
You can test the installation of the ODBC driver and your ability to connect
by using the odbcreg tool, which is part of the ODBC installation.
Start the odbcreg tool by enter a command in the form:
odbcreg -t hdbcodbc (for 64-bit driver)
or
odbcreg32 -t hdbcodbc32 (for 32-bit driver).
If the driver is installed properly, you should get the ODBC login screen.
Note, you can also run the command
odbcreg -g or odbcreg32 -g to get a list of installed drivers.
The SAP HANA driver is called HDBODBC
Automated update of SAP HANA server components
The SAP Software Update Manager is a separate software component that must
be started on the SAP HANA server. A good practice is to install this component
as a service.
The SAP Software Update Manager does not have a user interface.
It is controlled remotely from the SAP HANA studio.
Tip: The Software Update Manager can be configured as a Linux service by
running the following commands:
export JAVA_HOME=/usr/sap/<SID>/SUM/jvm/jre
/usr/sap/<SID>/SUM/daemon.sh install
The service can be started using the following command:
/etc/init.d/sum_daemon start
After the release of an SPS of the SAP HANA Appliance Software new revisions of the SAP HANA
database are released.
To update your SAP HANA database to these new revisions, use the commands
hdbupd or hdbsetup which are provided with the SAP HANA database installation.
Install the SAP HANA ODBO driver on the host where MS EXCEL has been installed and is running.
For more information, see SAP HANA Client Installation and Update Guide.
a. Open a command prompt and call the SAP HANA client installation program by entering
the following command:
hdbinst -a client [<option_list>]
b. Follow the instructions displayed by the installation tool.
- 16) Collecting System Information for Support
There is a Python script that allows you to collect information from your systems
even when no access to the system via SQL is possible.
This information can be added to the support message.
Location and Usage
The name of the Python script is
fullSystemInfoDump.py
and is part of a server installation. It runs from a command line and is located
in the directory
$DIR_INSTANCE/exe/python_support
(Linux).
To execute the script <sid>adm rights are required.
To start the script out of its location directory, enter:
python fullSystemInfoDump.py
By default the script creates a zip file with all of the collected support information
to the directory
DIR_TEMP/system_dump where DIR_TEMP
is the content of the variable with the same name in sapprofile.ini.
This output directory is shown as console output when the script is running, but it can
be looked up by entering:
hdbsrvutil -z | grep DIR_TEMP=
To change the default directory, an explicit absolute path can be given to the script,
for example:
python fullSystemInfoDump.py <output_dir>
Usage information can be displayed by entering:
python fullSystemInfoDump.py –h
To collect support information you need an SQL user with rights to select the system tables and
views listed in System Tables/Views.
For security reasons the user name and password for this SQL user cannot be given as command
line parameters to the script.
Instead you are prompted for this information:
ts1adm@luvm252058a:/usr/sap/TS1/HDB01/exe/python_support> python
fullSystemInfoDump.py
User name: SYSTEM
Password:
The password is not displayed on the command line.
If the system can be reached via SQL and the user name and password information is valid, the script
starts collecting support information.
If user name and/or password are invalid, the script aborts.
SAP HANA HDBSQL is a command line tool for entering and executing SQL statements, executing
database procedures, and querying information about SAP HANA databases.
You can use HDBSQL interactively or import commands from a file and execute them in the
background. You can access databases on your local computer and on remote computers.
To get a list of all available hdbsql commands, you should use:
hdbsql -h
Examples:
One step logon to the database on the PARMA computer with instance ID 01 as database
user MONA with the password RED.
hdbsql -n PARMA -i 1 -u MONA –p RED
To log on using a <user_key>, enter the following command:
hdbsql [<options>] -U <user_key>
Two-Step Logon, Procedure
Start HDBSQL:
hdbsql [<options>]
Log on to the database:
\c [<options>] -n <database_host> -i <instance_id> -u
<database_user>,<database_user_password>
You display general information about the database:
\s
host : wdfd00245293a:30015
database : ORG
user : SYSTEM
kernel version: 1.50.00.000000
SQLDBC version: libSQLDBCHDB 1.50.00 Build 0000000-0120
autocommit : ON
- 18) To run sql queries using hdbsql:
# Hdbsql –n <hostname>:<port> -u <database user> –p <password>
Port= 3<##>15 (## is the instance number)
For example for system number 01:
# Hdbsql –n coe-he-40:30115 –u system –p SAPTeched1
Welcome to the SAP In-Memory Computing interactive terminal.
Type: \h for help with commands
\q to quit
hdbsql=> select count (*) from EIM360.mara
COUNT(*)
14927
- 19) Performing a Database Backup Using SQL Commands
https://cookbook.experiencesaphana.com/bw/operating-bw-on-hana/data-safety/backup/performing-database-backup/
You can enter SQL commands either by using the SQL editor in SAP HANA studio,
or by using the hdbsql program on the command line.
The hdbsql program is located in
/usr/sap/<SID>/HDB<instance number>/exe/
Note Backups using SQL commands are only recommended for batch mode
(see section Using Batch Mode below).
The backup can be started with the following SQL command:
BACKUP DATA USING FILE (‘<backup_file_prefix>’)
The backup creates the backup files in the default directory.
The name of each backup file starts with <backup_file_prefix>.
If you want to change the default a location, specify the full
path, for example:
BACKUP DATA USING FILE (‘/backupDir/data/monday/COMPLETE_DATA_BACKUP’)
Performing a Database Backup Using Batch Mode
Currently, the main tool for batch mode backup is the command
line interface hdbsql.
This is the current recommended mode for executing backups from
operating system level.
hdbsql enables you to trigger backups via crontab.
- 20) Setting Up a Data Backup Using Cron
a. Install the client software.
The client software enables access to the hdbuserstore.
Use the following command:
hdbinst –a client (default location: /usr/sap/hdbclient)
b. Create a user key.
Use the following command:
/usr/sap/hdbclient/hdbuserstore set <KEY> <host>:3<instance id>15
<user> <password> Example: /usr/sap/hdbclient/hdbuserstore set
BACKUP vebwtests1:30015 user password
c. In crontab, call the following at the desired time:
/usr/sap/hdbclient/hdbsql –U<KEY> "BACKUP DATA USING FILE ('<target>')"
Example: /usr/sap/hdbclient/hdbsql -U BACKUP "BACKUP DATA USING FILE ('MONDAY')"
A data backup is then created in the default location. In the above example,
the prefix of all service-related backup files is “MONDAY”.
- 21) Canceling a Running Data Backup
You can cancel a data backup that is still running.
To cancel a running data backup, you can use either SAP HANA studio or an SQL command.
Prerequisites
A user needs the system privileges CATALOG READ and BACKUP ADMIN.
Canceling a Running Data Backup Using SAP HANA Studio
You can use SAP HANA studio to cancel running data backups that you
started using the backup wizard. To cancel a running data backup, choose Cancel.
The backup is then canceled and you are notified of this.
- 22) Canceling Other Running Data Backups
To cancel any data backup:
a. Find the Backup ID.
When a data backup is started, the system assigns a unique ID to the data backup.
To find the backup ID of the running data backup, use the monitoring view
M_BACKUP_CATALOG,
which provides an overview of information about backup and recovery activities.
To find the backup ID of the running data backup, use the following SQL command:
select BACKUP_ID from "SYS"."M_BACKUP_CATALOG" where entry_type_name =
'complete data backup' and state_name = 'running' order by sys_start_time desc;
You can now use the backup ID to cancel the running data backup.
Cancel the data backup.
To cancel the running data backup use the following SQL command:
backup cancel <backup_id>
Check that the data backup was canceled.
- 23) To check the state of the data backup, use the following command:
select state_name from "SYS"."M_BACKUP_CATALOG" where backup_id = <backup_id>
- 24) hdblogdiag & Recovery
Recover the database until a point in time with a timestamp using a dedicated directory for
data backups and further directories containing automatically written log backups.
Use the following command:
RECOVER DATABASE UNTIL TIMESTAMP '2011-08-22 15:00:00' CHANGE ALL DATA USING PATH
('/backup/MONDAY/') CHANGE ALL LOG USING PATH ('/backup/logs1/','/backup/logs2/')
- 25) Restore when log backups are missing
ref: SAP Note 1816483 - Restore when log backups are missing
A restore fails with the error "Recovery could not be completed Cannot
open file ...".
One or more log backups of the SAP HANA database are missing or damaged.
All the available log backups exist in the file system of the database server.
If not all the required log backups are available, an SAP HANA database
restore is subject to restrictions.
In most cases, you will only be able to restore the SAP HANA database to a
in time that lies before the time when the oldest missing log backup was written.
A restore to any point in time (including redo of the log area) is possible
only if the content of the missing log backup still exists in the log area.
To determine if this is the case, proceed as follows:
Determine the volume IDs and the lowest log item of the missing log backup
from the name of the backup. If a previous restore has failed with the
error message specified above, you can determine the name of the missing
log backup from the error message.
The log backups are named after the schema log_backup_<volume ID>_0_<lowest
log item>_<highest log item>, for example,
log_backup_2_0_12345_67890.
In this example, the volume ID would be 2 and the lowest log item 12345.
Use hdblogdiag to determine the lowest log item that still exists in the
log segments of the log area as follows:
Call
hdblogdiag seglist <directory of the log segments for volume ID>
This call issues a list of log segments that looks as follows:
LogSegment[0/0:<lowest log item>-<highest log item>(...
LogSegment[0/1:<lowest log item>-<highest log item>(......
Take into account that the system outputs the log items in hexadecimal
format and that you have to convert them into decimal numbers.
Example:
Assuming the parameter basepath_logvolumes has the value /hana/log/HAN and
the parameter use_mountpoints has the value yes, so that the log segments
lie in the subdirectory mnt0001.
The log segments for the volume with the volume ID 2 then lie there in the
subdirectory
hdb00002: > hdblogdiag seglist /hana/log/HAN/mnt0001/hdb0002
LogSegment[0/0:0x129540-0x131c00(...
LogSegment[0/1:0x131c00-0x139540(...
Log segment 0 has the lowest log item 1217856 (hexadecimal 0x129540), log
segment 1 has the lowest log item 1252352 (hexadecimal 0x131c00). This
means that the lowest log item that exists in the log segments is 1217856.
If the lowest log item of the missing log backup is bigger than the lowest
log item that still exists in a log segment of the log area, a restore to
the latest available point in time is possible.
In such a case, proceed as follows:
Generate a new backup catalog with
hdbbbackupdiag -generate (SAP Note1812057)
Start the restore for the point in time that you selected.
If a restore to the latest available point in time is not possible, you can
restore the SAP HANA database to an earlier point in time.
You can restore the SAP HANA database only with the log backups that were
written before the missing log backup.
You cannot use the log backups that were written after the missing log
backup.
In this situation, proceed as follows:
Generate a new backup catalog with
hdbbbackupdiag -generate (SAP Note 1812057).
Start the restore for the point in time that you selected. For this, you
must select "Initialize Log Area".
The program hdbbackupdiag provides support for determining the data backup
files and log backup files that are required to restore an SAP HANA
database, with "Recover the database to its most recent state" as the aim.
Depending on the availability of the file BackupCatalog.xml that is saved
under the path $DIR_INSTANCE/../SYS/global/hdb/metadata and that is used to
determine the restoration strategy, two application scenarios arise; they
are both described in the following section.
Scenario a: BackupCatalog.xml is available
If the current version of the file BackupCatalog.xml exists, the program
hdbbackupdiag
determines the most suitable data backup and creates a list
of the required log backup files.
To do this, you must call the program with the option -c <BackupCatalog>.
Use the option -c <BackupCatalog> to specify the name of the BackupCatalog
file.
In normal cases, this is BackupCatalog.xml.
If the program is not started from the directory in which the file
BackupCatalog.xml
is located, you can use the option -d <Path> to adjust the access path.
The following example illustrates the function:
hdbbackupdiag -d $DIR_INSTANCE/../SYS/global/hdb/metadata -c
BackupCatalog.xml
Output:
Data backup file: thursday_databackup_0_1
RedoLogPosition: 0
Backup time: 2012-04-12T17:30:03+02:00
Using hdbbackupdiag to Reconstruct the Backup Catalog
A recovery of SAP HANA database fails. The file "backup.log" contains the
error messages:
"recovery strategy could not be determined" and
"Catalog backup not found".
The backup catalog that the database created is not available or defective.
All data backups and log backups that are required for the recovery are
available in the file system of the database server.
You can use the program "hdbbackupdiag" to create a new backup catalog.
For this, you provide all the data backups and log backups in the file
system of the database server. If you cannot use the standard paths for
data backups and log backups due to space restrictions, you can also save
the files in different directories. Note that all files of the data backup
must be saved to one directory. However, log backups can be distributed
across multiple directories.
To do this, start the program hdbbackupdiag with the following options:
--generate
--dataDir <directory of the data backups>
--logDirs <directories of the log backups>
-d <target directory of the backup catalog>
All directories must be specified as absolute paths.
For a standard installation, the call is as follows, for example:
hdbbackupdiag --generate --dataDir $DIR_INSTANCE/backup/data
--logDirs $DIR_INSTANCE/backup/log -d $DIR_INSTANCE/backup/log
If you have distributed the log backup across multiple directories, you can
specify them behind the option --logDirs separated by commas. For example:
hdbbackupdiag --generate --dataDir $DIR_INSTANCE/backup/data
--logDirs $DIR_INSTANCE/backup/log,/mnt/disc2/log -d
$DIR_INSTANCE/backup/log
When you call "hdbbackupdiag", the content of the specified directories is
analyzed and a new backup catalog is generated. This backup catalog is
created with a directory for the log back up that is specified with -d.
Then new backup catalog has the file name "log_backup_0_0_0_0.n" whereby n is
the newly generated backup ID of the database.
To be able to verify the content of the backup catalog, you can output the
recovery strategy that is based on the latest data backup in the generated
backup catalog. For this, use the command
"hdbbackupdiag -d <target directory of the backup catalog>"
After you generate the backup catalog, a recovery of the database may
carried out.
In case the backup catalog is not created in the standard directory
$DIR_INSTANCE/backup/log, you must specify the directory in which the
backup catalog is located in the Recovery Wizard in the step "Locate Log
Backups".
For more information check OSS Note:
SAP Note 1812057 - Reconstruction of the backup catalog with hdbbackupdiag
http://scn.sap.com/community/hana-in-memory/blog/2012/12/28/how-to-use-sap-hana-hdbcons-utility
hdbcons is a tool to provide information about the actual used memory, the peak memory,
the throughput of the different allocators, etc.
SAP Note 1786918 - Required information to investigate high memory consumption
You are running SAP HANA and you experience high memory consumption / out
of memory situations.
You are asked to provide information using hdbcons.
SAP HANA Development Support requires information about a suspected memory
issue.
Connect to your HANA database server as user sidadm.
a. You suspect that a query requires too much memory:
Before running the query start the tracing:
hdbcons 'mm flag / -rs as'
Run the query.
Stop the tracing:
hdbcons 'mm flag / -rd as'
Write output:
hdbcons 'mm callgraph -r -o <filename> /'
Please be aware that this trace will slow down the system!
You suspect a memory leak:
Please provide the output files of the following commands:
a. hdbcons 'mm bl -rt Pool' > /<path>/<file_name.txt>
This will show us how much memory is located by which code line.
b. hdbcons 'mm l -s -S -p' > /<path>/<file_name.txt>
This will show which allocator allocates how much memory at the
moment and its peak memory allocation.
The memory consumption stays at a high level / the database seems to
hang because of high memory consumption
Please provide a runtime dump as described in SAP Note 1813020 and
the content of the monitoring view M_HEAP_MEMORY.
hdbcons To get threads list
hdbcons "context list -s" > thread_callstack_test.txt
To generate runtime dump (see the Note 1813020 - How to generate a runtime dump on SAP HANA)
hdbcons "runtimedump dump -f /test/rte_dump.txt"
- 28) Sizing Hana Basic Calculations
SAP BW Sizing On Hana Summary
RAM = (Source data footprint - 60gb) * 2 / 4 * c1 + 90gb
or
RAM = ( colstore tables footprint * 2 / 4 + rowstore tables footprint /1.5) * c1 + 50gb
Disk persistence = 4 * RAM
Disk Log = 1 * RAM
c = source database specific compression factor (where applicable)
Memory Sizing: Runtime Objects
RAM dynamic + RAM static
Total RAM is
RAM = (Source data footprint - 60gb) * 2 / 4 * c1 + 90gb
or
RAM = ( colstore tables footprint * 2 / 4 + rowstore tables footprint /1.5) * c1 + 50gb
c = source database specific compression factor (where applicable)
Disk Sizing
Disk persistence = 4 * RAM
Disk Log = 1 * RAM
Useful OSS Notes:
OSS 1736976 - Sizing Report for BW on HANA
OSS 1514966 - SAP HANA 1.0: Sizing SAP In-Memory Database
SAP BW on HANA Sizing Report - https://websmp209.sap-ag.de/~sapidb/012006153200000051552013E/SAP_BW_on_HANA_Sizing_Report_V1_4.pdf
OSS 1799449 - Sizing report ERP on SAP HANA database
OSS 1855041 - Sizing Recommendation for Master Node in BW-on-HANA
- 29) HANA SSO with Kerberos and Active Directory
The configuration is a complex task with various sources of error.
Main reasons are the cross OS nature of the setup (Linux/ Windows), often resulting
in problems with case (Windows: case insensitive, Linux: case sensitive) and the tight
integration into the network configuration (/etc/hosts, DNS).
In particular, there are various sources of error when creating the keytab and exporting it
from Active Directory.
The process is highly manual and consists of several steps across different operating
systems and hosts.
A python script is provided in SAP Note 1813724 which automates the creation of the
keytab.
In addition, the IP configuration at the HANA appliance is validated (hostname resolution
/ reverse lookup) and the Kerberos configuration is checked for consistency with the remote
Active Directory.
Unzip the attached hdbkrbconf.zip and run as <sid>adm
$ python hdbkrbconf.py -h
for help.
There are two main options, "-k" for creating the keytab and "-v" for validating the
configuration including the keytab.
Option "-V" will provide verbose output, together with an analysis file for SAP support.
This file will also be written in the event of an error.
More info, check: SAP Note 1813724 - HANA SSO/Kerberos: create keytab and validate conf
- 30) Row Store Reorganisation
Row store memory size is a lot bigger than the actual data size in row store and shows
high fragmentation ratio.
Row store grows by allocating a 64MB memory segment and shrinks by freeing empty
segments.
A segment is internally divided into fixed-size pages. When a row store table requires more
memory to store records, the table takes a free page from existing segments. If no segment
has a free page, a new segment is allocated.
Deleting a large number of records may result in a number of sparse segments. In such a case,
row store reorganization can be performed for memory compaction. The pages in sparse
segments are moved to other segments and the resultant empty segments are freed.
If the prerequisites are not satisfied, row store reorganization should not be executed.
The prerequisites, queries, and monitoring views used for the queries are applicable to Rev 50 and
to change in future releases.
o HANA Database Rev 50 or later
- HANA Database has to be upgraded prior to run row store
reorganization
o Catalog integrity check
- The following procedure call should run successfully and
returns empty result set.
CALL CHECK_CATALOG
('CHECK_OBJECT_REFERENTIAL_INTEGRITY','','','');
o Row store reorganization is recommended, when allocated row store
size is over 10GB and free page ratio is over 30%.
SELECT HOST, PORT, CASE WHEN (((SUM(FREE_SIZE) /
SUM(ALLOCATED_SIZE)) > 0.30) AND SUM(ALLOCATED_SIZE) >
TO_DECIMAL(10)*1024*1024*1024) THEN 'TRUE' ELSE 'FALSE' END
"Row store Reorganization Recommended", TO_DECIMAL(
SUM(FREE_SIZE)*100 / SUM(ALLOCATED_SIZE), 10,2) "Free Space
Ratio in %",TO_DECIMAL( SUM(ALLOCATED_SIZE)/1048576, 10, 2)
"Allocated Size in MB",TO_DECIMAL( SUM(FREE_SIZE)/1048576, 10,
2) "Free Size in MB" FROM M_SHARED_MEMORY WHERE ( CATEGORY =
'TABLE' OR CATEGORY = 'CATALOG' ) AND PORT LIKE '%03' GROUP BY
HOST, PORT;
If the result of "Reorganization Recommended" is "TRUE", then row
store memory can be reclaimed after row store reorganization.
o Estimation on maximum possible memory space that can be reclaimed:
SELECT SUM(NUM_FREE_DATA_PAGES)*16/1024 "Estimated Maximum
Memory Saving in MB" FROM SYS.M_DEV_MEMORY_SEGMENT WHERE
SEGMENT_TYPE = 0;
o Check disk space where log files are located.
SELECT (SUM(NUM_FREE_DATA_PAGES)*16/1024)*1.5 "Estimated Log
Volume Size in MB" FROM SYS.M_DEV_MEMORY_SEGMENT WHERE
SEGMENT_TYPE = 0;
Row store reorganization procedure
1. Make a complete database backup
2. Upgrade database to Rev50 or later
3. Make sure to start up database at least once during upgrade.
4. Shutdown HANA database.
5. Set up configuration parameter in indexserver.ini via HANA Studio.
[row_engine] page_compaction_enable = true
6. Restart the database. Startup will take longer than normal startup
when row store reorganization runs.
7. Check the memory fragmentation status after reorganization:
SELECT HOST, PORT, CASE WHEN (((SUM(FREE_SIZE) /
SUM(ALLOCATED_SIZE)) > 0.30) AND SUM(ALLOCATED_SIZE) >
TO_DECIMAL(10)*1024*1024*1024) THEN 'TRUE' ELSE 'FALSE' END
"Row store Reorganization Recommended", TO_DECIMAL(
SUM(FREE_SIZE)*100 / SUM(ALLOCATED_SIZE), 10,2) "Free Space
Ratio",TO_DECIMAL( SUM(ALLOCATED_SIZE)/1048576, 10, 2)
"Allocated Size in MB",TO_DECIMAL( SUM(FREE_SIZE)/1048576, 10,
2) "Free Size in MB" FROM M_SHARED_MEMORY WHERE ( CATEGORY =
'TABLE' OR CATEGORY = 'CATALOG' ) AND PORT LIKE '%03' GROUP BY
HOST, PORT;
8. Check Indexserver trace
Please check the indexserver trace files after row store
reorganization is done.
Row store reorganization is performed in 11 phases when successful.
It prints out "[RSReorg] start" message at the beginning,
"[RSReorg] success" message followed by "Reorganization statistics"
at the end. When there are errors during reorganization, row store
reorganization is stopped in that phase and all the changes are
rolled back and database starts up to return to its original state
Ref: SAP Note 1813245 - SAP HANA DB: Row store reorganization before reorganization is run.
- 31) How to generate a runtime dump on SAP HANA saphostagent/sapdbctrl for Hana
SAP Support asks you to generate a runtime dump during a high CPU/Memory consumption
a) Log into the linux HANA host as sidadm user;
b) Run command 'hdbcons';
c) On the hdbcons console run command below:
> runtimedump dump
This will create a file under traces directory called 'indexserver....rtedump.trc'.
d) Attach generated trace file to the OSS Message
Or alternatively
hdbcons "runtimedump dump -f /test/rte_dump.txt"
More info check SAP OSS Note: 1813020
- 32) DBSL hints for SAP HANA
The following DBSL hints are available for SAP HANA.
o dbsl_equi_join
You can use this hint for a FOR_ALL_ENTRIES in order to inform the
DBSL that an EQUI join can be created from this FAE statement; this
EQUI join can then be resolved for an IN data set.
You must then specify this hint together with the hint of the DBI interface
(&prefer_join 1&) in the statement (see Note 48230).
ABAP
SELECT * INTO <rtab> FROM <table> FOR ALL ENTRIES IN itab
WHERE a = itab-a AND b = itab-b AND c = itab-c AND d = itab-d
%_HINTS HDB '&prefer_join 1&' hdb 'dbsl_equi_join'
From this, the system generates the following statement for the
database.
SQL for the database
select * from <table> where (a, b, c, d) IN
( (?, ?, ?, ?), ... (?, ?, ?, ?) )
o dbsl_add_stmt
Use: dbsl_add_stmt <SQL enhancement>
This hint provides you with the option of adding an additional SQL
enhancement to the SQL statement in the DBSL. This hint is resolved
in the DBSL and the system appends the following text to the end of
the statement that was generated (after the keyword
dbsl_add_stmt).
ABAP
SELECT node FROM <table> CONNECTION ('HANA') INTO TABLE T_NODE
%_HINTS HDB 'dbsl_add_stmt WITH PARAMETERS (''expression'' =
''LEAVES("Node1")'' )'
SQL for the database
select node from table
with parameters ( 'expression' = 'leaves("Node1")' )
This hint is available in the following releases:
720 DBSL as of patch level 103
720-EXT DBSL as of patch level 103
803 DBSL
Note
In Release 7.20, you cannot use the keyword %_HINTS HDB to define the
hints for SAP HANA; instead, you must use the keyword %_HINTS ADABAS.
The database interfinterface ensures that this hint is also generated for an SAP
HANA Connection.
Ref: Useful OSS SAP Note 1622681 - DBSL Hints for Hana
http://help.sap.com/businessobject/product_guides/HAN01SP4/en/hana_sps4_HDB_server_inst_en.pdf
You can rename an SAP HANA database system as described in this section.
Caution:
Renaming a SAP HANA database system that is running with a permanent SAP license invalidates the
license so that the instance is locked down.
You need to request a new license key with the new system
ID and the new hardware key
(generated by renaming) in order to unlock the renamed system.
This especially impacts renaming in batch mode: since the renamed instance is locked down,
no other activities except license installation are then possible.
For more information, see SAP License Key.
Before performing the rename, you need to meet these prerequisites:
• You identify an existing SAP HANA database system, created by an installation or a file system
copy, that is to be renamed.
• The target system ID (SID) must not exist.
• The target instance number must not exist.
• You are logged in as the root user.
• If a mountpoint contains the system ID, you must first rename it manually before performing the
rename of the SAP HANA database.
To rename the instances of a distributed system, you perform the rename for all hosts with a single call of hdbrename.
Renaming a System in Interactive Mode
Make sure that you meet the prerequisites in Renaming a SAP HANA Database System .
In interactive mode, the program queries all essential parameters that are not defined using
command line options as well as parameters that have invalid values.
a. Open a root shell.
b
. Via the local mount point, change to the following directory on the shared file system:
/<sapmnt>/<SID>/global/hdb/install/bin
c. Call the hdbrename program by entering this command:
./hdbrename
d
. Specify the required data.
The system is now renamed.
Example Usage:
OSS Note 1738390 - How to update SAP HANA Linux server hardware key
When you have installed SAP HANA, you want to update the Linux server hardware key.
Prerequisite: You have logged on to Linux as SAP HANA instance administrator.
To update the hardware key, follow the procedure below:
Stop the SAP HANA DB instance
Remove line 'id=<a number>'
in /usr/sap/<SID>/SYS/global/hdb/custom/config/nameserver.ini
Execute 'hdbnsutil -convertTopology'
Start the SAP HANA DB instance
NOTE: Reinstallation of SAP HANA will generate a different hardware key,
but upgrade of SAP HANA will not change the hardware key.
- 35) hdbsrvutil - Example Usage
https://cookbook.experiencesaphana.com/bw/operating-bw-on-hana/hana-database-administration/troubleshooting/sap-support/location-and-usage/
Collecting Location and Usage Information
There is a Python script which allows you to collect support information for customer systems
even when no access to the system via SQL is possible.
This information can be added to the support message.
The name of the Python script is fullSystemInfoDump.py and is part of a server installation.
It runs from a command line and is located in the directory $DIR_INSTANCE/exe/python_support (Linux).
To execute the script <sid>adm rights of the customer system are required.
To start the script out of its location directory, enter: python fullSystemInfoDump.py
By default the script creates a zip file with all of the collected support information to the directory
DIR_TEMP/system_dump where DIR_TEMP is the content of the variable with the same name in sapprofile.ini.
This output directory is shown as console output when the script is running, but it can be looked up by entering:
hdbsrvutil -z | grep DIR_TEMP=
To change the default directory, an explicit absolute path can be given to the script, for example:
python fullSystemInfoDump.py <output_dir>
Usage information can be displayed by entering:
python fullSystemInfoDump.py –h
To collect support information you need an SQL user with rights to select the system tables and
views listed in System Tables/Views.
For security reasons the user name and password for this SQL user cannot be given as command
line parameters to the script.
If the customer system can be reached via SQL and the user name and password information is valid,
the script starts collecting support information. If user name and/or password are invalid, the script aborts.
If the customer system cannot be reached via SQL the script only collects information which can be
read without SQL access. The resulting zip file name has the following structure:
fullsysteminfodump_<SAPLOCALHOSTFULL>_<SAPSYSTEMNAME>_<YYYY>_<MM>_<DD>_<HH>_<MM>_<SS>.zip
SAPLOCALHOSTFULL and SAPSYSTEMNAME are again taken from sapprofile.ini.
- 36) Show Hana Processes HDB proc & HDB info
HDB proc
HDB info
eg /usr/sap/HDB/HDB00/HDB info