一:构造一个UNNAMEDnnnnn文件
select group#,archived,sequence#,status from v$log GROUP# ARC SEQUENCE# STATUS ---------- --- ---------- ---------------- RMAN> list backup of controlfile; BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 5 Full 7.11M DISK 00:00:03 14-DEC-12 BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20121214T062943 Piece Name: /oracle/app/db1/dbs/0fnsqnsl_1_1 Control File Included: Ckp SCN: 2779647876 Ckp time: 14-DEC-12 SQL> select group#,archived,sequence#,status from v$Log; GROUP# ARC SEQUENCE# STATUS ---------- --- ---------- ---------------- SQL> create tablespace jiujian datafile '/oracle/test/jiujian.dbf' size 1m; SQL> select file#,name from v$datafile; ---------- ---------------------------------------- 1 /oracle/test/system1.dbf 3 /oracle/test/sysaux01.dbf 4 /oracle/test/users01.dbf 8 /oracle/test/undotbs1.dbf 11 /oracle/test/jiujian.dbf SQL> create table t3(x int) tablespace jiujian1; 3 insert into t3 values(i); PL/SQL procedure successfully completed.
SEQUENCE# NAME FIRST_CHANGE# NEXT_CHANGE#
---------- ---------------------------------------- ------------- ------------
6 /oracle/archive/1_6_801957264.dbf 2779647184 2779648239
7 /oracle/archive/1_7_801957264.dbf 2779648239 2779648241
8 /oracle/archive/1_8_801957264.dbf 2779648241 2779648243
9 /oracle/archive/1_9_801957264.dbf 2779648243 2779648245
10 /oracle/archive/1_10_801957264.dbf 2779648245 2779648247
11 /oracle/archive/1_11_801957264.dbf 2779648247 2779648250
12 /oracle/archive/1_12_801957264.dbf 2779648250 2779648252
13 /oracle/archive/1_13_801957264.dbf 2779648252 2779648254
14 /oracle/archive/1_14_801957264.dbf 2779648254 2779648256
SQL> startup force nomount;
Total System Global Area 322961408 bytes
Variable Size 92277632 bytes
Database Buffers 222298112 bytes
Redo Buffers 6365184 bytes
Recovery Manager complete.
[oracle@oracle ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 14 07:16:07 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: CRM (not mounted)
RMAN> restore controlfile from '/oracle/app/db1/dbs/0fnsqnsl_1_1';
Starting restore at 14-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=210 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/oracle/CRM2/CRM/control01.ctl
output filename=/oracle/CRM2/CRM/control02.ctl
Finished restore at 14-DEC-12
RMAN> alter database mount;
released channel: ORA_DISK_1
SQL> select group#,archived,sequence#,status from v$log;
GROUP# ARC SEQUENCE# STATUS
---------- --- ---------- ----------------
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
SQL> recover database using backup controlfile;
ORA-00279: change 2779647876 generated at 12/14/2012 06:17:29 needed for thread
ORA-00289: suggestion : /oracle/archive/1_6_801957264.dbf
ORA-00280: change 2779647876 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto <---------------输入auto ORA-00279: change 2779648239 generated at 12/14/2012 06:44:13 needed for thread
ORA-00289: suggestion : /oracle/archive/1_7_801957264.dbf
ORA-00280: change 2779648239 for thread 1 is in sequence #7
ORA-00278: log file '/oracle/archive/1_6_801957264.dbf' no longer needed for
ORA-00279: change 2779648241 generated at 12/14/2012 06:44:14 needed for thread
ORA-00289: suggestion : /oracle/archive/1_8_801957264.dbf
ORA-00280: change 2779648241 for thread 1 is in sequence #8
ORA-00278: log file '/oracle/archive/1_7_801957264.dbf' no longer needed for
ORA-00279: change 2779648243 generated at 12/14/2012 06:44:14 needed for thread
ORA-00289: suggestion : /oracle/archive/1_9_801957264.dbf
ORA-00280: change 2779648243 for thread 1 is in sequence #9
ORA-00278: log file '/oracle/archive/1_8_801957264.dbf' no longer needed for
ORA-00279: change 2779648245 generated at 12/14/2012 06:44:15 needed for thread
ORA-00289: suggestion : /oracle/archive/1_10_801957264.dbf
ORA-00280: change 2779648245 for thread 1 is in sequence #10
ORA-00278: log file '/oracle/archive/1_9_801957264.dbf' no longer needed for
ORA-00279: change 2779648247 generated at 12/14/2012 06:44:16 needed for thread
ORA-00289: suggestion : /oracle/archive/1_11_801957264.dbf
ORA-00280: change 2779648247 for thread 1 is in sequence #11
ORA-00278: log file '/oracle/archive/1_10_801957264.dbf' no longer needed for
ORA-00279: change 2779648250 generated at 12/14/2012 06:44:19 needed for thread
ORA-00289: suggestion : /oracle/archive/1_12_801957264.dbf
ORA-00280: change 2779648250 for thread 1 is in sequence #12
ORA-00278: log file '/oracle/archive/1_11_801957264.dbf' no longer needed for
ORA-00279: change 2779648252 generated at 12/14/2012 06:44:21 needed for thread
ORA-00289: suggestion : /oracle/archive/1_13_801957264.dbf
ORA-00280: change 2779648252 for thread 1 is in sequence #13
ORA-00278: log file '/oracle/archive/1_12_801957264.dbf' no longer needed for
ORA-00279: change 2779648254 generated at 12/14/2012 06:44:22 needed for thread
ORA-00289: suggestion : /oracle/archive/1_14_801957264.dbf
ORA-00280: change 2779648254 for thread 1 is in sequence #14
ORA-00278: log file '/oracle/archive/1_13_801957264.dbf' no longer needed for
ORA-00279: change 2779648256 generated at 12/14/2012 06:44:23 needed for thread
ORA-00289: suggestion : /oracle/archive/1_15_801957264.dbf
ORA-00280: change 2779648256 for thread 1 is in sequence #15
ORA-00278: log file '/oracle/archive/1_14_801957264.dbf' no longer needed for
ORA-00308: cannot open archived log '/oracle/archive/1_15_801957264.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
1 这里提示找不到15号归档,由于15号归档是恢复控制文件前,数据库当前联机日志。 3 恢复控制文件后seq号发生了改变 但是日志文件内容可能还没变。所以我们用seq号为15时刻的日志文件进行尝试性恢复,过程如下: SQL> recover database using backup controlfile;
ORA-00279: change 2779648256 generated at 12/14/2012 06:44:23 needed for thread
ORA-00289: suggestion : /oracle/archive/1_15_801957264.dbf
ORA-00280: change 2779648256 for thread 1 is in sequence #15
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00283: recovery session canceled due to errors
ORA-01244: unnamed datafile(s) added to control file by media recovery ORA-01110: data file 11: '/oracle/test/jiujian1.dbf' ORA-01112: media recovery not started
从以上信息可看到我们之前新建的表空间已经被添加到了控制文件中 SQL> select file#,name,status from v$datafile;
---------- ---------------------------------------- -------
1 /oracle/test/system1.dbf SYSTEM
2 /oracle/test/zxb.dbf ONLINE
3 /oracle/test/sysaux01.dbf ONLINE
4 /oracle/test/users01.dbf ONLINE
5 /oracle/test/zxa.dbf ONLINE
6 /oracle/test/test1.dbf ONLINE
7 /oracle/test/zxc.dbf ONLINE
8 /oracle/test/undotbs1.dbf ONLINE
9 /oracle/test/zxbig.dbf ONLINE
10 /oracle/test2.dbf ONLINE
11 /oracle/app/db1/dbs/UNNAMED00011 RECOVER
SQL> alter database rename file '/oracle/app/db1/dbs/UNNAMED00011' to ' f';
2 重命名数据文件后数据文件头部信息和控制文件中数据文件信息如下: |
| |
| |
Checkpointed at scn: 0x0000.a5ae1636 | Stop scn: 0xffff.ffffffff |
thread:1 rba:(0xf.8f1.10) | |
3 综合以上信息我们需要继续应用联机日志/oracle/CRM2/CRM/redo03.log进行恢复过程,如下: QL> recover database using backup controlfile;
ORA-00279: change 2779648278 generated at 12/14/2012 06:45:04 needed for thread
ORA-00289: suggestion : /oracle/archive/1_15_801957264.dbf
ORA-00280: change 2779648278 for thread 1 is in sequence #15
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oracle/CRM2/CRM/redo03.log
4 恢复后数据文件头部信息和控制文件中数据文件信息如下: 数据文件/oracle/test/jiujian1.db的信息 |
| |
| |
Checkpointed at scn: 0x0000.a5ae1636 | Stop scn: 0x0000.a5ae1636 |
SQL> alter database open resetlogs;