博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle Rman 数据库的不完全恢复
阅读量:2496 次
发布时间:2019-05-11

本文共 9205 字,大约阅读时间需要 30 分钟。

前提条件:
1、数据库运行在归档模式;
2、必须有要恢复时间点前的所有数据文件备份和在恢复时间点和数据文件备份时刻之间的所有归档日志。
下面的恢复假设如下条件:
1、恢复使用当前的 incarnation;
2、使用当前的控制文件;
3、使用当前的参数文件。
--
决定恢复的 SCN
选择恢复到第5个 RECID 的结束 SCN (
849702)
SQL> SELECT RECID, STAMP, THREAD#, SEQUENCE#, FIRST_CHANGE#
       FIRST_TIME, NEXT_CHANGE#
FROM   V$ARCHIVED_LOG
WHERE  RESETLOGS_CHANGE# =
       ( SELECT RESETLOGS_CHANGE#
         FROM   V$DATABASE_INCARNATION
         WHERE  STATUS = 'CURRENT');
     RECID      STAMP    THREAD#  SEQUENCE# FIRST_TIME NEXT_CHANGE#
---------- ---------- ---------- ---------- ---------- ------------
         1  901491788          1          5     821736       846174
         2  901492103          1          6     846174       846670
         3  901492215          1          7     846670       846723
         4  901495908          1          8     846723       849501
         
5  901495932          1          9     849501       849702
         6  901495947          1         10     849702       850650
         7  901496002          1         11     850650       850945
         8  901496122          1         12     850945       851004
--可以设置 RMAN 的时间格式,也可以将其写在 .bash_profile 中
[oracle@localhost ~]$ export NLS_DATE_FORMAT="YYYY/MM/DD HH24:MI:SS"
--关闭数据库,并启动到 MOUNT 状态
RMAN> SHUTDOWN IMMEDIATE;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> STARTUP MOUNT
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area     318046208 bytes
Fixed Size                     1336260 bytes
Variable Size                125832252 bytes
Database Buffers             184549376 bytes
Redo Buffers                   6328320 bytes
--执行不完全恢复
RMAN> RUN
  SET UNTIL SCN 849702;    
  RESTORE DATABASE;
  RECOVER DATABASE;
}2> 3> 4> 5> 6> 
executing command: SET until clause
Starting restore at 2016/01/19 05:41:16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
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 /ORADATA/neo/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /ORADATA/neo/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /ORADATA/neo/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /ORADATA/neo/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /ORADATA/neo/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /ORADATA/neo/users02.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_nnndf_TAG20160118T222831_c9sxnl4j_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_nnndf_TAG20160118T222831_c9sxnl4j_.bkp tag=TAG20160118T222831
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 2016/01/19 05:42:42
Starting recover at 2016/01/19 05:42:42
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=7
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T223015_c9sxqq4f_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T223015_c9sxqq4f_.bkp tag=TAG20160118T223015
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc thread=1 sequence=7
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc RECID=9 STAMP=901518165
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T233324_c9t1g580_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T233324_c9t1g580_.bkp tag=TAG20160118T233324
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc thread=1 sequence=8
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc RECID=10 STAMP=901518173
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc thread=1 sequence=9
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc RECID=11 STAMP=901518173
media recovery complete, elapsed time: 00:00:18
Finished recover at 2016/01/19 05:43:19
--打开数据库
RMAN> ALTER DATABASE OPEN RESETLOGS;
database opened
--下面是后台告警日志中的内容
Tue Jan 19 05:41:19 2016
Full restore complete of datafile 6 /ORADATA/neo/users02.dbf.  Elapsed time: 0:00:00 
  checkpoint is 846683
Full restore complete of datafile 4 /ORADATA/neo/users01.dbf.  Elapsed time: 0:00:02 
  checkpoint is 846683
Tue Jan 19 05:41:37 2016
Full restore complete of datafile 5 /ORADATA/neo/example01.dbf.  Elapsed time: 0:00:15 
  checkpoint is 846683
  last deallocation scn is 775082
Full restore complete of datafile 3 /ORADATA/neo/undotbs01.dbf.  Elapsed time: 0:00:20 
  checkpoint is 846683
  last deallocation scn is 789640
Tue Jan 19 05:42:22 2016
Full restore complete of datafile 2 /ORADATA/neo/sysaux01.dbf.  Elapsed time: 0:01:01 
  checkpoint is 846683
  last deallocation scn is 825117
Tue Jan 19 05:42:33 2016
Full restore complete of datafile 1 /ORADATA/neo/system01.dbf.  Elapsed time: 0:01:12 
  checkpoint is 846683
  last deallocation scn is 824418
Tue Jan 19 05:42:43 2016
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6
alter database recover if needed
 start until change 849702
Media Recovery Start
Serial Media Recovery started
ORA-279 signalled during: alter database recover if needed
 start until change 849702
...
alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc
ORA-279 signalled during: alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc'...
Tue Jan 19 05:43:01 2016
alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc
Tue Jan 19 05:43:12 2016
ORA-279 signalled during: alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc'...
lash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc'...
alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc
Incomplete Recovery applied until change 849702 time 01/18/2016 23:32:08
Media Recovery Complete (neo)
Completed: alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc'
Tue Jan 19 05:46:14 2016
alter database open resetlogs
Archived Log entry 12 added for thread 1 sequence 13 ID 0x765bad34 dest 1:
RESETLOGS after incomplete recovery UNTIL CHANGE 849702
Resetting resetlogs activation ID 1985719604 (0x765bad34)
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_ora_29148.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 1 of thread 1 is not current copy
ORA-00312: online log 1 thread 1: '/ORADATA/neo/redo01.log'
Tue Jan 19 05:46:18 2016
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_m000_29872.trc:
ORA-00316: log 1 of thread 1, type 0 in header is not log file
ORA-00312: online log 1 thread 1: '/ORADATA/neo/redo01.log'
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_ora_29148.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 2 of thread 1 is not current copy
ORA-00312: online log 2 thread 1: '/ORADATA/neo/redo02.log'
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_ora_29148.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 3 of thread 1 is not current copy
ORA-00312: online log 3 thread 1: '/ORADATA/neo/redo03.log'
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_m000_29872.trc:
ORA-00316: log 2 of thread 1, type 0 in header is not log file
ORA-00312: online log 2 thread 1: '/ORADATA/neo/redo02.log'
Tue Jan 19 05:46:23 2016
Setting recovery target incarnation to 3
Checker run found 4 new persistent data failures

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26506993/viewspace-1978759/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26506993/viewspace-1978759/

你可能感兴趣的文章
hive常用函数及数据结构介绍
查看>>
Hive面试题干货(亲自跟着做了好几遍,会了的话对面试大有好处)
查看>>
力扣题解-230. 二叉搜索树中第K小的元素(递归方法,中序遍历解决)
查看>>
力扣题解-123. 买卖股票的最佳时机 III(动态规划)
查看>>
Django 源码阅读:服务启动(wsgi)
查看>>
Django 源码阅读:url解析
查看>>
Docker面试题(一)
查看>>
第一轮面试题
查看>>
2020-11-18
查看>>
Docker面试题(二)
查看>>
一、redis面试题及答案
查看>>
消息队列2
查看>>
C++ 线程同步之临界区CRITICAL_SECTION
查看>>
测试—自定义消息处理
查看>>
MFC中关于虚函数的一些问题
查看>>
根据图层名获取图层和图层序号
查看>>
规范性附录 属性值代码
查看>>
提取面狭长角
查看>>
Arcsde表空间自动增长
查看>>
Arcsde报ora-29861: 域索引标记为loading/failed/unusable错误
查看>>