How Does Oracle Delete archive log files?

Source: Internet
Author: User

The Oracle OEM manager displays visualized logs. After we manually clear the files in the archive directory, these records are not cleared from the controlfile, that is, oracle does not know that these files no longer exist! In this case, if we want to manually clear it, we can try this method after experiment:

1. Enter rman
2. connect target/
3. crosscheck archivelog all;
4. delete expired archivelog all;
At this time, we will not see it again in the OEM. If you have never done this operation, we can compare the controlfile size after the controlfile before this action!

How Does ORACLE Delete the archive and recycle the space correctly?

Backup is very important. You have no choice but to delete archived logs.
Deleting archived logs
Log on to the database server host as an ORACLE user or connect to the database server through a network
Go to ORACLE Data Backup Tool
Rman target/
Or rman target/@ orcl
Run
Delete archivelog all completed before 'sysdate-7 ';
Description
SYSDATA-7, indicating the current system time 7 days ago, the before keyword indicates the archived log 7 days ago, and if the flash back function is used, the flash back data is also deleted.
In the same way, you can delete all the logs from the past seven days to the present. However, this command should be clear. After this deletion, it is best to back up the database immediately.
Delete archivelog from time 'sysdate-7 ';

In UNIX/LINUX, you can also use FIND to FIND the archived data seven days ago and delete it using the EXEC sub-operation.

Find/oraarchive-xdev-mtime + 7-name "*. dbf"-exec rm-f {};
In this way, unmanaged archive files will still be left in RMAN.
You still need to execute the following two commands in RMAN
Crosscheck archivelog all;
Delete expired archivelog all;
So it is not as easy to use as the above method, but the advantage of using FIND is that you can perform a lot of operations on the condition and the EXEC subitem to implement more complex functions.

3. Brief introduction to the report obsolete command

Use the report obsolete command to report expired backups

RMAN> report obsolete; RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1 Report of obsolete backups and copiesType Key Completion Time Filename/Handle limit ------ too many Backup Set 125 01-NOV-04Backup Piece 125 01-NOV-04/ data1/oracle/orabak/full_0000541045804backup Set 131 04-NOV-04Backup Piece 131 04-NOV-04/data1/oracle/orabak/full_AVATAR2_20041104_131 .... backup Set 173 06-DEC-04Backup Piece 173 06-DEC-04/data1/oracle/orabak/replica Set 179 11-DEC-04Backup Piece 179 11-DEC-04/data1/oracle/orabak/arch544588206.arc ..... backup Piece 189 17-DEC-04/data1/oracle/orabak/replica Set 190 17-DEC-04Backup Piece 190 17-DEC-04/data1/oracle/orabak/replica Set 191 20-DEC-04Backup Piece 191 20-DEC-04/data1/oracle/orabak/Snapshot log 2973 20-DEC-04/opt/oracle/oradata/avatar2/archive/logs 2985.dbfarchive Log 2971 20-DEC-04/opt/oracle/oradata/avatar2/archive/logs 2984.dbf ..... archive Log 2705 17-DEC-04/opt/oracle/oradata/avatar2/archive/1_2717.dbfArchive Log 2704 17-DEC-04/opt/oracle/oradata/avatar2/archive/2716.dbfarchive Log 2703 17-DEC-04/opt/oracle/oradata /avatar2/archive/route 2715.dbfarchive Log 2702 17-DEC-04/opt/oracle/oradata/avatar2/archive/route 2714.dbf
 

4. Run the delete obsolete command to delete expired backups:

RMAN> delete obsolete; RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1 using channel ORA_DISK_1Deleting the following obsolete backups and copies: type Key Completion Time Filename/Handle -------------------- -------------------------------- Backup Set 125 01-NOV-04Backup Piece 125 01-NOV-04/data1/oracle/orabak/issue .... archive L Og 2704 17-DEC-04/opt/oracle/oradata/avatar2/archive/g02716.dbfarchive Log 2703 17-DEC-04/opt/oracle/oradata/avatar2/archive/mongolog 2702 17-DEC-04/opt/oracle/oradata/ avatar2/archive/4152714.dbfdo you really want to delete the above objects (enter YES or NO )? Yesdeleted backup piecebackup piece handle =/data1/oracle/orabak/full_AVATAR2_20041206_173 recid = 173 stamp = 544156241 ..... deleted archive logarchive log filename =/opt/oracle/oradata/avatar2/archive/export 2715.dbf recid = 2703 stamp = 545108268 deleted archive logarchive log filename =/opt/oracle/oradata/avatar2/archive /Listen 2714.dbf recid = 2702 stamp = 545107659 Deleted 286 objectsRMAN> crosscheck archivelog all; released channel: ORA_DISK_1allocated channel: ORA_DISK_1channel ORA_DISK_1: sid = 19 devtype = DISKspecification does not match any archive log in the recovery catalog
 


5. Check archive logs with crosscheck in rman. Both archive logs fail:
RMAN> crosscheck archivelog all;

Released channel: ORA_DISK_1
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 14 devtype = DISK
An error occurred while verifying the archived logs.
Archive log file name = D: oracleoradatatestarchive000047.dbf Record ID = 1 timestamp = 572866
683
An error occurred while verifying the archived logs.
Archive log file name = D: ORACLEORADATATESTARCHIVE11_48.DBF Record ID = 2 timestamp = 57286
6931
2 objects that have been cross-checked

6. Try to synchronize the data. If it doesn't work, the result won't work. crosscheck still fails:
RMAN> resync catalog;

Starting resync for all recovery Directories
Complete all resync

RMAN> crosscheck archivelog all;

Released channel: ORA_DISK_1
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 14 devtype = DISK
An error occurred while verifying the archived logs.
Archive log file name = D: oracleoradatatestarchive000047.dbf Record ID = 1 timestamp = 572866
683
An error occurred while verifying the archived logs.
Archive log file name = D: ORACLEORADATATESTARCHIVE11_48.DBF Record ID = 2 timestamp = 57286
6931
2 objects that have been cross-checked

7. Use list expired to check whether any invalid archive log exists, and verify that no invalid archive log exists:
RMAN> list expired archivelog all;

The description does not match any archived logs in the recovery directory.

8. Try changing the language environment. The result is crosscheck again. The two archive logs are all successful:
RMAN> exit


The recovery manager is complete.

C:> set nls_lang = american_america.zhs16gbk

C:> rman catalogrman/rman @ safetarget/

Recovery Manager: Release 9.2.0.1.0-Production

Copyright (c) 1995,200 2, Oracle Corporation. All rights reserved.

Connected to target database: TEST (DBID = 1870953724)
Connected to recovery catalog database

RMAN> crosscheck archivelog all;

Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 9 devtype = DISK
Validation succeeded for archived log
Archive log filename = D: oracleoradatatestarchiveapps47.dbf recid = 1 stamp = 57286
6683
Validation succeeded for archived log
Archive log filename = D: ORACLEORADATATESTARCHIVE11_48.DBF recid = 2 stamp = 5728
66931
Crosschecked 2 objects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.