Skip to content

Instantly share code, notes, and snippets.

View shaheerxt's full-sized avatar
🎯
Focusing

Shaheer shaheerxt

🎯
Focusing
View GitHub Profile
@shaheerxt
shaheerxt / audit_hana_connect_failures.sql
Last active December 22, 2021 13:53
SAP HANA Auditing
-- Please enable the auditing on database as documented in https://gist.github.com/shaheerxt/2ceda6c2d49e1fd33187428ff9da5a0b
-- Setup Policy as SYSTEM user (On the database - SYSTEMDB or TENANT DB):
CREATE AUDIT POLICY "AUDIT-USER_CONNECT_FAILURES" AUDITING UNSUCCESSFUL CONNECT LEVEL INFO;
-- Query to check if there are failures:
select *
from audit_log
where audit_policy_name = 'AUDIT-USER_CONNECT_FAILURES'
order by timestamp desc
limit 100;
-- You may want to check minutes aggregation if you have an application that often makes unsuccessful connections the database.
@shaheerxt
shaheerxt / audit_hana_user_modifications.sql
Last active December 22, 2021 13:56
SAP HANA Auditing
-- On the database, enable auditing:
ALTER SYSTEM ALTER CONFIGURATION ('nameserver.ini', 'SYSTEM')
set (
'auditing configuration',
'global_auditing_state'
) = 'true' with reconfigure;
-- All audit logs should be directed to a database table called audit log in our scenario:
ALTER SYSTEM ALTER CONFIGURATION ('nameserver.ini', 'SYSTEM')
set (
'auditing configuration',
@shaheerxt
shaheerxt / hana_hsr_setup.sh
Last active November 11, 2021 10:44
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
@shaheerxt
shaheerxt / hana_backups_schedule.sql
Created April 6, 2021 19:58
HANA backup scheduling via XS job table
-- query using below command
select * from _SYS_XS.JOB_SCHEDULES;
--Generate insert command from Studio as mentioned in above screenshot.
-- You will have to enter something like below for the FULL backup- happening every saturday 09:21 PM UTC for the database ABC
insert
into "_SYS_XS"."JOB_SCHEDULES" values(3,
'Scheduled_Backup::DataBackup',
'* * * sat 21 19 0',
'SCHEDULE-FULL-BACKUP-ABC',
--test if private gist can be moved to public
@shaheerxt
shaheerxt / 1_backupUserSetup.sql
Last active March 22, 2021 12:44
Prepare cron scheduled script for HANA backups
--sql commands
//setup user (named backupuser, for backup operations)
//login to SYSTEMDB-> SYSTEM user
create user backupuser password BackupUser1234;
alter user backupuser disable password lifetime;
grant Database backup admin,backup admin, catalog read to backupuser;
alter user backupuser activate;
--bash terminal
#setup userstore key (backupuser as user for backup operations)
@shaheerxt
shaheerxt / hanaPluginUninstall.sql
Created March 15, 2021 05:34
Uninstall SAP HANA plugin (or) component
/*
make sure you're in resident lcm directory, usually this is under installed shared path
for eg:
/hana/shared/ABC/hdblcm/
for help, execute
./hdblcm --uninstall --components --help
--components=all|<comp1>[,<comp2>]... Specifies the components (afl, client, eml, es, ets, hlm, lcapps, rdsync, rme, rtl,
sca, server, smartda, sop, streaming, studio, trp, xs and others) to be uninstalled
@shaheerxt
shaheerxt / hanaPluginVersionCheck.sql
Created March 15, 2021 05:20
check sap hana installed plugin details
hdbsql SYSTEMDB=> select plugin_name,value from m_plugin_manifests where KEY = 'fullversion';
| PLUGIN | VALUE |
| ------ | ----------------------------------- |
| AFL | 2.00.054.0000 Build 1611928859-1530 |
| EPMMDS | 1.00.202102.02.1611928859 |
2 rows selected (overall time 9207 usec; server time 2876 usec)
1. CHECK DB VERSION
select * from m_database;
2. CHECK DB SIZE
select now(), current_database() SID, to_decimal(sum(allocated_page_size/1024/1024/1024),10,0) DB_SIZE_GB from M_CONVERTER_STATISTICS;
3. CHECK FOR ORPHANED PERSISTENCE FILES
select vf.* from sys.m_table_virtual_files_ vf where vf.name like 'attribute\_%' escape '\' and vf.COLUMN_NAME='';
--SHOULD RETURN 0 ROWS
--IF ISSUES, PLEASE EXECUTE THE BELOW AS sidADM USER
@shaheerxt
shaheerxt / hanaupgradeIssue1s.sh
Created February 25, 2021 09:45
HANA Upgrade got stuck?
node1:/hana/shared/ABC # ls -alrt
total 40
drwxr-xr-x 3 root root 4096 Sep 30 11:01 ..
dr-xr-x--- 3 abcadm sapsys 4096 Sep 30 11:46 exe
drwxr-xr-x 2 abcadm sapsys 4096 Sep 30 11:49 profile
-rw-r--r-- 1 root root 226 Sep 30 11:50 ABC.hdbinstall
drwxr-x--- 5 abcadm sapsys 4096 Sep 30 11:50 global
drwxr-xr-x 7 root root 4096 Sep 30 11:53 hdblcm
drwxr-xr-x 2 abcadm sapsys 4096 Sep 30 12:17 lm_structure
drwxr-x--- 6 abcadm sapsys 4096 Oct 13 07:15 HDB00