Tuesday, May 12, 2026

SAP Hana DB - Refresh / Migration / Tenant Copy Procedure...!!!

This article details the process of copying a HANA database using the tenant copy method. This approach is useful in various scenarios, such as homogeneous database migrations, database refreshes, or the creation of new systems from existing instances.

A particularly useful feature is that the destination tenant does not need to be identical to the source tenant; it can even run on a different instance number!

The underlying mechanism is similar to HANA database replication. The following prerequisites apply:

Open communication from the target system to the source system

Creation of credentials for authenticated access to the source system

Unlike HANA System Replication, no operating system-level access is required. Instead, the credentials for the SYSTEM user (or an equivalent user) are required for both the target and source HANA databases.

Configuration of Parameters in the Source System

The parameters listed below must be configured in the source system. Since these may already be set in the database, a prior verification is advisable. As no SSL communication or trust relationship existed between the source and the target in this instance, SSL was disabled.

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('multidb', 'enforce_ssl_database_replication') = 'false' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication_communication', 'enable_ssl') = 'off' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('communication', 'ssl') = 'off' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('communication', 'listeninterface') = '.global' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'logshipping_async_buffer_size') = '1073741824' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'logshipping_timeout') = '30' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('persistence', 'log_mode') = 'normal' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('inifile_checker', 'enable') = 'true' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('inifile_checker', 'replicate') = 'false' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'SYSTEM') SET ('system_replication', 'logshipping_async_buffer_size') = '10737418240' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'logshipping_async_wait_on_buffer_full') = 'false' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'logshipping_max_retention_size') = '1048576' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'enable_log_retention') = 'on' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication_communication', 'listeninterface') = '.global' WITH RECONFIGURE;

Configuration of Parameters in the Target Database:

The following commands must be executed in the target database (SystemDB):

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('multidb', 'enforce_ssl_database_replication') = 'false' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication_communication', 'enable_ssl') = 'off' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('communication', 'ssl') = 'off' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('communication', 'listeninterface') = '.global' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'logshipping_async_buffer_size') = '1073741824' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('system_replication', 'logshipping_timeout') = '30' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('persistence', 'log_mode') = 'normal' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('inifile_checker', 'enable') = 'true' WITH RECONFIGURE;

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('inifile_checker', 'replicate') = 'false' WITH RECONFIGURE;


Note: If these parameters have been newly set, a restart of the HANA database (both source and target) may be required.

Additionally, the following command can be used to verify whether installed plugins are present in the source system, as they must be identical in the target system:

SELECT * FROM M_PLUGIN_MANIFESTS;

Executing the Tenant Copy

The following steps are required to initiate the tenant copy in the target system's SystemDB (via the HANA Studio SQL Editor):

1) Stop the tenant database: ALTER SYSTEM STOP DATABASE <SID>; 
(If the target SID is identical to the source SID, the existing tenant must be deleted: DROP DATABASE <SID>;)
2) Create credentials for the source system: 
CREATE CREDENTIAL FOR COMPONENT 'DATABASE_REPLICATION' PURPOSE '<Source DB Hostname>:<Nameserver SQL Port>' TYPE 'PASSWORD' USING 'user="SYSTEM";password="<Password>"'

3) Start the copy process: 
CREATE DATABASE <SID> AS REPLICA OF <Source DB SID> AT '<Source DB Hostname>:<30001>'; # (=Instance 00)

Progress can be monitored as follows:

SELECT * FROM SYS_DATABASES.M_DATABASE_REPLICA_STATISTICS;

In the event of errors regarding authentication or an unknown replication status, the index server log files on the target system provide further insight.

Takeover and Completion of Replication.

Once the status shows "Active," the copy is ready for finalization. In the case of a migration, the application on the source system must first be shut down.

1) Finalize replication: 
ALTER DATABASE <SID> FINALIZE REPLICA;
2) Remove credentials: 
DROP CREDENTIAL FOR COMPONENT 'DATABASE_REPLICATION' PURPOSE '<Source DB Hostname>:30001' TYPE 'PASSWORD';

Upon completion, the parameters configured during the procedure can be reset to their original values. Using this method, systems have been successfully migrated between different data centers.

Note:
The ports can be reset to match the original system configuration using the command below: (If desired)

ALTER SYSTEM STOP DATABASE <SID>;
ALTER DATABASE <SID> ALTER 'indexserver' AT '<Hostname>:31040' TO '31003';
ALTER SYSTEM START DATABASE <SID>;


































No comments:

Post a Comment