Skip to content

Instantly share code, notes, and snippets.

@shaheerxt
Last active November 11, 2021 10:44
Show Gist options
  • Save shaheerxt/298e66270df14ad81ce230d9a15106c3 to your computer and use it in GitHub Desktop.
Save shaheerxt/298e66270df14ad81ce230d9a15106c3 to your computer and use it in GitHub Desktop.
SAP HANA HSR Setup
DB name:
ABC
DB Instance No:
01
Site 1 hosts:
site1node1abc.somedomain.com
site1node2abc.somedomain.com
Site 2 hosts:
site2node1abc.somedomain.com
site2node2abc.somedomain.com
Add below entries in both primary and secondary /etc/hosts file
#HSR Primary
10.200.10.2 hana01-01 site1node1abc.somedomain.com
10.200.10.3 hana01-02 site1node2abc.somedomain.com
#HSR Secondary
10.201.20.2 hana01-01 site2node1abc.somedomain.com
10.201.20.3 hana01-02 site2node2abc.somedomain.com
Get the IP address of the database host by looking at any one info below
(i) nslookup hostname
(ii) hostname -i
(iii) ping hostname
(iv) ifconfig -a
(v) ip addr -4 a s
Add respective IP address in /etc/hosts file. We need to add both primary and secondary DB hosts IP mappings in /etc/hosts of both sites.
From Primary, trigger local full database backups for all databases within MDC. This is required for initial data replication to secondary.
You might have minimum 2 DBs (SYSTEMDB, and default Tenant, in this case ABC, if you haven't removed the tenant).
Please refer:
link.medium.com/68Z9iAcFPeb for backups
Primary
hdbnsutil -sr_enable --name=SITE1_PRIM_ABC
# status message 'done' if everything alright
Make sure the Secondary DB cluster is down, if not
sapcontrol -nr 1 -function StopSystem
Register secondary using:
hdbnsutil -sr_register --remoteHost=site1node1abc --remoteInstance=01 --replicationMode=async --operationMode=logreplay --name=SITE2_SEC_ABC
# status message 'done' if everything alright
Start secondary HANA:
sapcontrol -nr 01 -function StartSystem
Once the system started, from Primary, issue below commands to check the status of sync:
sql> select * from m_service_replication; (check the column REPLICATION_STATUS)
(or)
cmd# cdpy; python systemReplicationStatus.py (to be run as sidadm OS user, in this case abcadm user)
(or)
cmd# hdbcons -e hdbindexserver "replication info" (to be run as sidadm OS user, in this case abcadm user)
(or)
cmd# hdbcons -e hdbindexserver "replication info" | egrep 'sentLogPosTimestamp|shippedLogPosTimestamp' (to be run as sidadm OS user, in this case abcadm user)
--------------------------------------
#pitfalls
Hardly you would get any issue while setup, but there are chances. Here is what to look out and remediation
unable to contact primary site host hana01-01:40102. internal error,location=hana01-01:40102. Trying old-style port (port offset +100)...hana01-01:40102
(or)
unable to contact primary site host 10.200.10.2 (hana01-01):40102. internal error,location=10.200.10.2:40102. Trying old-style port (port offset +100)...10.237.58.19 (hana01-01):40102
==> make sure we have correct hostname/ip mappings setup in DB global.ini file
[system_replication_hostname_resolution]
10.200.10.2 = site1node1abc
10.200.10.3 = site1node2abc
10.201.20.2 = site2node1abc
10.201.20.3 = site2node2abc
primary and secondary has different systemPKI SSFS data and key or unable to check;Secondary system PKI SSFS-data-file checksum is different from primary!
==> Starting with HANA 2.0, we need to copy PKI datafile and key (sample below) from Primary to Secondary before we register the secondary. We can SCP/winSCP/SFTP the files for this task. Keep it in same location as primary.
/usr/sap/ABC/SYS/global/security/rsecssfs/data/SSFS_QAK.DAT
/usr/sap/ABC/SYS/global/security/rsecssfs/key/SSFS_QAK.KEY
unable to contact primary site; to 10.200.10.2 (hana01-01):40102; original error: timeout occured,location=10.200.10.2:40102. Was MTU size set to 1500? (Please refer to SAP Note 2142892);
==> Check the MTU value setup for the NIC interface. It should be 1500 as recommnded for HANA HSR setup. We can keep 1500 for HSR communication interfaces (NICs communicating between primary and secondary).
ifconfig -a # see the mtu value right next to the interface name
ifconfig <interface> mtu 1500 # change to 1500, sudo priv necessary. It's online.
Relevant Notes (Incase of any issues, or for your detailed understanding):
https://launchpad.support.sap.com/#/notes/2772007 - Error : system replication port could not be opened;port=40002
https://launchpad.support.sap.com/#/notes/2518396 - SAP HANA system replication - registration of secondary site fails
https://launchpad.support.sap.com/#/notes/2183363 - Configuration of SAP HANA internal network
https://launchpad.support.sap.com/#/notes/2748924 - Enabling HANA System replication returns error after Hardware change on secondary site
https://launchpad.support.sap.com/#/notes/2369981 - Required configuration steps for authentication with HANA System Replication
https://launchpad.support.sap.com/#/notes/2142892 - SAP HANA System Replication sr_register hangs at "collecting information"
https://launchpad.support.sap.com/#/notes/2081065 - Troubleshooting SAP HANA Network
https://launchpad.support.sap.com/#/notes/2222200 - FAQ: SAP HANA Network
https://launchpad.support.sap.com/#/notes/2092196 - How-To: Terminating Sessions in SAP HANA (for MTU related findings)
https://launchpad.support.sap.com/#/notes/2166157 - Error: 'failed to open channel ! reason: connection refused' when setting up Disaster Recovery
https://help.sap.com/viewer/bed8c14f9f024763b0777aa72b5436f6/2.0.02/en-US/0890ba10276e4b0a825640b197be7854.html - Setup and Initial Configuration Problems
@akuma85
Copy link

akuma85 commented Nov 9, 2021

HDB Version takes longer time in reporting back the status of systemreplication status

@shaheerxt
Copy link
Author

HDB version returns only HANA version details. For replication details, you can issue
python systemreplicationstatus.py
from python directory (Alias to the directory : cdpy)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment