案例分析:
问题描述:监控短信通知一oracle服务器磁盘空间告警,登录主机后确认为备份目录使用率过高,此目录只做rman备份,且rman保留策略为1份,正常不可能磁盘空间告警,查看rman备份脚本,备份存储在本地磁盘,其中脚本中删除过期备份策略没有问题,如下: report obsolete;
crosscheck archivelog all; crosscheck backup; crosscheck copy; delete noprompt expired backup; delete noprompt expired copy; delete noprompt obsolete;
手工执行删除过期备份命令,出现如下报错(且从备份日志中也看到每次执行此步骤都报错,所以过期备份一直没有删除,导致了磁盘空间紧张): RMAN> delete obsolete; --报错RMAN-06091:备份通道不匹配 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of delete command at 05/07/2008 22:04:21 RMAN-06091: no channel allocated for maintenance (of an appropriate type)
这个命令没有问题,为何会执行失败呢,列出备份信息,发现有SBT类型的备份,突然想起此oracle服务器近期通过rman整库迁移方式搬迁的,而老库是使用的NBU备份到磁带库,则老库的备份信息保留在控制文件中,而新库的控制文件在搬迁过程中使用的是老库的,这些存储在控制文件中的老库中的备份,在检查时被发现,没有分配合适的通道,无法删除。所以执行命令报错了,所以现在问题就是怎样去把控制文件中的那些到磁带的备份信息删掉。 RMAN> list backup summary; List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- --------------- ------- ------- ---------- --- 41333 B 0 A SBT_TAPE 15-FEB-17 1 1 NO HOT_DB_BK_LEVEL0 41340 B 0 A SBT_TAPE 15-FEB-17 1 1 NO HOT_DB_BK_LEVEL0 ............. 41372 B A A SBT_TAPE 16-FEB-17 1 1 NO TAG20170216T000929 41386 B F A SBT_TAPE 20-FEB-17 1 1 NO TAG20170220T001015 .............
生产为上,先强制删除类型为disk的过期备份释放空间吧。 RMAN> delete force noprompt obsolete device type disk;
再想办法磁带的备份信息删掉,但问题关键是现在已经没有磁带备份设备了,则无法为其分配磁带通道,怎样去分配一个到磁带的渠道,幸运的是看到了一个类似的案例 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.
于是执行如下,过期与废弃的SBT类型的备份都被删除了: 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 backup; RMAN> release channel ;
再查看备份集信息,发现居然还有SBT类型的备份,这是怎么回事?继续执行看看什么情况: RMAN> list backup summary; RMAN> allocate channel for maintenance device type sbt parms 'SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)'; allocated channel: ORA_MAINT_SBT_TAPE_2 channel ORA_MAINT_SBT_TAPE_2: SID=1281 instance=notedb2 device type=SBT_TAPE channel ORA_MAINT_SBT_TAPE_2: WARNING: Oracle Test Disk API 注:如果曾经使用过SBT,现在没有磁带备份设备,而且rman也无法连接到磁带通道,oracle给出上述测试API。
RMAN> delete backup; List of Backup Pieces BP Key BS Key Pc# Cp# Status Device Type Piece Name ------- ------- --- --- ----------- ----------- ---------- 41333 41333 1 1 AVAILABLE SBT_TAPE bk_41368_1_935977151 41334 41334 1 1 AVAILABLE SBT_TAPE bk_41367_1_935977150 41372 41372 1 1 AVAILABLE SBT_TAPE al_41407_1_936058169 41385 41385 1 1 AVAILABLE SBT_TAPE al_41418_1_936403779 41386 41386 1 1 AVAILABLE SBT_TAPE cntrl_41420_1_936403815 Do you really want to delete the above objects (enter YES or NO)? yes RMAN-06207: WARNING: 18 objects could not be deleted for SBT_TAPE channel(s) due RMAN-06208: to mismatched status. Use CROSSCHECK command to fix status
RMAN> crosscheck backup; RMAN> delete noprompt expired backup; RMAN> list backup summary; 从上述可看到,未删除的SBT备份是因其SBT_TAPE 不匹配状态,需执行CROSSCHECK检查备份的有效性,严重警告:生产库上直接delete backup操作是不允许的,因当前操作做了稳妥的备案,所以执行此命令查看状态,最终发现了问题并解决。
转载:https://www.cnblogs.com/zfox2017/p/6610388.html