Document Type | Technical Information
Category | Administration
Applicable Product Version | 7FS02PS
Document Number | TADTI110
Overview
This is a script that deletes archive logs stored in TAS or filesystem using tbrmgr, removing archive logs older than the retention period.
Method
Script
$ vi delete_archivelog.sh
#!/bin/sh
USERNAME=sys
PASSWORD=tibero
TB_SID=t724
INTERVAL_DAY=14
LOG_DIR=/home/tibero/
LOG_NAME=archive_delete_`date "+%Y%m%d"`.log
export TB_HOME=/home/tibero/tibero7
export PATH=$TB_HOME/bin:$TB_HOME/client/bin:$PATH
export LD_LIBRARY_PATH=$TB_HOME/lib:$TB_HOME/client/lib:$LD_LIBRARY_PATH
export TB_SID=${TB_SID}
BEFORETIME=`date -d "-${INTERVAL_DAY} days" +%Y%m%d%H%M%S`
mkdir -p $LOG_DIR
echo 'begin delete archivelogs.' > $LOG_DIR/$LOG_NAME
echo >> $LOG_DIR/$LOG_NAME
echo 'running command : tbrmgr delete --userid '${USERNAME}'/'${PASSWORD}'@'${TB_SID}' --cf-only --archivelog --beforetime '${BEFORETIME}'' >> $LOG_DIR/$LOG_NAME
tbrmgr delete --userid ${USERNAME}/${PASSWORD}@${TB_SID} --cf-only --archivelog --beforetime ${BEFORETIME} >> $LOG_DIR/$LOG_NAME
echo >> $LOG_DIR/$LOG_NAME
echo 'running command : tbrmgr delete --userid '${USERNAME}'/'${PASSWORD}'@'${TB_SID}' --archivelog --beforetime '${BEFORETIME}'' >> $LOG_DIR/$LOG_NAME
tbrmgr delete --userid ${USERNAME}/${PASSWORD}@${TB_SID} --archivelog --beforetime ${BEFORETIME} >> $LOG_DIR/$LOG_NAME
echo >> $LOG_DIR/$LOG_NAME
echo 'end delete archivelogs.' >> $LOG_DIR/$LOG_NAME
$ sh delete_archivelog.sh Note
- When deleting archive logs with tbrmgr, the list of archive logs matching the condition is checked in v$archived_log stored in the controlfile.
- If archive logs are deleted using the OS rm command, changes are not reflected in the controlfile, causing tbrmgr to find archive logs already deleted by the rm command and resulting in a (-1138) error during archive log deletion.
- To resolve this, use the --cf-only option of tbrmgr to delete information about archive logs deleted by the rm command from the controlfile, preventing the (-1138) error when deleting archive logs with tbrmgr.
- The --cf-only option of tbrmgr deletes information only from the controlfile without physically deleting files.
- Since archive log sequences above 256 may not be cleaned up in the controlfile even when using the --cf-only option, apply patch 344835b or later.
CautionApply patches through technical support provided by Tmax Tibero.