SAP Start Service in HA environments

SAP Start Service or sapstartsrv is a Unix daemon / Windows service assigned to an SAP instance. It controls and monitors the assigned instance. Since sapstartsrv is a vital part of any SAP instance and due its specific feature a proper HA setup needs to handle sapstartsrv correctly and can make use of its features. This paper provides some information which should help HA partners to handle it correctly Download the Document

PUBLICSAP Start Service in HA environmentsDate: 2025-01-03Owner: Server Infrastructure Team
© 2025 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 2 / 6Table of contentsIntroduction ................................................................................................................................................................. 3Sapstartsrv Startup and Lifecycle ..................................................................................................................... 3Instance Start/Stop .................................................................................................................................................. 4Instance Monitoring ................................................................................................................................................. 4Webservice Authentication .................................................................................................................................. 5Sapcontrol Command Line Tool ........................................................................................................................ 5Error Handling and Cleanup................................................................................................................................. 5SAP HA Shared Library Interface ....................................................................................................................... 6Documentation .......................................................................................................................................................... 6
© 2025 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 3 / 6IntroductionSap Start Service or sapstartsrv is a Unix daemon / Windows service assigned to an SAP instance. It controlsand monitors the assigned instance. Since sapstartsrv is a vital part of any SAP instance and due its specificfeature a proper HA setup needs to handle sapstartsrv correctly and can make use of its features. This paperprovides some information which should help HA partners to handle it correctly.There is one additional sapstartsrv installed once per hosts offering OS, database and LM relatedfunctionality. The following is not related to this SAP Hostagent sapstartsrv. SAP Hostagent must not behandled by a HA setup. It is installed on a machine and must not be moved by a HA failover.Sapstartsrv Startup and LifecycleOn Windows, sapstartsrv is installed as a Windows service. By default, it is installed with startup type“Automatic”. It provides a self-registration / unregistration capability via “-r” and “u” option.On UNIX sapstartsrv runs as a daemon. This is achieved by installing “sapinit” once on the machine. Eachsapstartsrv gets registered in /usr/sap/services. The self-registration / unregistartion capability is provided via-reg” and “unreg” option.This way sapstartsrv is designed to get started at OS boot and remains running “forever”. Even if the assignedSAP instances gets stopped sapstartsrv remains running. However, when applying a kernel patch it will getupdated via sapcpe during instance start. In this case sapstartsrv will restart itself 5 minutes after the updatehappened.In a HA setup sapstartsrv must be moved together with the assigned instance. Furthermore, the HA setupmust ensure that sapstartsrv is only running on the cluster node which actually owns the assigned instance.Typically, one the following two solutions can be used: Sapstartsrv is registered on both/all cluster nodes. In this case the HA solution must ensure it canand will only be started on one of the nodes. E.g. on Windows the service startup type can beswitched to “Manually” and service startup is controlled by the HA solution. Another option is toensure the file system hosting the instance executables is only accessible on one cluster node. Sapstartsrv is only registered on the active cluster node. In this case the HA solution must unregisterand register sapstartsrv during a failover.Sapstartsrv can also be restarted manually via its webservice function “RestartService”, e.g. triggered by anAdministrator via SAP MMC / MC or sapcontrol to activate certain configuration changes. A HA solution musthandle manual and automatic sapstartsrv restarts, e.g. by tolerating short term sapstartsrv unavailablesituations. Long term sapstartsrv failure should be handled by the HA solution. The HA solution may try torestart a failed sapstartsrv using function “StartService” of the “sapcontrol” command line tool. If sapstartsrvcan be restarted it will pick up the instance processes automatically and continue operating as usual.By using webservice function “StopService” sapstartsrv can be stopped without stopping the instance. Ifsapstartsrv is stopped normally (Windows Service control manager or SIGINT) it will stop the assignedinstance as well.
© 2025 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 4 / 6Instance Start/StopInstance start/stop is triggered via webservice functions “Start” / “Stop” of sapstartsrv. Traditional SAPstart/stop command line tools have been adapted to use the webservice interface as well (directly or via“sapcontrol” command line tool). On Windows the deprecated DCOM interface of sapstartsrv still exists butshould not be used anymore.On UNIX, sapstartsrv does not launch the instance process directly. Instead, sapstart is used to actuallystart the processes. Anyway, sapstart should not be used directly to start the instance (bypassingsapstartsrv).The actually started processes are configured in the profile using Start_Program_<NR> profile parameters.By using Restart_Program_<NR> parameter instead, a process which died unexpectedly gets restartedautomatically. This may e.g. be used to restart the message server in case of failure to avoid a complete SCSinstance failover if possible or to restart the enqueue replication server of the ERS instances automaticallyafter a successful lock table transfer.Instance MonitoringThe major webservice function to monitor the instance status is “GetProcessList”. It returns a list of allprocesses started via the profile. Each process has a status color: Gray: Stopped Yellow: Running with problems or a synchronous temporary process like “sapcpe” executed duringstartup Green: Running Red: Could not be startedFor most critical process a status monitoring beyond just “process is running” is performed: disp+work: Verify instance is connected to message server, verify dialog queue info can be read fromshared memory, verify progress in dialog queue processing. In case of double stack jstart/jcontrolstatus is integrated jstart/jcontrol: Verify status information from AS Java startup framework enq_server: Verify enqueue statistic can be retrieved from enqueue server msg_server: Verify message server client list can be retrieved from message serverAn instance is considered as fully available if all processes have a green status. The overall instance status isreported by sapstartsrv every 60 sec in available.log in DIR_HOME of the assigned instance. During the firstrestart after a kernel switch the status of disp+work, jstart, jcontrol may remain yellow for some minutesalthough the instance is fully operational until sapstartsrv gets (automatically) restarted. This is caused byusing shared memory for monitoring which may cause an old sapstartsrv to fail accessing the shared memorycreated by a new version of disp+work, jstart, jcontrol. A HA solution needs to handle temporary “yellow”status of processes.“EnqGetLockTable” and “EnqGetStatistic” can be used to monitor the enqueue server in more detail.Especially “EnqGetStatistic” / EnqGetStatistic2 provides information about the replication state which maybe used to avoid triggering failovers in case of missing or failed replication.“J2EEGetProcessList” provides additional status information for AS Java.
© 2025 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 5 / 6“GetAlertTree” and “GetAlerts” provide general CCMS status information (similar to rz20 transaction)“GetSystemInstanceList” provides information on all instances of the system (updated asynchronously every60 sec by each sapstartsrv in the system).Webservice AuthenticationThe webservice interface of sapstartsrv requires client authentication for executing critical functions like“Start” or “Stop”. By default, almost all functions are protected. However, SAP customers are free change thissetting according to their security requirements. A HA product using the webservice interface must be able toprovide proper authentication. By default, http basic authentication with OS <sid>adm user and passwordcan be used. For local connections a so called “trusted connect” can be used via the “sapcontrol” commandline tool (Option: Windows: “-prot PIPE”, UNIX: “-prot NI_HTTP” (default)). This way when executed as<sid>adm all functions of the webservice interface can be executed without explicitly providing OS user andpassword.For more details and advanced security features please refer to SAP note 927637 and 1439348.Sapcontrol Command Line ToolThe HA product can access the webservice interface of sapstartsrv by using the “sapcontrol” command linetool or by implementing a webservice client on its own. By using the “sapcontrol” tool a trusted connect canbe used (see above), however the output of sapcontrol needs to be analyzed by the HA product in this case.Sapcontrol provides some exit codes to detect success or failure of an operation:0 Last webmethod call successful1 Last webmethod call failed, invalid parameter2 StartWait, StopWait, WaitforStarted, WaitforStopped, RestartServiceWait timed out3 GetProcessList succeeded, all processes running correctly4 GetProcessList succeeded, all processes stoppedFurthermore option “-format script” can be used to generate an easy to parse output format.Error Handling and CleanupSince sapstartsrv is a mandatory component, for normal instance stop additional steps are necessary to stopan instance in case of permanent sapstartsrv failure. In general SAP processes can be stopped using SIGINTsignal. A soft shutdown can be triggered via SIGQUIT. Finally, processes can be killed by using“TerminateProcess” / SIGKILL. On Windows sapstartsrv creates a JobObject named SAP<SID>_<NR> whichhosts all processes of the assigned instance (including sapstartsrv itself). This can be used to find anydangling processes which need to be stopped for cleanup. On UNIX “kill.sap” and “shutdown.sap” aregenerated in DIR_HOME during instance startup. They can be used to send a SIGINT to “sapstart” or the childprocesses of “sapstart”.During normal instance start/stop shared memory is cleaned up by the instance processes. In case ofproblems this may not always be performed correctly. On Windows SAP shared memory is automatically