SAP HANA cleanup tasks like purging the backup catalog or deleting old trace files need to be implemented individually.SAP created a Python script which called as HANACLEANER.PY to perform these tasks automatically.
Installation “hanacleaner.py”
We can install SAP HANACleaner in the following way:
- Download the attached script hanacleaner.py from SNOTE 2399996
2399996 – How-To: Configuring automatic SAP HANA Cleanup with SAP HANACleaner
- Copy to HANA database server.
It’s better to copy this script to below location ;
/usr/sap/SID/HDB00/exe/python_support
Usage of “hanacleaner.py”
To check all the available configuration options ;
python hanacleaner.py — help
Example usage of the hanacleaner.py ;
- No execution of actions (“hanacleaner needs input arguments”).
python hanacleaner.py
- Clean up backup catalog entries and backups that are older than 30 days and that don’t be long to the ten newest backups.
python hanacleaner.py -be 10 -bd 30 -td true
- Clean up statistics server alerts, traces and backup catalog entries older than 42 days, rename and compress backup.log and backint.log when size exceeds 50 MB, handle / acknowledge events after 2 / 42 days
python hanacleaner.py -tc 42 -tf 42 -ar 42 -bd 42 -zb 50 -eh 2 -eu 42
Configure “hanacleaner.py” as a script with crontab entries ;
- First we need to create a user to execute this script ;
We can create the user as HANACLEANER via HANA Administration Concole
We need to add below authorizations to user HANACLEANER
- Now we continue with “hdbuserstore” steps ;
We need to create a KEY via following syntax.
hdbuserstore SET SYSTEMKEY <servername>:<port> <username> <password>
- Let’s make a connection test ;
python hanacleaner.py -k SYSTEMKEY -be 20
- Create “hanacleaner.sh” script with hanacelaner.py options.
Example script content ;
#!/bin/bash
source $HOME/.bashrc
python /usr/sap/<SID>/HDB00/exe/python_support/hanacleaner.py -fl 25 -fo true -tc 30 -tf 40 -td true -to true -es true -os false -ar 30 -ad true -bd 60 -zb 40 -lr 3 -eh 10 -eu 10 -lr 3 -fo true -or 25 -op /usr/sap/<SID>/HDB00/<SERVERNAME>/trace
- Configure crontab entries for <SID>adm user for every night at 1 c’clock
crontab -e -u <SID>adm
0 1 * * * /tmp/HANACLEANER/hanacleaner.sh >> /tmp/HANACLEANER/hanacleaner.log 2>&1
Check the Output;
Hello,
When i schedule hana cleaner through crontab, it fails with the error :
/bin/sh : hdbuserstore : command not found.
However, when i run the hanacleaner script manually, it works fine.
Can you please suggest if any special config is required for cronjob scheduling ?
Thanks,
Sahil.
Hello Sahil,
Is it possible to change “sh” shell to “bash” shell
Best Regards.