欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

RMAN恢复数据库ORA-01861错误 博客分类: Oracle oraclermanora-01861 

程序员文章站 2024-03-16 14:59:40
...

在一个新环境中恢复数据库备份。在数据文件还原阶段,就出现了错误。

 

环境说明:Oracle 10.2.0.3 for solaris 10,备份数据库是RAC,恢复则在单实例上进行。

 

操作出现过程如下:

 

第一步,将数据库恢复到某个时间点,恢复出错。

 

RMAN> run
2> {
3> allocate channel ch01 type disk;
4> allocate channel ch02 type disk;
5> set until time "to_date('2012-06-25 23:00:00','yyyy-mm-dd hh24:mi:ss')";
6> set newname for datafile 1 to '/stor2T/app/oracle/oradata/urpdb/system01.dbf';
7> set newname for datafile 2 to '/stor2T/app/oracle/oradata/urpdb/undotbs1.dbf';
8> restore datafile 1;
9> restore datafile 2;
10> switch datafile all;
11> release channel ch01;
12> release channel ch02;
13> }

using target database control file instead of recovery catalog
allocated channel: ch01
channel ch01: sid=155 devtype=DISK

allocated channel: ch02
channel ch02: sid=156 devtype=DISK

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 27-JUN-12

released channel: ch01
released channel: ch02
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/27/2012 16:09:51
ORA-01861: literal does not match format string

 

我想,这可能是时间格式问题,先回避它吧。

 

第二步,换成成UNTIL SCN去还原数据文件。

 


RMAN> run
2> {
3> allocate channel ch01 type disk;
4> allocate channel ch02 type disk;
5> set until scn 3054150330;
6> set newname for datafile 1 to '/stor2T/app/oracle/oradata/urpdb/system01.dbf';
7> restore datafile 1;
8> switch datafile all;
9> release channel ch01;
10> release channel ch02;
11> }

allocated channel: ch01
channel ch01: sid=155 devtype=DISK

allocated channel: ch02
channel ch02: sid=156 devtype=DISK

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 27-JUN-12

released channel: ch01
released channel: ch02
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/27/2012 16:12:38
ORA-01861: literal does not match format string

RMAN>

即使使用SCN也是报错。

 

第三步,检查备份结果集,也报错。

 

RMAN> list backupset summary;

using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 06/27/2012 16:29:18
ORA-01861: literal does not match format string

 

 

这下麻烦了。难道问题是出在环境变量上吗?

 

检查环境变量设置,和数据库初始化参数设置。

 

env|grep NLS_DATE_FORAMT

结果显示的已经是'yyyy-mm-dd hh24:mi:ss'格式了。

 

 

再查metalink,发现有bug

 

Cause

Bug 8513905 : ORA-1861 DURING RMAN RECOVERY

Backuppieces in the controlfile have an invalid date. To check if you are hitting this bug query the controlfile:

SQL> alter session set nls_date_format='dd-mon-rr hh24:mi:ss'; 
SQL> select recid, status, device_type, handle, completion_time from
v$backup_piece where completion_time > '<date>';

Use '<date>' to limit the output to those backuppieces being used during recovery and check for invalid dates.   In this case, completion_time for the backuppiece was 04/31/2009 00:57:33 (April only has 30 days).

If the SQL above raises ORA-1861, dump the controlfile and find the trace file in target udump directory :

SQL> alter session set events 'immediate trace name controlf level 20';

Look for a the BACKUP PIECE RECORDS section eg

 *************************************************************************** 
  BACKUP PIECE RECORDS 
  *************************************************************************** 
  ... 
  RECID #68030 Recno 5688 Record timestamp 06/30/09 16:32:01 piece #1 copy 
  #1 pool 0 
  Backup set key: stamp=690857355, count=69079 
  V$RMAN_STATUS: recid=1152921504606803592, stamp=1152921504606803584 
  Flags: <concurrent access> <compressed> 
  Device: DISK 
  Handle: /orashare/backup/S_DBARCLG_BCK_enkir9cb_1_1 
  Media-Handle: 
  Comment: 
  Tag: S_DBARCLG_Q1QSST1_300609_0015 
  Completion time 06/31/09 11:43:20 <<<

 

 

在doc中说,影响到的数据库版本从10.2.0.3到10.2.0.5。

这下麻烦大了。

 

 

(miki西游 @mikixiyou 原文链接 http://mikixiyou.iteye.com/blog/1569221

 

参照 doc 一步一步去解决吧。

 

第一种解决方法,重建控制文件。

第二种,第三种,请参考官方doc,ID 852723.1