Chinaunix首页 | 论坛 | 博客
  • 博客访问: 349800
  • 博文数量: 50
  • 博客积分: 309
  • 博客等级: 二等列兵
  • 技术积分: 503
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-09 20:16
文章分类

全部博文(50)

文章存档

2018年(2)

2015年(1)

2014年(21)

2013年(24)

2012年(1)

2010年(1)

分类: Oracle

2014-06-22 10:20:01

今天在公司的数据库上看到这样的一个RMAN备份脚本:

run {
 allocate channel c1 type disk maxpiecesize = 2G;
 allocate channel c2 type disk maxpiecesize = 2G;
 backup incremental level 1 database format '/backup/osedb_osedb01/data/%d_DF_%T_%s_%p.bak'
 plus archivelog  format '/backup/osedb_osedb01/arch/%d_AF_%T_%s_%p.log' all delete all input;
 release channel c1;
 release channel c2;
}

注意上面红色字体部分。我一看,感觉好像有些问题,于是在测试机上做了一下试验,发现果然是有错误的。下面进行详细说明。

1. 首先,上面的脚本是错误的,应该将上面红色字体的第一个"all"去掉即可。

2. delete input和delete all input的区别

(1)如果归档日志目录只是一个时,即归档时只有一份归档日志时,上面的两种写法是没有区别的;

(2)如果归档日志目录有多个时,即归档时保存有多份归档日志时,那么:

delete input当备份了归档日志后,会删除第一个归档目录(如:log_archive_dest_1)下的所有归档日志;

delete all input则在备份了归档日志后,所有所有log_archive_dest_n中的备份的archivelog都会被删除。

3. 那么,至于什么时候可以使用all delete input或all delete all input呢?

在1,2小点中提到的写法都是在备份数据库时顺便备份归档日志的写法,如:

backup database plus archivelog delete all input;

而使用all delete all input是直接专门对数据库归档日志进行备份时使用,如:

backup archivelog all delete all input;

 

附加:

当在备份归档日志时,如果有些归档日志被删除了或是丢失了,那么在备份过程就就会报错RMAN-06059:

假如现数据库有如下的归档日志:

RMAN> list archivelog all;

List of Archived Log Copies

Key    Thrd Seq  S    Low Time   Name

-------  ----  -------  -      ---------         -------------

59       1      35      A   16-MAY-11  /u01/backup/arch1/1_35_750725106.dbf

60       1      35      A   16-MAY-11  /u01/backup/arch2/1_35_750725106.dbf

61       1      36      A   16-MAY-11  /u01/backup/arch1/1_36_750725106.dbf

62       1      36      A   16-MAY-11  /u01/backup/arch2/1_36_750725106.dbf

现在手工在操作系统下用rm命令将36号归档日志文档删除,模拟36号归档日志丢失了,那么在执行备份归档日志时将出现:

RMAN> backup tablespace app plus archivelog delete all input;

Starting backup at 16-MAY-11

current log archived

using channel ORA_DISK_1

archived log /u01/backup/arch1/1_36_750725106.dbf not found or out of sync with catalog

trying alternate file for archivelog thread 1, sequence 36

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of backup plus archivelog command at 05/16/2011 03:22:29

RMAN-06059: expected archived log not found, lost of archived log compromises recoverability

ORA-19625: error identifying file /u01/backup/arch2/1_36_750725106.dbf

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

这就是因为缺少了36号归档日志的原因,那么现在怎么处理呢?

解决办法:

RMAN> crosscheck archivelog all;

或者:RMAN> change archivelog all crosscheck;

再次执行备份操作即可。

然后需要在RMAN中进行清除操作:

RMAN> list archivelog all;

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
------- ---- ------- - --------- ----
62      1    36      X 16-MAY-11 /u01/backup/arch2/1_36_750725106.dbf
61      1    36      X 16-MAY-11 /u01/backup/arch1/1_36_750725106.dbf

RMAN> delete archivelog 61,62;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
------- ---- ------- - --------- ----
61      1    36      X 16-MAY-11 /u01/backup/arch1/1_36_750725106.dbf
62      1    36      X 16-MAY-11 /u01/backup/arch2/1_36_750725106.dbf

Do you really want to delete the above objects (enter YES or NO)? y
deleted archive log
archive log filename=/u01/backup/arch1/1_36_750725106.dbf recid=61 stamp=751258131
deleted archive log
archive log filename=/u01/backup/arch2/1_36_750725106.dbf recid=62 stamp=751258131
Deleted 2 objects


来源:http:///Linux/2011-10/45403.htm

阅读(1627) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~