The following tips will provides you a new knowledge about how to do an automated housekeeping job for your HANA server. These tips will be very useful for clean up your database logs, traces, alerts, internal events, etc.
Please follow these steps:
- Create Database Role and Database User to perform housekeeping
- Open terminal in Linux (or use Putty from Windows), and connect to HANA Linux Server using root. Execute commands below:
- Back to terminal, using root, change directory to / , and execute command below:
Then, type in the following:Adjust the directory to your own HANA System directory for trace files, and save this file using command :wq!
- Create directory hanacleaner_history on directory /usr/sap and change its ownership into ndbadm:sapsys using command below:
chown ndbadm:sapsys hanacleaner_history
- Download files from link : HERE
In those downloaded zip file, copy hanacleaner.py file to HANA Linux Server in directory:
/usr/sap/NDB/HDB00/exe/python_supportChange hanacleaner.py ownership to ndbadm:sapsys
Edit hanacleaner.py file, check parameters in lines 918, 921, and 964:Line 918 : zipBackupPath = cdalias(‘cdtrace’)Line 921 : dbuserkeys = [“HANACLEANER1KEY”] à Key stored in hdbuserstore in step 2 above.Line 964 : ignore_filesystems = “” –> Fill this “” using fullpath of filesystems that are 100% used (such as iso mounted filesystems)
Save this file after you finished.
- Copy hanacleaner.sh from downloaded file (step 5 above) to HANA Linux server in any directory, such as /home/Schedule_Script/ and change its ownership to ndbadm:sapsys , and change this file into executable file using command chmod 777 hanacleaner.sh
Edit this file, and adjust its parameter to your own policy.
To learn more about this parameter, please check file hanacleaner.pdf in downloaded file (step 5 above).
- Edit crontab for user ndbadm, in directory /etc using command crontab -u ndbadm -e
Insert this line into crontab for example:
0 6 * * * /home/Schedule_Script/hanacleaner.sh
This schedule will run using ndbadm as executor, every 6 AM in the morning, file hanacleaner.sh will be executed.
To execute hanacleaner.sh manually, you must change user into ndbadm using command su ndbadm and execute hanacleaner.sh using command ./hanacleaner.sh, and it will write an output file in /usr/sap/hanacleaner_history/ directory each time it’s executed.