当前位置:Gxlcms > mysql > Oracle归档日志的清楚

Oracle归档日志的清楚

时间:2021-07-01 10:21:17 帮助过:38人阅读

我们都都知道在controlfile中记录着每一个archivelog的相关信息,当然们在OS下把这些物理文件delete掉后,在我们的controlfile中

我们都都知道在controlfile中记录着每一个archivelog的相关信息,,当然们在OS下把这些物理文件delete掉后,在我们的

controlfile中仍然记录着这些archivelog的信息,在Oracle的OEM管理器中有可视化的日志展现出,当我们手工清除archive目录下的文件后,这些记录并没有被我们从controlfile中清除掉,也就是oracle并不知道这些文件已经不存在了!这时候我们要做手工的清除的话,下面我经过实验,可以尝试这种方法:

1. 进入rman

2. connect target /

3. crosscheck archivelog all;

4. delete expired archivelog all;

这时候我们再去OEM中看就一定看不到,如果你的从来没有做过这个动作的话,我们可以比较从这个动作前的controlfile后动作后的controlfile的大小!

ORACLE正确删除归档并回收空间的方法

ORACLE正确删除归档并回收空间的方法

一个ORACLE归档日志经常满,表现为/oraarchive 这个文件空间占用100%大家一定抱怨ORACLE为何没有归档维护工具,很多人直接删除了事,错了,ORACLE有,而且很智能,可以正确的删除归档和FLASHBACK,不过切记,ORACLE归档日志对于ORACLE的数据恢复和备份非常重要,不到万不得已不要删除归档日志。

删除归档日志的过程

以ORACLE用户身份登录到数据库服务器主机或通过网络连接

进入ORACLE数据备份工具

rman target/

或rman target/@orcl

在命令窗口里面执行

DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';

说明

SYSDATA-7,表明当前的系统时间7天前,before关键字表示在7天前的归档日志,如果使用了闪回功能,也会删除闪回的数据。

同样道理,也可以删除从7天前到现在的全部日志,不过这个命令要考虑清楚,做完这个删除,最好马上进行全备份数据库

DELETE ARCHIVELOG FROM TIME 'SYSDATE-7';

UNIX/LINUX下也可以通过FIND找到7天前的归档数据,使用EXEC子操作删除

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

这样做仍然会在RMAN里留下未管理的归档文件

仍需要在RMAN里执行下面2条命令

crosscheck archivelog all;

delete expired archivelog all;

所以还不如上面的方法好用,不过用FIND的好处就是,可以在条件上,和EXEC子项上做很多操作,实现更复杂的功能

3.简要介绍一下report obsolete命令

使用report obsolete命令报告过期备份

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/arch544588206.arc

.....

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

Backup Set 190 17-DEC-04

Backup Piece 190 17-DEC-04 /data1/oracle/orabak/arch545106665.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.使用delete obsolete命令删除过期备份:

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

linux

人气教程排行