导航

如何删除控制文件中过去rman备份到磁带的备份集

Posted on 2015-10-09 09:51  datalife  阅读(501)  评论(0编辑  收藏  举报

问题描述:

早上做数据库巡检,发现FRA(flash recovery area)空间使用率达到66%,是平时的两倍。由于库不大,备份策略是本地磁盘备份,
每天一全备,REDUNDANCY 1 ,备份完成后delete obsolete ,EXPIRED 的备份集。也就是说只保留了一个最新的备份,且大小为33%左右。

问题排查:
检查备份日志,发现存在如下错误:
RMAN>  delete noprompt obsolete; 
......
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 02/10/2014 14:00:50
RMAN-06091: no channel allocated for maintenance (of an appropriate type)

rman 下list backup of database 发现有几个备份到磁带的备份集。
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4943 838M SBT_TAPE 00:00:35 02/10/2014 
BP Key: 4943 Status: UNAVAILABLE Tag: TAG20100411T004252
Piece Name: arch_20100411_4970_1
List of Archived Logs in backup set 4943
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 16014 4006475789091 10-APR-10 4006475846928 10-APR-10
1 16015 4006475846928 10-APR-10 4006475885650 10-APR-10
1 16016 4006475885650 10-APR-10 4006475943776 10-APR-10
1 16017 4006475943776 10-APR-10 4006475979118 10-APR-10
1 16018 4006475979118 10-APR-10 4006476023785 10-APR-10
1 16019 4006476023785 10-APR-10 4006476071180 10-APR-10
1 16020 4006476071180 10-APR-10 4006476158466 10-APR-10
1 16021 4006476158466 10-APR-10 4006476250848 10-APR-10
1 16022 4006476250848 10-APR-10 4006525513941 11-APR-10
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4948 517M SBT_TAPE 00:00:29 02/10/2014 
BP Key: 4948 Status: AVAILABLE Tag: TAG20100412T002657
Piece Name: arch_20100412_4976_1
List of Archived Logs in backup set 4948
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 16030 4006527200207 11-APR-10 4006527247642 11-APR-10
1 16031 4006527247642 11-APR-10 4006527316362 11-APR-10
1 16032 4006527316362 11-APR-10 4006527374966 11-APR-10
1 16033 4006527374966 11-APR-10 4006527472280 11-APR-10
1 16034 4006527472280 11-APR-10 4006528044006 11-APR-10
1 16035 4006528044006 11-APR-10 4006576257046 02/10/2014
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
且前一天备份的那个backupset也没有被删掉。

所以,至此问题清楚了,FRA使用率高是因为多了一个前一天的backupset 。

问题是,为什么命令块里面明明有
 report obsolete;
CROSSCHECK BACKUP;
CROSSCHECK COPY;
DELETE noprompt EXPIRED BACKUP;
DELETE noprompt EXPIRED COPY;
delete noprompt obsolete;
这些命令,为什么没有把那个已经过期的备份集删掉呢?
于是,rman单独执行     
RMAN>  delete noprompt obsolete;                                         
......                                                                   
using channel ORA_DISK_1                                                 
RMAN-00571: ===========================================================  
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============  
RMAN-00571: ===========================================================  
RMAN-03002: failure of delete command at 02/10/2014 14:00:50             
RMAN-06091: no channel allocated for maintenance (of an appropriate type)
同样不能删除。  

这时候才反映过来,备份集删不掉应该是与控制文件中Device Type  为 SBT_TAPE 的东西有关。
这才想起年前放假前测试过一款备份软件,备份集已经没了,但是备份信息依然存在于控制文件中,正因为rman试图去删除
这些backup set 的时候发现 没有分配合适的通道,无法删除,所以导致FRA上expired 的backupset 也无法被成功删除。

所以现在问题就是怎样去把控制文件中的那些到磁带的备份信息删掉。

rman target /
                                                                            
RMAN> show channel ;                                                        
                                                                            
using target database control file instead of recovery catalog              
RMAN configuration parameters for database with db_unique_name FINAPRIM are:
RMAN configuration has no stored or default parameters   

没有已分配的渠道。                     

然后问题的关键是,现在已经没有磁带备份设备了,怎样去分配一个到磁带的渠道,幸运的是看到了一个兄弟类似的案例,
有这么一段:                                                                                                                                                             
Suppose your current backup strategy uses only disk, but you have several old tape       
backups you want to get rid of. You can allocate a maintenance channel for performing the
deletion of the tape backups by using the dummy sbt API (because the media manager isn’t
available any longer). You can then use the delete obsolete command to remove the tape   
backups. Here’s an example showing how to do those things:                              
                                                                                         
RMAN> allocate channel for maintenance device type sbt                                   
parms 'SBT_LIBRARY=oracle.disksbt,                                                       
ENV=(BACKUP_DIR=/tmp)';                                                                  
RMAN> delete obsolete;                                                                   
                                                                                         
Although the media manager isn’t available any longer, RMAN simulates a callout to the  
media management layer (MML) and successfully initiates the maintenance command to       
delete the old tape backups you want toget rid of.         

哈哈,看起来太合适我了。  
RMAN> allocate channel for maintenance device type sbt parms 'SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)';
RMAN> delete noprompt obsolete;  
RMAN> DELETE noprompt EXPIRED  ;
RMAN> release channel ;
                           
然后 然后就大功告成了,很顺利的就删掉了。

再然后,测试了一下备份,没有任何问题,该渠道并不会影响当前的备份策略。

本文转自:http://blog.csdn.net/hj402555749/article/details/19041221