Showing posts with label data. Show all posts
Showing posts with label data. Show all posts

Thursday, 20 March 2025

why we need encrypt data volume in SAP HANA.

Encrypting the data volume in SAP HANA is crucial for ensuring the security and integrity of sensitive data. Here’s why it is needed:

1. Data Protection

Prevents unauthorized access to stored data, even if someone gains access to the physical storage.

Protects sensitive business data, such as financial records, customer information, and trade secrets.


2. Regulatory Compliance

Helps meet compliance standards like GDPR, HIPAA, PCI-DSS, and SOX, which require data encryption at rest.


3. Security Against Physical Theft

If the storage medium (disks, SSDs) is stolen or lost, encrypted data remains unreadable without the encryption keys.


4. Prevention of Data Tampering

Encryption ensures that data remains unchanged unless accessed through authorized SAP HANA mechanisms.


5. SAP Security Best Practices

SAP recommends enabling data volume encryption as part of its security guidelines to maintain a secure system landscape.


How SAP HANA Data Volume Encryption Works

Data volume encryption encrypts data pages before writing them to disk.

Uses AES-256 encryption algorithm for strong security.

The encryption keys are managed securely within SAP HANA Secure Store in the system database.


Would you like guidance on how to enable data volume encryption in SAP HANA?


To enable data volume encryption in SAP HANA, follow these steps:


---

Prerequisites

✅ You must have SYSTEM or DATABASE ADMIN privileges.
✅ SAP HANA version SPS 09 or later supports data volume encryption.
✅ Ensure that Backup Encryption is also enabled to prevent unencrypted backups.


---

Steps to Enable Data Volume Encryption

1. Check Current Encryption Status

Run the following SQL command in SAP HANA Studio or DBA Cockpit to check if encryption is already enabled:

SELECT * FROM M_ENCRYPTION_OVERVIEW WHERE NAME = 'DATA_VOLUME';

If ENCRYPTED = FALSE, encryption is not enabled.



---

2. Enable Data Volume Encryption

Run the following SQL command:

ALTER SYSTEM PERSISTENCE ENCRYPTION ON;

This command enables encryption for new and modified data pages.

Existing data remains unencrypted until rewritten (e.g., via table reload or reorganization).



---

3. Restart SAP HANA Database

Restart SAP HANA to apply changes:

SHUTDOWN IMMEDIATE;

Then, start SAP HANA again using SAP HANA Cockpit or command line.



---

4. Verify Encryption

After the restart, check the encryption status again:

SELECT * FROM M_ENCRYPTION_OVERVIEW WHERE NAME = 'DATA_VOLUME';

If ENCRYPTED = TRUE, encryption is successfully enabled.



---

Additional Steps (Optional but Recommended)

✅ Encrypt Existing Data

Since existing data is not automatically encrypted, consider the following approaches:

Reorganize Tables: Reload tables using:

ALTER TABLE <table_name> REORGANIZE;

Perform a Full Backup & Restore:

Take a backup.

Restore it to enforce encryption on all data.



✅ Enable Backup Encryption (Recommended)

Ensure backups are also encrypted to prevent data leaks:

ALTER SYSTEM BACKUP ENCRYPTION ON;


---

Key Considerations

⚠️ Performance Impact: Encryption slightly increases CPU load (~3-5%).
⚠️ Key Management: The encryption keys are securely stored in SAP HANA Secure Store.
⚠️ Recovery & Migration: Ensure you securely back up the encryption keys when migrating or recovering the database.

Would you like assistance with key management or performance tuning after enabling encryption?

Key Management & Performance Tuning for SAP HANA Encryption

After enabling data volume encryption, it's crucial to manage encryption keys securely and optimize system performance.


---

1. Key Management in SAP HANA

Where are the Encryption Keys Stored?

SAP HANA securely stores encryption keys in the Secure Store in File System (SSFS).

The key file is located at:

/usr/sap/<SID>/SYS/global/security/rsecssfs/data/SSFS_<SID>.DAT

The SSFS master key is stored in:

/usr/sap/<SID>/SYS/global/security/rsecssfs/key/SSFS_<SID>.KEY


Key Management Best Practices

✅ Backup the SSFS Key Files
Since encryption keys are needed for recovery, always back up both:

tar -cvf SSFS_Backup.tar \
/usr/sap/<SID>/SYS/global/security/rsecssfs/data/SSFS_<SID>.DAT \
/usr/sap/<SID>/SYS/global/security/rsecssfs/key/SSFS_<SID>.KEY

Store the backup securely (e.g., external encrypted storage).


✅ Rotate Encryption Keys Regularly
To rotate keys without downtime:

ALTER SYSTEM ENCRYPTION KEY RENEW;

This generates a new encryption key and updates encrypted data.


✅ Restore SSFS Keys During System Recovery
If migrating or recovering SAP HANA, restore the SSFS key files before starting the database.

cp SSFS_<SID>.DAT /usr/sap/<SID>/SYS/global/security/rsecssfs/data/
cp SSFS_<SID>.KEY /usr/sap/<SID>/SYS/global/security/rsecssfs/key/


---

2. Performance Tuning After Enabling Encryption

CPU Optimization

Since AES-256 encryption increases CPU load (~3-5%), optimize SAP HANA’s performance:

✅ Enable Hardware-Accelerated Encryption (AES-NI Support)
SAP HANA automatically detects AES-NI (Intel/AMD) for faster encryption.
To check if AES-NI is enabled:

cat /proc/cpuinfo | grep aes

If not supported, consider upgrading hardware or adjusting workload distribution.

✅ Monitor CPU Utilization
Use the following query to check CPU load:

SELECT * FROM M_LOAD_HISTORY WHERE MEASUREMENT = 'CPU';

If CPU usage is consistently high, consider scaling up hardware or adjusting parallel processing.


---

I/O Performance Optimization

✅ Enable Data Compression
Data compression reduces I/O load by minimizing storage size:

ALTER TABLE <table_name> COMPRESS FOR OLTP;

✅ Optimize Page Load Behavior
Adjust global.ini parameters for better read performance:

[persistence]
page_load_io_parallelism = 16

✅ Use Fast Storage (NVMe SSDs)
If experiencing slow write speeds, move encrypted volumes to high-speed SSDs for better performance.


---

Monitoring & Troubleshooting Encryption Performance

✅ Check Encryption Performance with System Views
To monitor encryption performance impact:

SELECT * FROM M_ENCRYPTION_STATUS;

Look for high ENCRYPTION_CPU_TIME values.


✅ Monitor Read/Write Latency

SELECT * FROM M_VOLUME_IO_TOTAL_STATISTICS;

If WRITE_TIME increases significantly, consider upgrading disk speed.



---

Final Recommendations

✔️ Regularly backup SSFS keys to avoid encryption-related recovery issues.
✔️ Monitor CPU and disk performance after enabling encryption.
✔️ Optimize storage & enable compression to balance security and performance.
✔️ Use AES-NI acceleration for faster encryption processing.

Would you like specific guidance on backup strategies, high availability, or disaster recovery with encrypted SAP HANA?
Backup Strategies, High Availability, and Disaster Recovery for Encrypted SAP HANA

Since your SAP HANA system has data volume encryption enabled, backups, failover, and disaster recovery must ensure encrypted data remains secure and recoverable.


---

1. Backup Strategies for Encrypted SAP HANA

Key Considerations

Backup Encryption: If data volume encryption is enabled, backups must also be encrypted.

SSFS Key Backup: Encryption keys are required to restore encrypted data.


Types of Backups

✅ Full Database Backup (Recommended for Encrypted Data)

Encrypts the backup automatically when data volume encryption is enabled.

Can be scheduled via SAP HANA Cockpit or run manually:

BACKUP DATA USING FILE ('/hana/backup/full_backup');

Validate backup encryption:

SELECT * FROM M_BACKUP_CATALOG WHERE ENTRY_TYPE_NAME = 'complete data backup';


✅ Incremental & Differential Backups

Incremental Backup: Saves changes since the last backup.

Differential Backup: Saves changes since the last full backup.

To create incremental backups:

BACKUP DATA INCREMENTAL USING FILE ('/hana/backup/incremental_backup');


✅ Log Backups (Continuous Protection)

Ensures minimal data loss by saving transaction logs.

Must be stored securely:

BACKUP LOG USING FILE ('/hana/backup/log_backup');

Enable automatic log backup in global.ini:

[persistence]
log_backup_interval = 900


Backup Best Practices

✔️ Backup both the encrypted data and SSFS keys.
✔️ Store backups securely in a different location (e.g., cloud storage or offsite).
✔️ Automate backups with a schedule using SAP HANA Cockpit or a script.
✔️ Test backup restoration regularly.


---

2. High Availability (HA) for Encrypted SAP HANA

High Availability Setup Options

✅ System Replication (Recommended for SAP HANA with Encryption)

SAP HANA System Replication ensures real-time failover between primary and secondary instances.

Steps to Configure System Replication with Encrypted Data

1️⃣ Enable System Replication on Primary:

hdbnsutil -sr_enable --name=PRIMARY_SITE

2️⃣ Register the Secondary System:

hdbnsutil -sr_register --name=SECONDARY_SITE --remoteHost=<primary_host> --remoteInstance=<instance_number>

3️⃣ Start Replication:

hdbnsutil -sr_start

4️⃣ Check Replication Status:

SELECT * FROM M_SERVICE_REPLICATION;

System Replication Considerations for Encrypted SAP HANA

✔️ Ensure encryption keys (SSFS) are replicated to the secondary system.
✔️ Use synchronous replication for critical data (prevents data loss).
✔️ Test failover scenarios regularly.


---

3. Disaster Recovery (DR) for Encrypted SAP HANA

Key Considerations for Disaster Recovery

Both data and encryption keys (SSFS) must be backed up and recoverable.

Use geo-redundant storage for backup retention.


Disaster Recovery Plan

✅ Step 1: Restore SAP HANA Backup in a Disaster Scenario

1. Copy backup files to the new server.


2. Restore the database:

RECOVER DATA USING FILE ('/hana/backup/full_backup');


3. Restore log backups if needed:

RECOVER LOG;



✅ Step 2: Restore SSFS Encryption Keys

1. Copy the SSFS backup to the new system:

cp SSFS_<SID>.DAT /usr/sap/<SID>/SYS/global/security/rsecssfs/data/
cp SSFS_<SID>.KEY /usr/sap/<SID>/SYS/global/security/rsecssfs/key/


2. Restart SAP HANA:

HDB start



✅ Step 3: Verify Data Integrity After Recovery

Check encryption status:

SELECT * FROM M_ENCRYPTION_STATUS;

Ensure system is running in normal mode:

SELECT * FROM SYS.M_DATABASE;



---

Final Recommendations

✔️ Always back up SSFS keys along with encrypted data backups.
✔️ Use system replication for HA to minimize downtime.
✔️ Test backup restoration and DR drills at least once per quarter.
✔️ Store backups securely in offsite/cloud storage for disaster protection.

how to recover SAP HANA database. if data volumes are encrypted. using Hana studio.

if i dont have ssfs key and data. what error i will get


Recovering an Encrypted SAP HANA Database Using SAP HANA Studio

When data volume encryption is enabled in SAP HANA, recovering the database requires both:

1. The database backup (full + log backups)


2. The SAP Secure Store in File System (SSFS) key



If the SSFS key is missing, SAP HANA cannot decrypt the data, and you will get an error.


---

1. Recovery Steps in SAP HANA Studio

Step 1: Start Recovery in SAP HANA Studio

1️⃣ Open SAP HANA Studio and connect to the system.
2️⃣ Go to Backup and Recovery → Recover System.
3️⃣ Select Recover Database from Backup.
4️⃣ Choose the latest Full Data Backup from the catalog.
5️⃣ Click Start Recovery.

Step 2: Provide SSFS Key for Encrypted Data

If the system is encrypted, SAP HANA will look for the SSFS key files in:

/usr/sap/<SID>/SYS/global/security/rsecssfs/

If the SSFS key exists, SAP HANA decrypts the data and restores the database.


✅ Verify Successful Recovery:
Run:

SELECT * FROM M_ENCRYPTION_STATUS;

If ENCRYPTED = TRUE, encryption is intact, and recovery is successful.


---

2. What Happens If the SSFS Key is Missing?

If the SSFS key is missing, SAP HANA cannot decrypt the data. You will see errors like:

Error Messages in SAP HANA Studio

1. Error: Authentication failed. Cannot open Secure Store

This happens if the SSFS key file is missing or corrupted.



2. Error: Encrypted data cannot be read. Missing encryption key.

This means SAP HANA cannot decrypt the data volumes.



3. Error: Recovery failed: Cannot read encrypted data

The backup is restored, but the system cannot decrypt the database.




📌 Command Line Error (if recovering via CLI)

hdbsql RECOVER DATA USING FILE ('/hana/backup/full_backup');

Output: Could not decrypt persisted data. Recovery failed.



---

3. How to Fix the Issue? (If SSFS Key is Missing)

✅ Option 1: Restore SSFS Key Backup

1️⃣ Copy the SSFS backup from a secure location (if available).
2️⃣ Restore it to the correct location:

cp SSFS_<SID>.DAT /usr/sap/<SID>/SYS/global/security/rsecssfs/data/
cp SSFS_<SID>.KEY /usr/sap/<SID>/SYS/global/security/rsecssfs/key/

3️⃣ Restart SAP HANA:

HDB restart

✅ Option 2: Restore Without Encryption (Only If No SSFS Backup Exists)

⚠️ Warning: This will erase encrypted data, and you will lose all encrypted records.
1️⃣ Delete the encrypted database volumes:

rm -rf /hana/data/<SID>/mnt00001/*

2️⃣ Start SAP HANA in a new, unencrypted mode:

HDB start

3️⃣ Restore a backup that was not encrypted.

🚨 If all backups are encrypted and SSFS is lost, the data is unrecoverable.


---

4. Final Recommendations

✔️ Always back up SSFS keys when performing a full backup.
✔️ Store keys securely in a separate location (e.g., external drive, cloud).
✔️ Test recovery scenarios in a non-production environment.

Would you like a script to automate SSFS key backup along with database backups?

Monday, 2 May 2022

Backup and recovery introduction

 what is persistence layer?

persistence layer is required to ensure that the HANA system can be restarted or restored back to the last consistent state in case of a power failure or abrupt shutdown or system failure.


    Database data is stored 2 places:

         1. Data volumes.
         2. Log volumes.


1.Data volume:

    It contains system data, Application data and undo logs
    it write data in Async mode.

    

2. Log volume:

Redo logs store the changes to the data (insert, update , Delete).

Synchronous writes on commit.


Savepoint: changed data and undo logs are written from memory to disk.

                     default every 5 minutes

                     Automatic execution.


to take complete backup of system, need 3 things:

  1.  Complete backup.
  2.  incremental / differential backups.
  3. Most recent log entries from the log area.






    

Thursday, 5 March 2020

Access data from file in linux scripts

instead of search for one particular word line by line in file using the below command in scripts

In manual way of running Linux command, more command is useful to search for key word.

The follow method can be used to search for a key word in file in script point of view.

  1. To grep error messages from log file.
                  grep -i error /usr/sap/sid/work/dev_disp.log
      2.To grep warming messages from log file.
                 grep -i warning /usr/sap/sid/work/dev_disp.log
      3. To grep  for fail  key word in the file.
                grep -i fail /usr/sap/sid/work/dev_disp.log


Output to file:To send output  of above cmd to one file use syntax as below:



grep  -i error /usr/sap/sid/work/dev_disp.log > /install/error.log

Saturday, 11 January 2020

How to extent sap data unit in sybase

In any database data units and log units are core places where the data of database resides. in this post  i am sharing the process of extending disk space of one data unit in Sybase.

In the below screenshots,  sapdata_1 to sap data _4 & saplog_1 to saplog_2 are available.

To extended the disk space of sapdata_4,execute the below commands:



% isql -Usapsa -SSOL -X
Password:
1> use master
2> go
1> disk resize name = "SOL_data_004",size="5G"
2> go
1> use master
2> go
1> alter database SOL on SOL_data_004 = '5G'
2> go




Note: the disk space from root is assigned to sapdata_4. 

Friday, 5 July 2019

Disk Management 3: Automatic backup of old Transports to usr/sap/trans/olddata folder.




Note : the performance of SAP system will increase by the above process. while importing the Transport request. Because of unavailability of OLD Transport request in the import buffer.







Wednesday, 15 May 2019

SAP HANA NOTES 15: Working with resource and Resource groups


  •  The Cockpit Manager, any user with the Cockpit Resource Administrator role can register resources and create groups of resources that other cockpit users will be able to access with SAP HANA cockpit.
  • Selecting Registered Resources allows you to see all the resources that have been registered, and to register more.
  • Selecting Resource Groups allows you to see all the groups that have been created, along with the resources and cockpit users that have been associated with each. Here, you can also create a new resource group, or add a resource or cockpit user to a group. 

TASK 1: Registering a resource

Add a resource so that cockpit users can monitor and manage it with SAP HANA cockpit.

  1. Your cockpit user has the assigned role Cockpit Resource Administrator or Cockpit Power User. If you use the Cockpit Power User role, you can register a resource, but you can't assign it to a resource group. 
  2. To create a technical user during registration, you have to provide the credentials of an administrator on the resource who has user creation privileges. If you don't have such credentials, ask someone who does to create a technical user for the resource before you register it. (The technical user is a dedicated database user the cockpit will use to collect health data from the resource. It's exempt from the password expiration policy. SAP recommends that you not allow human users to log in with the technical user's credentials.) 
  3. (optional) If you plan to encrypt the SAP Control or database connection, in SAP HANA XS advanced, you have:                                                                                                                                           1. Manually imported the server root certificate(s)                                                                         2. Trusted the certificate(s) using the command syntax xs trust-certificate                                          <ALIAS> -c   <CERT_FILE>                                                                                                   3. Exported the certificate(s) to the cockpit using the commands                                                          xs restage cockpit-hdb-service followed by xs restart service cockpit-hdb-                               svc
  4. If you plan to add the resource to a group during the registration process, the group must already exist.

Context

To make a resource available to cockpit users, first register the resource, then add the resource to at least one resource group, and finally assign cockpit users to the resource group. 

Procedure


  1.  Connect to the Cockpit Manager and sign in as a cockpit user with the Cockpit Resource Administrator role or the Cockpit Power User role. You can reach the Cockpit Manager by entering the Cockpit Manager URL created during cockpit installation, or by following the Manage Cockpit link in the cockpit. The URL takes this form:


              https://<cockpit-host>:<port-number>


click on HANA cockpit ADMIN for cockpit manager.


       2. In the Cockpit Manager, select Register a Resource.


       3.In the Resource section:

4. In the Connection section, choose whether to encrypt the cockpit's connections to SAP Control (for starting and stopping) and to the database.



○ If you encrypt the SAP Control connection, you are allowing a secure connection (HTTPS) to SAP Control (provided that you have met the prerequisite importing the trusted certificate(s) to the cockpit).

 ○ If you encrypt the database connection using a secure JDBC connection, choose whether to validate the certificate. This option lets you stipulate whether to verify that the remote server is trusted by the cockpit. Deselect the checkbox if the SAP HANA database has a certificate that differs from the one currently imported, or if you have not imported the certificate from the SAP HANA database into XS advanced. However, the recommendation is that you instead import a certificate for encrypted connections. 

Optionally, you can enter a hostname to override the one in the certificate. You could do this to avoid the validation failure that may result from the hostname in a certificate differing from the hostname that cockpit uses to connect, as in the case, for example, of a host alias, or a short hostname instead of a fully qualified domain name.





TASK 2 :Create a Technical User



Before registering a resource, set up a dedicated database user that SAP HANA cockpit will use to collect health data for monitoring (such as information on alerts and system performance).


Prerequisites 


You have the credentials of an administrator account on the resource that has user creation privileges


You can create a technical user when you register a resource with the cockpit if you can provide the credentials of an administrator on that resource with the ability to create user accounts. In that case, you need not follow the steps below. These steps are useful when a user with the Cockpit Power User role will be registering the resource. In that scenario, create a technical user for the resource before the power user registers it.

The technical user requires the CATALOG READ system privilege and SELECT on the _SYS_STATISTICS schema and is exempt from password expiration policies. 


Procedure

 1. Set up the technical user account on the resource to be registered: 

Use SQL to create the technical user required to register a resource through the SAP HANA cockpit and grant the minimum necessary authorizations: 


2. Give the technical user credentials to the person who will register the resource.

TASK 3: Edit resource settings,including SS0

Once a resource has been registered, you, as a cockpit resource administrator, may have reason to modify some of the original registration settings.

Prerequisites 

Your cockpit user has the assigned role Cockpit Resource Administrator.

Procedure 

1. Connect to the Cockpit Manager and sign in as a cockpit user with the Cockpit Resource Administrator role. 

You can reach the Cockpit Manager by entering the Cockpit Manager URL created during cockpit installation, or by following the Manage Cockpit link in the cockpit.  

The URL takes this form: https:<cockpit-host>:<port-number>

2. On the Cockpit Manager page, click Registered Resources. The Resources page lists all the systems known to the SAP HANA cockpit.

3. In the left pane, select the resource whose settings you want to modify.
4. Click Edit.

Note 

Before enabling SSO, consider migrating the Personal Security Environment (PSE) file to an indatabase store. When SSO is enabled, a new PSE file may be created, which may prevent cockpit access to stored certificates. See SAP Note 265666.
In the dialog box, in order to authorize this change, enter the credentials of an existing database user with the privileges: 
TRUST ADMIN
○ CERTIFICATE ADMIN 
○ USER ADMIN

5.Click Save.


TASK 4: Enable single sign on



TASK 5: Un register a resource




TASK 6: Override Data Collection for a Resource


Tuesday, 14 May 2019

SAP HANA COCKPIT NOTES 14: configuring cockpit settings,Setting Connection Timeout


Introduction:


In the Cockpit Manager, as a cockpit administrator, you can select Settings to configure data collection, proxy server settings, and the connection timeout period, and to control whether or not SAP HANA Cockpit displays auto-created groups.




TASK 1:DATA COLLECTION


As a cockpit administrator, you can reconfigure the default, pre configured SAP HANA cockpit global settings for collecting monitoring data, such as system status, alert counts, and other data from registered resources.

Navigation

In the Cockpit Manager, select Cockpit Settings, and then Data Collection.

If necessary, you can change the defaults to specify:
● How many worker threads the collection service should use. Increasing threads can improve response time but uses more memory. The default is 5 threads.
● Whether and how often the cockpit collects system status and alert counts. The default is 60 seconds.
● Whether and how often the cockpit collects key performance area monitoring data from each managed resource.The default is 5 minutes.

There may be a brief lag before your changes in values take effect.

Note: 

You can also modify the collection settings for a specific resource by editing the details of that resource. Doing so overrides the global settings for that particular resource. See Override Data Collection for a Resource.


Tip: 
  • The cockpit can support 1000s of registered resources.
 If the System Health Monitor displays ‘Not Collected’ for specific resources, you may wish to investigate the collection service log for rejected collections and reconfigure the worker threads accordingly.
Screenshots for the above scenario Task1:

step1: cockpit manager -->cockpit settings-->Data collection
Resultant screen look likes below:

Task 2:setting connection timeout



screenshot for the above timeout scenario:



Task 3: setting proxy server



screenshots for the above TASK 3: SETTING PROXY SERVER

cockpit manager--> cockpit settings--proxy                                                                                           


resultant screen:


TASK 4: Specifying Display of Auto-Generated Groups



As a cockpit administrator, you can choose whether or not SAP HANA cockpit displays resources as part of auto-created resource groups, or solely as part of resource groups that you create.

 A resource group—a named set of one or more registered resources—controls management and monitoring privileges. When you assign a cockpit user to a resource group that you have created, you enable the user to monitor and manage the group's resources through the cockpit. Each registered resource also belongs to a usage type resource group. These auto-created groups of resources (Production, Test, Development) are based on the system usage type of each resource. System usage type is configured during system installation, or later using the global.ini file with the usage parameter in the system_information section.

You can choose to hide one or more of the auto-created groups through the Cockpit Manager by selecting Settings, then Display, and deselecting or selecting each box. Opting to hide the auto-created groups does not affect the system usage type associated with the resource. It simply prevents the cockpit from organizing the display of resources by auto-created group.



screenshots for the above TASK4: scenario