MEMBER -------------------------------------------------------------------------------- /home/oradata/stuorcl/redo03.log /home/oradata/stuorcl/redo02.log /home/oradata/stuorcl/redo01.log /home/oradata/stuorcl/redo_dg_01.log /home/oradata/stuorcl/redo_dg_02.log /home/oradata/stuorcl/redo_dg_03.log
6 rows selected.
SQL>
1,nomount下创建控制文件; [root@xuelong4 ~]# su - oracle [oracle@xuelong4 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 4 13:48:23 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
Total System Global Area 1.1358E+10 bytes Fixed Size 2216744 bytes Variable Size 8589937880 bytes Database Buffers 2751463424 bytes Redo Buffers 13946880 bytes SQL>
3,创建控制文件
CREATE CONTROLFILE REUSE set DATABASE "stuorcl" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 454 DATAFILE ‘/home/oradata/stuorcl/system01.dbf‘, ‘/home/oradata/stuorcl/sysaux01.dbf‘, ‘/home/oradata/stuorcl/undotbs01.dbf‘, ‘/home/oradata/stuorcl/users01.dbf‘, ‘/home/oradata/stuorcl/stuorclk01.dbf‘, ‘/home/oradata/stuorcl/plas01.dbf‘, ‘/home/oradata/stuorcl/pl01.dbf‘, ‘/home/oradata/stuorcl/help01.dbf‘, ‘/home/oradata/stuorcl/adobelc01.dbf‘, ‘/home/oradata/stuorcl/sms01.dbf‘ LOGFILE GROUP 1 (‘/home/oradata/stuorcl/redo03.log‘) SIZE 10M, GROUP 2 (‘/home/oradata/stuorcl/redo02.log‘) SIZE 10M, GROUP 3 (‘/home/oradata/stuorcl/redo01.log‘) SIZE 10M, GROUP 4 (‘/home/oradata/stuorcl/redo_dg_01.log‘) SIZE 10M, GROUP 5 (‘/home/oradata/stuorcl/redo_dg_02.log‘) SIZE 10M, GROUP 6 (‘/home/oradata/stuorcl/redo_dg_03.log‘) SIZE 10M CHARACTER SET ZHS16GBK;
执行过程: SQL> CREATE CONTROLFILE REUSE set DATABASE "stuorcl" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 454 DATAFILE ‘/home/oradata/stuorcl/system01.dbf‘, ‘/home/oradata/stuorcl/sysaux01.dbf‘, 2 3 4 5 6 7 8 9 10 ‘/home/oradata/stuorcl/undotbs01.dbf‘, ‘/home/oradata/stuorcl/users01.dbf‘, ‘/home/oradata/stuorcl/stuorclk01.dbf‘, ‘/home/oradata/stuorcl/plas01.dbf‘, ‘/home/oradata/stuorcl/pl01.dbf‘, ‘/home/oradata/stuorcl/help01.dbf‘, ‘/home/oradata/stuorcl/adobelc01.dbf‘, ‘/home/oradata/stuorcl/sms01.dbf‘ LOGFILE GROUP 1 (‘/home/oradata/stuorcl/redo03.log‘) SIZE 10M, GROUP 2 (‘/home/oradata/stuorcl/redo02.log‘) SIZE 10M, GROUP 3 (‘/home/oradata/stuorcl/redo01.log‘) SIZE 10M, GROUP 4 (‘/home/oradata/stuorcl/redo_dg_01.log‘) SIZE 10M, GROUP 5 (‘/home/oradata/stuorcl/redo_dg_02.log‘) SIZE 10M, GROUP 6 (‘/home/oradata/stuorcl/redo_dg_03.log‘) SIZE 10M CHARACTER SET ZHS16GBK; 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Control file created.
SQL>
4,在新控制文件中注册数据文件备份和归档备份
catalog start with ‘/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/‘; 在mount状态下执行 RMAN> catalog start with ‘/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/‘;
released channel: ORA_DISK_1 searching for all files that match the pattern /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/
List of Files Unknown to the Database ===================================== File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/full_stuorcl_20150123_3051.bak File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/rman_backup.log File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/arch_stuorcl_20150123_3050.bak File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/arch_stuorcl_20150123_3052.bak
Do you really want to catalog the above files (enter YES or NO)? yes cataloging files... cataloging done
List of Cataloged Files ======================= File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/full_stuorcl_20150123_3051.bak File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/arch_stuorcl_20150123_3050.bak File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/arch_stuorcl_20150123_3052.bak
List of Files Which Where Not Cataloged ======================================= File Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/rman_backup.log RMAN-07517: Reason: The file header is corrupted
channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /home/oradata/stuorcl/system01.dbf channel ORA_DISK_1: restoring datafile 00002 to /home/oradata/stuorcl/sysaux01.dbf channel ORA_DISK_1: restoring datafile 00003 to /home/oradata/stuorcl/undotbs01.dbf channel ORA_DISK_1: restoring datafile 00004 to /home/oradata/stuorcl/users01.dbf channel ORA_DISK_1: restoring datafile 00005 to /home/oradata/stuorcl/stuorclk01.dbf channel ORA_DISK_1: restoring datafile 00006 to /home/oradata/stuorcl/plas01.dbf channel ORA_DISK_1: restoring datafile 00007 to /home/oradata/stuorcl/pl01.dbf channel ORA_DISK_1: restoring datafile 00008 to /home/oradata/stuorcl/help01.dbf channel ORA_DISK_1: restoring datafile 00009 to /home/oradata/stuorcl/adobelc01.dbf channel ORA_DISK_1: restoring datafile 00010 to /home/oradata/stuorcl/sms01.dbf channel ORA_DISK_1: reading from backup piece /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/full_stuorcl_20150123_3051.bak channel ORA_DISK_1: piece handle=/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/full_stuorcl_20150123_3051.bak tag=TAG20150123T030053 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:45:45 Finished restore at 04-FEB-15
RMAN>
此时去看oracle后台的alert日志,正在一个个修复数据文件,信息如下: [root@xuelong4 trace]# tail -f /oracle/app/oracle/diag/rdbms/stuunq/stuorcl/trace/alert_stuorcl.log GROUP 5 (‘/home/oradata/stuorcl/redo_dg_02.log‘) SIZE 10M, GROUP 6 (‘/home/oradata/stuorcl/redo_dg_03.log‘) SIZE 10M CHARACTER SET ZHS16GBK Wed Feb 04 17:05:40 2015 alter database mount ORA-1100 signalled during: alter database mount ... Wed Feb 04 17:05:55 2015 alter database mount ORA-1100 signalled during: alter database mount... Wed Feb 04 17:08:38 2015 Full restore complete of datafile 8 /home/oradata/stuorcl/help01.dbf. Elapsed time: 0:00:02 checkpoint is 10903299975 last deallocation scn is 9881798870 Full restore complete of datafile 9 /home/oradata/stuorcl/adobelc01.dbf. Elapsed time: 0:00:00 checkpoint is 10903299975 Wed Feb 04 17:08:53 2015 Full restore complete of datafile 10 /home/oradata/stuorcl/sms01.dbf. Elapsed time: 0:00:07 checkpoint is 10903299975 Wed Feb 04 17:09:52 2015 Full restore complete of datafile 7 /home/oradata/stuorcl/pl01.dbf. Elapsed time: 0:00:46 checkpoint is 10903299975 last deallocation scn is 10891613103 Wed Feb 04 17:12:41 2015 Full restore complete of datafile 3 /home/oradata/stuorcl/undotbs01.dbf. Elapsed time: 0:03:28 checkpoint is 10903299975 last deallocation scn is 10903242336 Undo Optimization current scn is 10903252140 Wed Feb 04 17:14:00 2015 Full restore complete of datafile 4 /home/oradata/stuorcl/users01.dbf. Elapsed time: 0:05:26 checkpoint is 10903299975 last deallocation scn is 10893349080 Wed Feb 04 17:17:52 2015 Full restore complete of datafile 1 /home/oradata/stuorcl/system01.dbf. Elapsed time: 0:08:11 checkpoint is 10903299975 last deallocation scn is 10825889348 Undo Optimization current scn is 10903252140 Wed Feb 04 17:20:27 2015 db_recovery_file_dest_size of 15360 MB is 0.00% used. This is a user-specified limit on the amount of space that will be used by this database for recovery-related files, and does not reflect the amount of space available in the underlying filesystem or ASM diskgroup. Wed Feb 04 17:20:40 2015 Full restore complete of datafile 2 /home/oradata/stuorcl/sysaux01.dbf. Elapsed time: 0:12:02 checkpoint is 10903299975 last deallocation scn is 10901674267 ........
6,开始恢复操作 RMAN> recover database;
Starting recover at 04-FEB-15 using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=29053 channel ORA_DISK_1: reading from backup piece /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/arch_stuorcl_20150123_3052.bak channel ORA_DISK_1: piece handle=/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-23/arch_stuorcl_20150123_3052.bak tag=TAG20150123T032709 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 archived log file name=/oracle/app/oracle/flash_recovery_area/archivelog/1_29053_821708334.dbf thread=1 sequence=29053 unable to find archived log archived log thread=1 sequence=29054 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 02/04/2015 16:19:14 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 29054 and starting SCN of 10903302108
RMAN>
在11g官方文档error messages中对错误描述如下: RMAN-06054: media recovery requesting unknown archived log for thread string with sequence string and starting SCN of string Cause: Media recovery is requesting a log whose existence is not recorded in the recovery catalog or target database control file. Action: If a copy of the log is available, then add it to the recovery catalog and/or control file via a CATALOG command and then retry the RECOVER command. If not, then a point-in-time recovery up to the missing log is the only alternative and database can be opened using ALTER DATABASE OPEN RESETLOGS command.
recover database until scn 10903302108; RMAN> recover database until scn 10903302108;
Starting recover at 04-FEB-15 using channel ORA_DISK_1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 02/04/2015 16:30:30 RMAN-20208: UNTIL CHANGE is before RESETLOGS change
RMAN>
List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time ------- ------- -------- ---------------- --- ---------- ---------- 2 2 stuorcl 3391761643 PARENT 945184 25-JUL-13 1 1 stuorcl 3391761643 CURRENT 10909913627 02-FEB-15
RMAN> google下,看到http://blog.itpub.net/26442936/viewspace-767439/上面有说明 RMAN> reset database to incarnation 2; RMAN> restore database until scn 1045382; RMAN> recover database until scn 1045382; SQL> alter database open resetlogs; 的方式,不过我的incarnation 2已经是2013年的太早了,这种方式不适合。
尝试rman的不完全恢复记录,切换到SQL窗口去: SQL> recover database using backup controlfile until cancel; ORA-00279: change 10903299975 generated at 01/23/2015 03:00:53 needed for thread 1 ORA-00289: suggestion : /oracle/app/oracle/flash_recovery_area/archivelog/1_29053_821708334.dbf ORA-00280: change 10903299975 for thread 1 is in sequence #29053
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 10903302108 generated at 01/23/2015 03:27:09 needed for thread 1 ORA-00289: suggestion : /oracle/app/oracle/flash_recovery_area/archivelog/1_29054_821708334.dbf ORA-00280: change 10903302108 for thread 1 is in sequence #29054 ORA-00278: log file ‘/oracle/app/oracle/flash_recovery_area/archivelog/1_29053_821708334.dbf‘ no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto ORA-00308: cannot open archived log ‘/oracle/app/oracle/flash_recovery_area/archivelog/1_29054_821708334.dbf‘ ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3
ORA-00308: cannot open archived log ‘/oracle/app/oracle/flash_recovery_area/archivelog/1_29054_821708334.dbf‘ ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3
SQL>
SQL> alter database open resetlogs;
Database altered.
SQL>
7,去后台验证下数据,找一张一直有日期变化的表数据: SQL> select to_char(a.last_login_date,‘yyyy-mm-dd hh24:mi:ss‘) from stu.pst_ac a where to_char(a.last_login_date,‘yyyy-mm-dd hh24:mi:ss‘)>‘2015-01-23 00:00:00:00‘ order by to_char(a.last_login_date,‘yyyy-mm-dd hh24:mi:ss‘) desc;
SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 4 19:03:56 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select ut.TABLE_NAME from user_tables ut where rownum<3;