Chapter 4. Configuring the SAP HANA system replication
You must configure and test the SAP HANA system replication before you can configure the HANA instance in a cluster. Follow the SAP guidelines for the HANA system replication setup: SAP HANA System Replication: Configuration.
4.1. Prerequisites for the SAP HANA system replication setup Copy linkLink copied to clipboard!
SAP HANA configuration
SAP HANA must be installed and configured identically on both nodes.
Hostname resolution
Both systems must be able to resolve the FQDN of both systems. To ensure that FQDNs can be resolved even without DNS you can place them into /etc/hosts.
Example of /etc/hosts entries for the SAP HANA scale-up systems:
[root]# cat /etc/hosts ... 192.168.0.11 node1.example.com node1 192.168.0.12 node2.example.com node2
[root]# cat /etc/hosts
...
192.168.0.11 node1.example.com node1
192.168.0.12 node2.example.com node2
As documented at hostname | SAP Help Portal, SAP HANA only supports hostnames with lowercase characters.
SAP HANA log_mode
For the system replication to work, you must set the SAP HANA log_mode variable to normal, which is the default value.
Verify the current log_mode as the HANA administrative user <sid>adm on both nodes:
rh1adm $ hdbsql -u system -p '<HANA_SYSTEM_PASSWORD>' -i ${TINSTANCE} \
"select value from "SYS"."M_INIFILE_CONTENTS" where key='log_mode'"
VALUE "normal"
1 row selected
rh1adm $ hdbsql -u system -p '<HANA_SYSTEM_PASSWORD>' -i ${TINSTANCE} \
"select value from "SYS"."M_INIFILE_CONTENTS" where key='log_mode'"
VALUE "normal"
1 row selected
4.2. Performing an initial HANA instance backup Copy linkLink copied to clipboard!
You can only enable the HANA system replication when an initial backup of the SAP HANA instance exists on the primary instance for the planned SAP HANA system replication setup.
You can use SAP HANA tools to create the backup and skip the manual procedure. See SAP HANA Administration Guide - SAP HANA Database Backup and Recovery for more information.
Prerequisites
-
You have a writable directory to which the backup files are saved for the SAP HANA administrative user
<sid>adm. - You have sufficient free space available in the filesystem on which the backup files are stored.
Procedure
Optional: Create a dedicated directory for the backup in a suitable path, for example:
mkdir <path>/<SID>-backup
[root]# mkdir <path>/<SID>-backupCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<path>with a path on your system, which has enough free space for the initial backup files.Change the owner of the backup path to user
<sid>admif the target directory is not already owned or writable by the HANA user, for example:chown <sid>adm:sapsys <path>/<SID>-backup
[root]# chown <sid>adm:sapsys <path>/<SID>-backupCopy to Clipboard Copied! Toggle word wrap Toggle overflow Change to the
<sid>admuser for the remaining steps:su - <sid>adm
[root]# su - <sid>admCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a backup of the
SYSTEMDBas the<sid>admuser. Specify the path to the files the backups will be stored in. Ensure that the target filesystem has enough free space left, then create the backup:rh1adm $ hdbsql -i ${TINSTANCE} -u system -p '<HANA_SYSTEM_PASSWORD>' -d SYSTEMDB \ "BACKUP DATA USING FILE ('<path>/${SAPSYSTEMNAME}-backup/bkp-SYS')" 0 rows affected (overall time xx.xxx sec; server time xx.xxx sec)rh1adm $ hdbsql -i ${TINSTANCE} -u system -p '<HANA_SYSTEM_PASSWORD>' -d SYSTEMDB \ "BACKUP DATA USING FILE ('<path>/${SAPSYSTEMNAME}-backup/bkp-SYS')" 0 rows affected (overall time xx.xxx sec; server time xx.xxx sec)Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
TINSTANCEandSAPSYSTEMNAMEare environment variables that are part of the<sid>admuser shell environment.TINSTANCEis the instance number andSAPSYSTEMNAMEis the. Both are automatically set to the instance values related to the<sid>admuser. -
Replace
<path>with the path where the<sid>admuser has write access and where there is enough free space left.
-
Create a backup of all tenant databases as the
<sid>admuser. Specify the path to the files the backups will be stored in. Ensure that the target filesystem has enough free space left. Create the tenant DB backup:rh1adm $ hdbsql -i ${TINSTANCE} -u system -p '<HANA_SYSTEM_PASSWORD>' -d SYSTEMDB \ "BACKUP DATA FOR ${SAPSYSTEMNAME} USING FILE ('<path>/${SAPSYSTEMNAME}-backup/bkp-${SAPSYSTEMNAME}')" 0 rows affected (overall time xx.xxx sec; server time xx.xxx sec)rh1adm $ hdbsql -i ${TINSTANCE} -u system -p '<HANA_SYSTEM_PASSWORD>' -d SYSTEMDB \ "BACKUP DATA FOR ${SAPSYSTEMNAME} USING FILE ('<path>/${SAPSYSTEMNAME}-backup/bkp-${SAPSYSTEMNAME}')" 0 rows affected (overall time xx.xxx sec; server time xx.xxx sec)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<path>with the path where the<sid>admuser has write access and where there is enough free space left.
Verification
List the resulting backup files. Example when using
/hana/log/RH1-backupas the directory to store the initial backup:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the HANA command
hdbbackupcheckto confirm the sanity of each instance backup file you created:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Troubleshooting
The backup fails because the
<sid>admuser is not able to write to the target directory:* 447: backup could not be completed: [2001003] createDirectory(path= '/tmp/RH1-backup/', access= rwxrwxr--, recursive= true): Permission denied (rc= 13, 'Permission denied') SQLSTATE: HY000
* 447: backup could not be completed: [2001003] createDirectory(path= '/tmp/RH1-backup/', access= rwxrwxr--, recursive= true): Permission denied (rc= 13, 'Permission denied') SQLSTATE: HY000Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that the
<sid>admuser can create files inside of the target directory you define in the backup command. Fix the permissions, for example using step 2 of the procedure.The backup fails because the target filesystem runs out of space:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the free space of the filesystem on which the target directory is located. Increase the filesystem size or choose a different path with enough free space available for the backup files.
4.3. Configuring the primary HANA replication instance Copy linkLink copied to clipboard!
Enable the HANA system replication on the system which you plan to be the initial primary instance of your planned system replication setup.
Prerequisites
- You have created an initial backup for the HANA instance on the primary node based on steps described in Performing an initial HANA instance backup.
Procedure
Enable the system replication on the HANA instance that becomes the initial primary. Run the command as
<sid>admon the first, or primary, node:rh1adm $ hdbnsutil -sr_enable --name=<DC1> nameserver is active, proceeding ... successfully enabled system as system replication source site done.
rh1adm $ hdbnsutil -sr_enable --name=<DC1> nameserver is active, proceeding ... successfully enabled system as system replication source site done.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<DC1>with your primary HANA site name.
-
Replace
Verification
Check the system replication status as
<sid>adm, and verify that it shows the current node asmode: primary, and thatsite idandsite nameare populated with the primary instance site information:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Configuring the secondary HANA replication instance Copy linkLink copied to clipboard!
You must register the secondary HANA instance to the primary instance to complete the setup of the HANA system replication.
Prerequisites
-
You have installed SAP HANA on the secondary node using the same
SIDand instance number as the primary instance. -
You have configured
root ssh keysbetween the cluster nodes. -
You have opened 2 terminals on the secondary node, one for the
rootuser and one for the<sid>admuser.
Procedure
Stop the secondary HANA instance and run as the
<sid>admuser onnode2:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change to the directory where HANA stores the keys of the system replication encryption:
cd /usr/sap/<SID>/SYS/global/security/rsecssfs
[root]# cd /usr/sap/<SID>/SYS/global/security/rsecssfsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the HANA system PKI file
SSFS_<SID>.KEYfrom the primary HANA instance to the secondary instance:rsync -av node1:$PWD/key/SSFS_<SID>.KEY key/
[root]# rsync -av node1:$PWD/key/SSFS_<SID>.KEY key/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the PKI file
SSFS_<SID>.DATfrom the primary HANA instance to the secondary instance:rsync -av node1:$PWD/data/SSFS_<SID>.DAT data/
[root]# rsync -av node1:$PWD/data/SSFS_<SID>.DAT data/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Register the secondary HANA instance to the primary instance, in the
<sid>admuser terminal:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<DC2>with your secondary HANA site name. -
Choose the values for
replicationModeandoperationModeaccording to your requirements for the system replication. -
TINSTANCEis an environment variable that is set automatically for user<sid>admby reading the HANA instance profile. The variable value is the HANA instance number.
-
Replace
Start the secondary HANA instance. Run as
<sid>admonnode2:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Check that the system replication is running on the secondary instance and the
modematches the value you used for thereplicationModeparameter in thehdbnsutil -sr_registercommand in step 5. Run as<sid>admon node2:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change to the Python script directory of the HANA instance as user
<sid>adm, on both instances. The easiest way to do this is to usecdpy, which is an alias built into the<sid>admuser shell that SAP HANA populates during the instance installation:rh1adm $ cdpy
rh1adm $ cdpyCopy to Clipboard Copied! Toggle word wrap Toggle overflow In our example this command changes the current directory to
/usr/sap/RH1/HDB02/exe/python_support/.Show the current status of the established HANA system replication, on both instances.
On the primary instance the system replication status is always displayed with all details:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
ACTIVEmeans that the HANA system replication is in a healthy state and fully synced. -
SYNCINGis displayed while the system replication is being updated on the secondary site, for example after a takeover of the secondary instance to become the new primary. -
INITIALIZINGis shown after the system replication has first been enabled or a full sync has been triggered.
-
On the secondary instance, the output of
systemReplicationStatus.pyis less detailed:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.5. Testing the HANA system replication Copy linkLink copied to clipboard!
We recommend that you test the HANA system replication thoroughly before you proceed with the cluster setup. The verification of the correct system replication behavior can help to prevent unexpected results when the HA cluster manages the system replication afterwards.
Use timeout values in the cluster resource configuration that cover the measured times of the different tests to ensure that cluster resource operations do not time out prematurely.
You can also test different parameter values in the HANA configuration to optimize the performance by measuring the time that certain activities take when performed manually outside of cluster control.
Perform the tests with realistic data loads and sizes.
Full replication
- How long does the synchronization take after the newly registered secondary is started until it is in sync with the primary?
- Are there parameters which can improve the synchronization time?
Lost connection
- How long does it take after the connection was lost between the primary and the secondary instance, until they are in sync again?
- Are there parameters which can improve the reconnection and sync times?
Takeover
- How long does the secondary instance take to be fully available after a takeover from the primary?
- What is the time difference between a normal takeover and a "takeover with handshake"?
- Are there parameters which can improve the takeover time?
Data consistency
- Is the data you create available and correct after you perform a takeover?
Client reconnect
- Can the client reconnect to the new primary instance after a takeover?
- How long does it take for the client to access the new primary after a takeover?
Primary becomes secondary
- How long does it take a former primary until it is in sync again with the new primary, after it is registered as a new secondary?
- If configured, how long does it take until a client can access the newly registered secondary for read operations?