时间:2021-07-01 10:21:17 帮助过:18人阅读
oracle的OEM管理器中有可视化的日志展现出,当我们手工清除archive目录下的文件后,这些记录并没有被我们从controlfile中清除掉,
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数据备份工具
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 commandRMAN retention policy is set to redundancy 1Report of obsolete backups and copiesType Key Completion Time Filename/Handle-------------------- ------ ------------------ --------------------Backup Set 125 01-NOV-04Backup Piece 125 01-NOV-04 /data1/oracle/orabak/full_1_541045804Backup 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/full_AVATAR2_20041206_173Backup Set 179 11-DEC-04Backup Piece 179 11-DEC-04 /data1/oracle/orabak/arch544588206.arc.....Backup Piece 189 17-DEC-04 /data1/oracle/orabak/arch545106606.arcBackup Set 190 17-DEC-04Backup Piece 190 17-DEC-04 /data1/oracle/orabak/arch545106665.arcBackup Set 191 20-DEC-04Backup Piece 191 20-DEC-04 /data1/oracle/orabak/arch_AVATAR2_20041220_194Archive Log 2973 20-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2985.dbfArchive 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.dbfArchive Log 2704 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2716.dbfArchive Log 2703 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2715.dbfArchive 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 commandRMAN retention policy is set to redundancy 1using 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/full_1_541045804....Archive Log 2704 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2716.dbfArchive Log 2703 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2715.dbfArchive Log 2702 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2714.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/1_2715.dbf recid=2703 stamp=545108268deleted archive logarchive log filename=/opt/oracle/oradata/avatar2/archive/1_2714.dbf recid=2702 stamp=545107659Deleted 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 在rman中用crosscheck检查归档日志,2个归档日志都是失败的:
RMAN> crosscheck archivelog all;
释放的通道: ORA_DISK_1
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=14 devtype=DISK
对归档日志的验证失败
存档日志文件名 =D:ORACLEORADATATESTARCHIVE1_47.DBF 记录 ID=1 时间戳 =572866
683
对归档日志的验证失败
存档日志文件名 =D:ORACLEORADATATESTARCHIVE11_48.DBF 记录 ID=2 时间戳 =57286
6931
已交叉检验的 2 对象
6 试着同步一下,看行不行,结果不行,crosscheck还是失败:
RMAN> resync catalog;
正在启动全部恢复目录的 resync
完成全部 resync
RMAN> crosscheck archivelog all;
释放的通道: ORA_DISK_1
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=14 devtype=DISK
对归档日志的验证失败
存档日志文件名 =D:ORACLEORADATATESTARCHIVE1_47.DBF 记录 ID=1 时间戳 =572866
683
对归档日志的验证失败
存档日志文件名 =D:ORACLEORADATATESTARCHIVE11_48.DBF 记录 ID=2 时间戳 =57286
6931
已交叉检验的 2 对象
7 用list expired看看是否有失效的archive log,证明没有失效的archive log:
RMAN> list expired archivelog all;
说明与恢复目录中的任何存档日志均不匹配
8 更改语言环境试试,结果再次crosscheck,2个archive log 都成功了:
RMAN> exit
恢复管理器完成。
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