Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle archive log deletion

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

We all know that information about every archivelog is recorded in controlfile. Of course, after we drop these physical files delete under OS, in our

The archivelog information is still recorded in controlfile, and there is a visual log in oracle's OEM manager showing that when we manually purged the files in the archive directory, these records were not erased from controlfile, that is, oracle did not know that these files no longer exist! At this time, if we want to do manual cleaning, I can try this method through experiments below:

1. Enter rman

2. Connect target /

3. Crosscheck archivelog all

4. Delete expired archivelog all

At this time, we will not be able to see it in the OEM. If you have never done this action before, we can compare the size of the controlfile after the controlfile before and after the action!

ORACLE's method of correctly deleting archives and reclaiming space

ORACLE's method of correctly deleting archives and reclaiming space

An ORACLE archive log is often full, showing that the file / oraarchive takes up 100% of the file space. Everyone must complain that ORACLE does not have an archive maintenance tool. Many people delete it directly, wrong, ORACLE has it, and it is smart to delete archives and FLASHBACK correctly. However, keep in mind that ORACLE archive logs are very important for ORACLE data recovery and backup. Do not delete archive logs unless you have to.

The process of deleting an archive log

Log in to the database server host or connect over the network as ORACLE

Enter the ORACLE data backup tool

Rman target/

Or rman target/@orcl

Execute in the command window

DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7'

Description

SYSDATA-7, indicating that the current system time is 7 days ago, and the before keyword indicates the archived logs 7 days ago. If the flashback feature is used, the flashback data will also be deleted.

By the same token, you can delete all logs from 7 days ago to the present, but this command should be carefully considered. After this deletion, it is best to make a full backup of the database immediately.

DELETE ARCHIVELOG FROM TIME 'SYSDATE-7'

The archived data of 7 days ago can also be found through FIND under UNIX/LINUX, and deleted using Exec sub-operation.

Find / oraarchive-xdev-mtime + 7-name "* .dbf"-exec rm-f {}

Doing so will still leave unmanaged archives in RMAN

You still need to execute the following two commands in RMAN

Crosscheck archivelog all

Delete expired archivelog all

So it's not as good as the above method, but the advantage of using FIND is that you can do a lot of operations on conditions and EXEC subitems to achieve more complex functions.

3. A brief introduction to report obsolete command

Report out-of-date backups using the report obsolete command

RMAN > report obsolete

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

Report of obsolete backups and copies

Type Key Completion Time Filename/Handle

--

Backup Set 125 01-NOV-04

Backup Piece 125 01-NOV-04 / data1/oracle/orabak/full_1_541045804

Backup Set 131 04-NOV-04

Backup Piece 131 04-NOV-04 / data1/oracle/orabak/full_AVATAR2_20041104_131

....

Backup Set 173 06-DEC-04

Backup Piece 173 06-DEC-04 / data1/oracle/orabak/full_AVATAR2_20041206_173

Backup Set 179 11-DEC-04

Backup Piece 179 11-DEC-04 / data1/oracle/orabak/arch644588206.arc

.

Backup Piece 189 17-DEC-04 / data1/oracle/orabak/arch645106606.arc

Backup Set 190 17-DEC-04

Backup Piece 190 17-DEC-04 / data1/oracle/orabak/arch645106665.arc

Backup Set 191 20-DEC-04

Backup Piece 191 20-DEC-04 / data1/oracle/orabak/arch_AVATAR2_20041220_194

Archive Log 2973 20-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2985.dbf

Archive Log 2971 20-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2984.dbf

.

Archive Log 2705 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2717.dbf

Archive Log 2704 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2716.dbf

Archive Log 2703 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2715.dbf

Archive Log 2702 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2714.dbf

4. Use the delete obsolete command to delete an expired backup:

RMAN > delete obsolete

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

Using channel ORA_DISK_1

Deleting the following obsolete backups and copies:

Type Key Completion Time Filename/Handle

--

Backup Set 125 01-NOV-04

Backup Piece 125 01-NOV-04 / data1/oracle/orabak/full_1_541045804

....

Archive Log 2704 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2716.dbf

Archive Log 2703 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2715.dbf

Archive Log 2702 17-DEC-04 / opt/oracle/oradata/avatar2/archive/1_2714.dbf

Do you really want to delete the above objects (enter YES or NO)? Yes

Deleted backup piece

Backup piece handle=/data1/oracle/orabak/full_AVATAR2_20041206_173 recid=173 stamp=544156241

.

Deleted archive log

Archive log filename=/opt/oracle/oradata/avatar2/archive/1_2715.dbf recid=2703 stamp=545108268

Deleted archive log

Archive log filename=/opt/oracle/oradata/avatar2/archive/1_2714.dbf recid=2702 stamp=545107659

Deleted 286 objects

RMAN > crosscheck archivelog all

Released channel: ORA_DISK_1

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: sid=19 devtype=DISK

Specification does not match any archive log in the recovery catalog

5 check the archive log with crosscheck in rman, and both archive logs fail:

RMAN > crosscheck archivelog all

Released channel: ORA_DISK_1

Assigned channel: ORA_DISK_1

Channel ORA_DISK_1: sid=14 devtype=DISK

Failed to verify the archive log

Archive log file name = D:ORACLEORADATATESTARCHIVE1_47.DBF record ID=1 timestamp = 572866

six hundred and eighty three

Failed to verify the archive log

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, see if it works, but it doesn'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

Assigned channel: ORA_DISK_1

Channel ORA_DISK_1: sid=14 devtype=DISK

Failed to verify the archive log

Archive log file name = D:ORACLEORADATATESTARCHIVE1_47.DBF record ID=1 timestamp = 572866

six hundred and eighty three

Failed to verify the archive log

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 see if there is a failed archive log, and prove that there is no invalid archive log:

RMAN > list expired archivelog all

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

8 try to change the locale, and once again, all crosscheck,2 archive log are 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, 2002, 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:ORACLEORADATATESTARCHIVE1_47.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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report