SAP and SAP HANA: discovery, stop and start on Linux
Discover SAP systems and stop/start SAP HANA and application instances with HDB and sapcontrol.
Quick reference to discover the SAP systems installed on a Linux server, then stop and start a SAP HANA database and the associated SAP application instances.
In the examples, <SID> is the SAP system ID, hdbadm is the <sid>adm user of the HANA database and appadm the one of the application.
Discover SAP systems
List the SAP start processes:
ps -eo pid,command | grep -v grep | grep -v sapstartsrv | grep sapstart | awk '{print $3}'
Identify the SIDs and their profiles:
ls /usr/sap/
ls /usr/sap/<SID>
ls /usr/sap/<SID>/SYS/profile/
vim /usr/sap/sapservices
Find the instance number (SAPSYSTEM) in the profiles:
grep -R "SAPSYSTEM =" /sapmnt/*/profile/*
Stopping and starting SAP HANA
If the database is not configured for autostart, a manual action is required after a server reboot.
Log on to Linux as the database <sid>adm user, then:
HDB stop
HDB start
For a tenant database or the whole system:
ALTER SYSTEM START DATABASE <database_name>
/usr/sap/<SID>/HDB<instance>/exe/sapcontrol -nr <instance> -function StartSystem HDB
/usr/sap/<SID>/HDB<instance>/exe/sapcontrol -nr <instance> -function StopSystem HDB
To change the restart mode of a tenant:
ALTER DATABASE <database_name> DEFAULT RESTART
Stopping and starting the SAP application
A SAP installation usually has central services (for example instance 00) and an application server (for example instance 10). Order matters: start the central services first, stop the application server first.
Start:
sapcontrol -nr 00 -function StartSystem ALL
sapcontrol -nr 10 -function StartSystem ALL
Stop:
sapcontrol -nr 10 -function StopSystem ALL
sapcontrol -nr 00 -function StopSystem ALL
Direct execution as the <sid>adm user:
su - appadm -c "sapcontrol -nr 00 -function StartSystem ALL"
su - appadm -c "sapcontrol -nr 00 -function StopSystem ALL"
Other useful commands: stopping the service itself and listing processes.
sapcontrol -nr 00 -function StopService
sapcontrol -nr 00 -function GetProcessList
stopsap r3
If the server provides /etc/rc.SAP.* scripts (installation-specific), they can be used with sudo: sudo /etc/rc.SAP.<name> stop.
Check the status
sudo ps -ef | grep -i HDB
HDB proc # as the <sid>adm user
hdbuserstore list # user store keys
df -h
The status can also be checked in SAP HANA Studio.
Notes
- Instance numbers (00, 01, 10) are examples: check them against the profiles.
rc.SAP.*script and user names depend on the installation.