susCostOpt.py(7)
π susCostOpt.py β the SAPHanaSR glow-up, section 7 style
okay bestie, buckle up π this is susCostOpt.py from the SAPHanaSR manual set (section 7, very official, very iconic), and it's genuinely not scary once you know what it's doing. let's get into it.
β¨ NAME β¨
susCostOpt.py β the provider for the SAP HANA srHook method postTakeover(). that's it, that's the whole name section π
πΈ DESCRIPTION πΈ
so susCostOpt.py can be used to provide a script for the SAP HANA HA/DR hook provider method postTakeover(). π«Ά
the SAP HANA nameserver hands you a Python-based API (they call them "HA/DR providers"), and it gets called at the important moments of the host auto-failover and system replication takeover processes. these so-called hooks are literally there so you can run arbitrary operations that need to be executed. and the method postTakeover() β you guessed it β gets called after a successful sr_takeover action. main character timing, honestly. π
what susCostOpt.py actually does: it executes SQL statements to remove the memory allocation limit and switches off HANA column table preload after takeover from primary to secondary site in an SAP HANA scale-up cost-optimised scenario. slay. π
this hook script needs to be configured and activated on the secondary node. not the primary. secondary. no cap. π¨
π SUPPORTED PARAMETERS π
the "HA/DR providers" API accepts these parameters for the ha_dr_provider_suscostopt section:
provider = susCostOptβ mandatory. must not be changed. like, don't touch it. πpath = /usr/share/SAPHanaSR-angiβ mandatory. please change only if requested.costopt_primary_global_allocation_limit = [ 0 | <limit-in-mb> ]β optional. not set or set to0means unlimited.userkey = <costoptkey>β optional. default issaphanasr_<SID>_costopt.execution_order = 2β mandatory. needs to run aftersusHanaSR.py. respect the queue bestie π§
and the "HA/DR providers" API accepts this parameter for the trace section:
ha_dr_suscostopt = [ info | debug ]β optional. will be added automatically if not set. it's giving self-sufficient β¨
π₯ RETURN CODES π₯
0β successful program execution. we love a happy ending π>0β usage, syntax or execution errors. π
π¦ EXAMPLES π¦
example entry in SAP HANA global configuration
file: /hana/shared/$SID/global/hdb/custom/config/global.ini
the section ha_dr_provider_suscostopt is needed on the secondary site only. additional settings in sections memorymanager and system_replication on secondary site are needed for the cost-optimised scenario. the example SID is HA1, memory limit is 24000MB in case of running as HANA secondary, 32000MB in case of running as HANA primary. these settings will be changed in case of takeover. so they need to be restored in order to recover the original state. see also the example recovery procedure. the HANA has to be stopped before the file can be changed. π
[memorymanager]
global_allocation_limit = 24000
[system_replication]
preload_column_tables = false
...
[ha_dr_provider_suscostopt]
provider = susCostOpt
path = /usr/share/SAPHanaSR-angi
userkey = saphanasr_HA1_costopt
costopt_primary_global_allocation_limit = 32000
execution_order = 2
[trace]
ha_dr_suscostopt = info
...
example: checking the HANA tracefiles for postTakeover() events
to be executed on HANA secondary site.
# su - ha1adm
~> cdtrace
~> grep susCostOpt.*postTakeover nameserver_*.trc
example: checking the HANA tracefiles for when the hook script has been loaded
to be executed on HANA secondary site.
# su - ha1adm
~> cdtrace
~> grep HADR.*load.*susCostOpt nameserver_*.trc
~> grep susCostOpt.init nameserver_*.trc
example: adding the HANA database user to <sid>admΒ΄s keystore
the HANA database user SYSTEM has permission to change memory limit and column pre-load. for security reasons on production systems always a dedicated user with restricted permission needs to be created. π the keystore for <sid>adm has to be created on secondary site. the example SID is HA1, lowercase-SID is ha1, instance number is 10, TCP port for database access is 31013, database user is SYSTEM, userkey in keystore is saphanasr_HA1_costopt, password is SuSE1234. please refer to SAP documentation for details on HANA commands.
# su - ha1adm
~> hdbuserstore SET saphanasr_HA1_costopt localhost:31013 SYSTEM SuSE1234
~> hdbuserstore LIST saphanasr_HA1_costopt
overview on recovery procedure for reverting to normal operation after takeover
on postTakeover() the hook script changes configuration in memory and in persistence. it is necessary to recover the initial settings on secondary site (step 7) before the fully operational state can be re-established (steps 8-11). further, the HANA cluster resource default is AUTOMATED_REGISTER=false. this also makes administrative interaction necessary (steps 1-4). if AUTOMATED_REGISTER=true is set, the Linux cluster will do that automatically. see manual page ocf_suse_SAPHanaController(7) for details on cluster resource settings. use exact same site names as known to the Linux cluster. see manual page SAPHanaSR_maintenance_examples(7). before doing anything with the cluster, and after something has been done, the status of Linux cluster and HANA system replication has to be checked. see manual page SAPHanaSR_maintenance_examples(7). π
the procedure at a glance:
- set HANA multi-state resource into maintenance
- clean up HANA primitive resource
- site_A: register former primary as new secondary
- site_A: start new secondary, and wait for SR sync to finish
- site_B: stop primary
- site_A: do
sr_takeoveron secondary - site_B: adapt
global.inion stopped former primary - site_B: register former primary as new secondary
- site_B: start new secondary, and wait for SR sync to finish
- refresh HANA multi-state resource
- take HANA multi-state resource out of maintenance
adapting configuration for secondary in memory and in persistence (global.ini)
this can be done for adapting the global.ini to prepare a future secondary. e.g. in the context of the above procedure for reverting back to the initial state. in that context it might be done before the primary gets stopped at step 5. in that case above step 7 is not needed anymore. efficiency queen π§ββοΈ
example instance number is 00, SID is S07, user keystore is saphanasr_S07_costopt, memory limit for the secondary database is 128000 MB.
# su - s07adm
~> hdbsql -i 00 -U saphanasr_S07_costopt -d SYSTEMDB
hdbsql SYSTEMDB=> ALTER SYSTEM ALTER CONFIGURATION
('global.ini','SYSTEM') \
SET ('memorymanager','global_allocation_limit') = '128000' \
WITH RECONFIGURE
hdbsql SYSTEMDB=> ALTER SYSTEM ALTER CONFIGURATION
('global.ini','SYSTEM') \
SET ('system_replication','preload_column_tables') = 'false' \
WITH RECONFIGURE
hdbsql SYSTEMDB=> quit
π FILES π
/usr/share/SAPHanaSR-angi/susCostOpt.pyβ the hook provider, delivered with the RPM/hana/shared/$SID/global/hdb/custom/config/global.iniβ on-disk representation of HANA global system configuration/usr/sap/$SID/home/.hdb/$HOST/β path to HANA user keystore/usr/sap/$SID/HDB$nr/$HOST/traceβ path to HANA tracefiles
β REQUIREMENTS β
- SAP HANA 2.0 SPS04 or later provides the HA/DR provider hook method
postTakeover(). - no other HADR provider hook script should be configured for the
postTakeover()method. hook scripts for other methods, provided in SAPHanaSR-angi, can be used in parallel tosusCostOpt.py, if not documented contradictingly. - the hook provider needs to be added to the HANA global configuration on the secondary site, in memory and on disk (in persistence).
- an HANA database user with permission for changing memory limit and table preload needs to be added to
<sid>admΒ΄s keystore on the secondary site. susCostOpt.pyis supported for SAP HANA scale-up, but not for scale-out. read it again. not scale-out. π
π BUGS π
in case of any problem, please use your favourite SAP support process to open a request for the component BC-OP-LNX-SUSE. go get your support ticket bestie π«Ά
π SEE ALSO π
SAPHanaSR-ScaleUp-CostOpt(7) , SAPHanaSR(7) , susHanaSR.py(7) , ocf_suse_SAPHanaTopology(7) , ocf_suse_SAPHanaController(7) , ocf_heartbeat_SAPInstance(7) , crm(8) , python3(8) , SAPHanaSR-manageProvider(8) , https://help.sap.com/docs/SAP_HANA_PLATFORM?locale=en-US https://help.sap.com/docs/SAP_HANA_PLATFORM/6b94445c94ae495c83a19646e7c3fd56/5df2e766549a405e95de4c5d7f2efc2d.html?locale=en-US
π«Ά AUTHORS π«Ά
A.Briel, F.Herschel, L.Pinne. legends, honestly π
π COPYRIGHT π
(c) 2022-2026 SUSE LLC susCostOpt.py comes with ABSOLUTELY NO WARRANTY. for details see the GNU General Public License at http://www.gnu.org/licenses/gpl.html (yes, the caps are load-bearing, it's giving legal π
)
and that's the whole vibe check, bestie π¦ this page is susCostOpt.py(7) from the SAPHanaSR set, dated 13 Apr 2023 β go off and configure your secondary node responsibly πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: SAPHanaSR-angi 1.3.4-160000.1.1 Β· GPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms