SAPHanaSR.py(7)

NAME
SAPHanaSR.py - Provider for SAP HANA srHook method srConnectionChanged().

DESCRIPTION
SAPHanaSR.py can be used to provide a script for the SAP HANA srHook method srConnectionChanged(). The SAP HANA nameserver provides a Python-based API ("HA/DR providers"), which is called at important points of the host auto-failover and system replication takeover process. These so called hooks can be used for arbitrary operations that need to be executed. The method srConnectionChanged() is called on the master nameserver as soon as one of the replicating services loses or establishes the system replication connection. This method is called only once. SAPHanaSR.py updates the cluster attribute srHook at changes of the HANA system replication status. Thus this attribute is more reliable than the attribute sync_state which is polled by RA monitors. This hook script needs to be configured and activated on all HANA nodes.

SUPPORTED PARAMETERS
* The "HA/DR providers" API accepts the following parameters for the ha_dr_provider_SAPHanaSR section:

[ha_dr_provider_saphanasr]

provider = SAPHanaSR
    Mandatory. Must not be changed.

path = /usr/share/SAPHanaSR
    Mandatory. Please change only if requested.

execution_order = [ INTEGER ]
    Mandatory. Order might depend on other hook scripts.

* The "HA/DR providers" API accepts the following parameter for the trace section:

[trace]

ha_dr_saphanasr = [ info | debug ]
    Optional. Will be added automatically if not set.

* The he SAPHanaController and SAPHana RA recognize the effecting system replication status via attributes in the CIB´s SAPHanaSR properties section. The SAP System Indentifier (sid) is given in lower case:

hana_${sid}_site_srHook_${site} = [ SOK | SFAIL | SWAIT ]

Note: SAPHanaSR-ScaleOut comes with a differnt SAPHanaSR.py that provides global attributes.

RETURN CODES
0 Successful program execution.
>0 Usage, syntax or execution errors.

EXAMPLES

* Example for entry in sudo permissions /etc/sudoers

    # SAPHanaSR (Scale-Up) needs for srHook
    ha1adm ALL=(ALL) NOPASSWD: /usr/sbin/crm_attribute -n hana_ha1_site_srHook_*

* Example for looking up the sudo permission for the srHook script.
All related files (/etc/sudoers and /etc/sudoers.d/*) are scanned. Example SID is HA1.

    # sudo -U ha1adm -l | grep "NOPASSWD.*crm_attribute.*hana_ha1"

* Example for entry in SAP HANA global configuration /hana/shared/$SID/global/hdb/custom/config/global.ini
This file is needed at both sites. The HANA has to be stopped before the files can be edited.

    [ha_dr_provider_saphanasr]
    provider = SAPHanaSR
    path = /usr/share/SAPHanaSR
    execution_order = 1
    [trace]
    ha_dr_saphanasr = info

    * Example for entry in SAP HANA 2.0 global configuration /hana/shared/$SID/global/hdb/custom/config/global.ini to enable multi-target aware third site.
    This entry is needed to allow ocf_suse_SAPHana(7) parameter AUTOMATED_REGISTER=true in multi-target environments. The HANA has to be stopped before the files can be edited. Do not copy the file between nodes. Please check SAP HANA documentation for details.

        [system_replication]
         ...
        register_secondaries_on_takeover = true
         ...

    * Example for creating the optional SAPHanaSR python object file manually. This object file will not be updated with RPM package updates.

        # mkdir -p /hana/shared/srhook
        # chown ha1adm.sapsys /hana/shared/srhook
        # su - ha1adm
        # cd /hana/shared/srhook
        # python -m py_compile /usr/share/SAPHanaSR/SAPHanaSR.py
        # ls -l SAPHanaSR.pyc

    * Example for checking the system log for srHook setting HANA system replication status in the CIB properties section. To be executed on respective HANA primary site's master nameserver.

        # grep "sudo.*crm_attribute.*srHook" /var/log/messages

    * Example for checking the HANA tracefiles for srConnectionChanged() events. To be executed on respective HANA primary site's master nameserver.

        # su - sleadm
        ~> cdtrace
        ~> grep SAPHanaSR.srConnectionChanged.*called nameserver_*.trc
        ~> grep crm_attribute.*SAPHanaSR nameserver_*.trc
        # exit

    * Example for checking the HANA tracefiles for when the hook script has been loaded. To be executed on both sites' master nameservers.

        # su - sleadm
        ~> cdtrace
        ~> grep HADR.*load.*SAPHanaS nameserver_*.trc

    * Example for comparing Linux cluster srHook attribute with current HANA SR state. SID is HA1. To be executed on current HANA primary site.

        # SAPHanaSR-showAttr | grep -A4 srHook
        # su - ha1adm -c "HDBSettings.sh systemReplicationStatus.py"

    * Potentially dangerous example for manually changing Linux cluster srHook attribute according to current HANA SR state. This might be desired if the HANA SR state has changed while the Linux cluster was completely down. SID is ICE, site is BERG, current HANA SR state is SFAIL.
    Note: Understand the impact before trying.

        # su - iceadm -c "HDBSettings.sh systemReplicationStatus.py"
        # cs_clusterstate -i
        # crm_attribute -n hana_ice_site_srHook_BERG -v SFAIL -t crm_config -s SAPHanaSR
        # SAPHanaSR-showAttr

    * Example for removing orphaned global srHook attribute. This might be done after upgrading from old-style srHook, to avoid confusion caused by different HANA HADR provider API versions. See also SAPHanaSR.py(7) and SAPHanaSR-manageAttr(8) from SAPHanaSR-ScaleOut. SID is HA1.

        # SAPHanaSR-showAttr
        # crm configure show SAPHanaSR
        # cs_clusterstate -i
        # crm_attribute --delete -t crm_config --name hana_ha1_glob_srHook
        # crm configure show SAPHanaSR
        # SAPHanaSR-showAttr

FILES

/usr/share/SAPHanaSR/SAPHanaSR.py
    the hook provider, delivered with the RPM

/hana/shared/srhook/SAPHanaSR.pyc
    the hook provider, if pre-compiled for the particular HANA (optional)

/hana/shared/$SID/global/hdb/custom/config/global.ini
    the on-disk representation of HANA global system configuration

/etc/sudoers , /etc/sudoers.d/*
    the sudo permissions configuration

/usr/sap/$SID/HDB$nr/$HOST/trace
    path to HANA tracefiles

/usr/sap/$SID/HDB$nr/.crm_attribute.$SITE
    the internal cache for srHook status changes while Linux cluster is down, file is owned by ${SID}adm and must never be touched

REQUIREMENTS
1. SAP HANA 2.0 SPS04 or later provides the HA/DR provider hook method srConnectionChanged() with multi-target aware parameters. SAP HANA 1.0 does not provide them. The multi-target aware parameters are needed for the SAPHanaSR scale-up package.

2. No other HADR provider hook script should be configured for the srConnectionChanged() method. Hook scripts for other methods, provided in SAPHanaSR, can be used in parallel to SAPHanaSR.py, if not documented contradictingly.

3. The user ${sid}adm needs execution permission as user root for the command crm_attribute.

4. The hook provider needs to be added to the HANA global configuration, in memory and on disk (in persistence).

5. If the hook provider should be pre-compiled, the particular Python version that comes with SAP HANA has to be used.

BUGS
In case of any problem, please use your favourite SAP support process to open a request for the component BC-OP-LNX-SUSE. Please report any other feedback and suggestions to feedback@suse.com.

SEE ALSO
SAPHanaSR(7) , ocf_suse_SAPHanaTopology(7) , ocf_suse_SAPHana(7) , ocf_heartbeat_IPaddr2(7) , susCostOpt.py(7) , susTkOver.py(7) , susChkSrv.py (7) , SAPHanaSR-monitor(8) , SAPHanaSR-showAttr(8) , SAPHanaSR-manageProvider(8) , SAPHanaSR-hookHelper(8) , crm_attribute(8) , sudo(8) , sudoers(5), python(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
F.Herschel, L.Pinne.

COPYRIGHT
(c) 2015-2018 SUSE Linux GmbH, Germany.
(c) 2019-2022 SUSE LLC
SAPHanaSR.py comes with ABSOLUTELY NO WARRANTY.
For details see the GNU General Public License at http://www.gnu.org/licenses/gpl.html