绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
RMAN-06091分析备份脚本的存在问题
2021-11-15 09:52:35


近遇到一个问题,一个数据库的备份目录/backup满了,导致后续备份无法写入,再检查日志时发现错误
delete obsolete
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 11/10/2021 17:28:02
RMAN-06091: no channel allocated for maintenance (of an appropriate type)


我们先分析这个错误RMAN-06091说明对于备份到不同介质的备份,执行Delete obsolete操作时刻
没有分配channel.我们可以使用list backup指令查看备份是否在disk或者磁带上。然后通过如下指令解决
备份在磁盘:
RMAN> allocate channel for maintenance type disk;
备份在磁带:parms参数根据实际情况修改
allocate channel t1 device type sbt parms='SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)';
然后再执行delete obsolete操作
即如果是单独执行使用如下指令配合
RMAN> allocate channel for maintenance type disk;
RMAN> delete obsolete device type disk;

如果是run{} 执行块,需要在执行块中增加分配通道的步骤,如下是原始脚本
#!/bin/bash
source /export/home/oracle/.profile
day=`date -u +%Y%m%d`
rman target / > /backup/log/bk_level2_$day.log <<EOF
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 2 database tag='datafile_bak' format '/backup/datafile/level2_%U_%T.bkp';
sql 'alter system archive log current';
backup archivelog all tag='arch_bak' format '/backup/archivelog/arch_%U_%T.bkp' delete input;
backup current controlfile tag='bak_ctl' format ='/backup/controlfile/ctl_file_%U_%T.bkp';
backup spfile tag='spfile' format ='/backup/spfile/spfile_%U_%T.bkp';
delete noprompt expired backup;
delete noprompt obsolete device type disk;
release channel d1;
release channel d2;
}
allocate channel for maintenance device type disk;
delete noprompt obsolete redundancy 1 device type disk;
exit;
EOF

在run{}块中分配了两个通道用户备份,但是在delete操作时没有分配通道,所以run{}部分报错。这个报错
得原因就是没有channel,所以在之前脚本修改如下
delete noprompt expired backup;
allocate channel for maintenance device type disk;
delete noprompt obsolete device type disk;

如果你细心也会发现这个脚本其实还有其他问题就是delete noprompt expired backup这个操作需要crosscheck
所以我们可以如下修改
crosscheck backup;
delete noprompt expired backup;
allocate channel for maintenance device type disk;
delete noprompt obsolete device type disk;

再继续看脚本其实,我们发现再run{}后有如下删除obsolete操作
allocate channel for maintenance device type disk;
delete noprompt obsolete redundancy 1 device type disk;
所以run{}中得delete obsolete是没有必要得。
所以我们可以如下修改脚本
#!/bin/bash
source /export/home/oracle/.profile
day=`date -u +%Y%m%d`
rman target / > /backup/log/bk_level2_$day.log <<EOF
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 2 database tag='datafile_bak' format '/backup/datafile/level2_%U_%T.bkp';
sql 'alter system archive log current';
backup archivelog all tag='arch_bak' format '/backup/archivelog/arch_%U_%T.bkp' delete input;
backup current controlfile tag='bak_ctl' format ='/backup/controlfile/ctl_file_%U_%T.bkp';
backup spfile tag='spfile' format ='/backup/spfile/spfile_%U_%T.bkp';
crosscheck backupset;
delete noprompt expired backup;
release channel d1;
release channel d2;
}
allocate channel for maintenance device type disk;
delete noprompt obsolete redundancy 1 device type disk;
exit;
EOF

再次执行脚本,没有之前的609错误。

分享好友

分享这个小栈给你的朋友们,一起进步吧。

Oracle运维新鲜事-技术与管理各占半边天
创建时间:2020-08-04 11:34:57
本技术栈旨在分享技术心得,运维趣事,故障处理经验,调优案例,故障处理涉及集群,DG,OGG,大家生产中遇到的问题基本都会囊括了,我会发布生产库遇到的故障,希望在交流中互助互益,共同提高,也希望大家讨论,如果您有生产中遇到的集群问题,也可以在这里提出来,一起讨论,现实中也帮助不少同学解决了生产库的故障。
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

栈主、嘉宾

查看更多
  • Abraham林老师
    栈主
  • 小雨滴
    嘉宾
  • hawkliu
    嘉宾
  • u_97a59a25246404
    嘉宾

小栈成员

查看更多
  • 栈栈
  • dapan
  • 小菜鸟___
  • hwayw
戳我,来吐槽~