ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

How to delete expired or obsolete archvielog files.

2021-04-08 09:34:51  阅读:242  来源: 互联网

标签:files log defaultCONFIGURE obsolete How archivelog RMAN expired delete


How to delete expired or obsolete archvielog files.

  RMAN provided two commands for deleting archive log.

1.delete expired archivelog
2.backup archivelog all delete input

These command can delete archive logs based on the input provided. There were two things that RMAN made sure every time it attempted to delete an archive log. The first is that specified archive log is backed up to all the locations specified under log_archived_dest_n parameters. The value under these parameters can be flash recovery area or non flash recovery area. Second is whether the archive logs to be deleted are obsolete or not. This in turn depends on your backup retention policy. An archive redo log is considered obsolete if it is not required in any recovery scenario.
Using RMAN we can remove the old archvielogs or old backup file using report obsolete or delete obsolete by setting rman rman retention policy
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name DEV are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\APP\USER\PRODUCT\12.1.0\DBHOME_1\DATA
BASE\SNCFDEV.ORA'; # default
RMAN>
Above Configuration show  RMAN  retention policy is 1, based on this retention policy only report obsolete or delete obsolete will work. Manually we can remove the expired archivelog using below 2 options:

1.delete .. expired archivelog;
2.backup archivelog all delete input;

1. delete .. expired archivelog;

By using this command we can remove the old archivelog manually.

Using OS command remove the old archivelog files from the archivelog log location.
Move to archivelog location then issue (to find the achivelog location , connect sqlplus / as sysdba )
execute below command to find the archive log.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     46
Next log sequence to archive   48
Current log sequence           48
SQL> 
Archvielog location using Flash revoerey area,

SQL> show parameter recover
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      E:\app\user\fast_recovery_area
db_recovery_file_dest_size           big integer 6930M
db_unrecoverable_scn_tracking        boolean     TRUE
recovery_parallelism                 integer     0
SQL>

ARchivelog location is "E:\app\user\fast_recovery_area\dev\ARCHIVELOG".
move to this location and issue command below with 2 options.
Recommended options is move the old archivelog file to some other directory wait for 2 days then remove that files. or directly reomove like below
rm -rf  *.arc or
rm -rf  (specified archivelog files)

Then issue the command connecting RMAN.

C:\Users\user>rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Oct 11 17:19:15 2017
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.
connected to target database: DEV (DBID=4027486540)
RMAN>
RMAN> list expired archivelog all;
using target database control file instead of recovery catalog
specification does not match any archived log in the repository
RMAN>
Before crosscheck its shows like this.
RMAN> crosscheck archivelog all;

It will crosscheck the archivelog files with RMAN repository deleted files status changed to expired in RMAN repository.

RMAN> list expired archivelog all;
List of Archived Log Copies for database with db_unique_name DEV
=====================================================================
Key     Thrd Seq     S Low Time
------- ---- ------- - ---------
39      1    48      X 11-OCT-17
        Name: E:\APP\USER\FAST_RECOVERY_AREA\DEV\ARCHIVELOG\2017_10_11\O1_MF_1_
8_DXW2ZZFW_.ARC
RMAN>

Then issue below command to remove from the RMAN repository.

RMAN> delete expired archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=129 device type=DISK
List of Archived Log Copies for database with db_unique_name DEV
=====================================================================
Key     Thrd Seq     S Low Time
------- ---- ------- - ---------
39      1    48      X 11-OCT-17
        Name: E:\APP\USER\FAST_RECOVERY_AREA\DEV\ARCHIVELOG\2017_10_11\O1_MF_1_4
8_DXW2ZZFW_.ARC
Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=E:\APP\USER\FAST_RECOVERY_AREA\DEV\ARCHIVELOG\2017_10_11\
O1_MF_1_48_DXW2ZZFW_.ARC RECID=39 STAMP=957116888
Deleted 1 EXPIRED objects
RMAN>
RMAN> delete noprompt expired archivelog all;

this command will remove the files without prompting the Yes or no.

2.Backup archivelog all delete input:

Above command will remove the all archivelog file after taking the backup of all archvielog available in current RMAN repository.

We have options also

It will take backup 2 days before archivelog file and then remove it.
RMAN> backup archivelog until time 'sysdate-2' delete input;

Crosscheck commands:

To crosscheck all backups use:
RMAN> CROSSCHECK BACKUP;

To list any expired backups detected by the CROSSCHECK command use:
RMAN> LIST EXPIRED BACKUP;

To delete any expired backups detected by the CROSSCHECK command use:
RMAN> DELETE EXPIRED BACKUP;

To crosscheck all archive logs use:
RMAN> CROSSCHECK ARCHIVELOG ALL;

To list all expired archive logs detected by the CROSSCHECK command use:
RMAN> LIST EXPIRED ARCHIVELOG ALL;

To delete all expired archive logs detected by the CROSSCHECK command use:
RMAN> DELETE EXPIRED ARCHIVELOG ALL;

To crosscheck all datafile image copies use:
RMAN> CROSSCHECK DATAFILECOPY ALL;

To list expired datafile copies use:
RMAN> LIST EXPIRED DATAFILECOPY ALL;

To delete expired datafile copies use:
RMAN> DELETE EXPIRED DATAFILECOPY ALL;

To crosscheck all backups of the USERS tablespace use:
RMAN> CROSSCHECK BACKUP OF TABLESPACE USERS;

To list expired backups of the USERS tablespace:
RMAN> LIST EXPIRED BACKUP OF TABLESPACE USERS;

To delete expired backups of the USERS tablespace:
RMAN> DELETE EXPIRED BACKUP OF TABLESPACE USERS;

标签:files,log,defaultCONFIGURE,obsolete,How,archivelog,RMAN,expired,delete
来源: https://www.cnblogs.com/yaoyangding/p/14630660.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有