[Notes] Oracle 10g 刪除 Archive log

2011/10/04 張貼者: Damon.Huang

Check "Flash Recovery Area" parameters

[oracle@example ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Oct 4 13:54:37 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
SQL> conn / as sysdba;
Connected.

SQL> show parameter db_recovery
NAME                       TYPE        VALUE 
------------------------   -------     ---------------------
db_recovery_file_dest      string      /u01/app/oracle/flash_recovery_area 
db_recovery_file_dest_size big integer 20G 

Delete archive log

備份後刪除:
[oracle@ksfm2 ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Oct 4 14:21:52 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: KCLV (DBID=3445048213)
RMAN> CROSSCHECK ARCHIVELOG ALL; 
....
....
RMAN> BACKUP ARCHIVELOG ALL DELETE ALL INPUT;
直接刪除不備份
RMAN> delete force noprompt archivelog until time 'sysdate - 7';
RMAN> exit;

Shell Scripts 清除範例,可以排在 Cron job

(1) clearArchivelogs.sh
#!/bin/bash
export ORACLE_BASE=/u01/app/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=ORCL
export RMAN_CMDFILE=RMAN_CMDFILE

$ORACLE_HOME/bin/rman target=/ cmdfile=$RMAN_CMDFILE

# Cleaning Empty Folder
find /u01/app/oracle/flash_recovery_area/ORCL/archivelog -type d -empty -exec rm -rf {} \;
 
(2) RMAN_CMDFILE
delete force archivelog until time 'sysdate - 7';
exit;

Reference:

標籤:

張貼留言

技術提供:Blogger.