完全恢复是:恢复到故障前所有已经提交的事物。
必须满足下面条件:
1.处于归档模式
2.有良好基点备份
3.有上次备份操作后生成的所有重做日志
4.有上次备份操作后生成的所有归档重做日志
5.有必须的增量备份
6.有未归档的联机重做日志
预览用于恢复操作的备份restore <> preview
上一篇介绍了restore failure preview ,还可以在进行恢复得时候模拟演练下database、tablespace 、:
#整个库
RMAN> restore database preview;
Starting restore at 21-DEC-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=6 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=35 device type=DISK
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 599.67M DISK 00:01:53 21-DEC-15
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 8870031 21-DEC-15 /oracle/oradata/yang/system01.dbf
3 Full 8870031 21-DEC-15 /oracle/oradata/yang/undotbs01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 600.15M DISK 00:02:03 21-DEC-15
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp
List of Datafiles in backup set 10
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 8870032 21-DEC-15 /oracle/oradata/yang/sysaux01.dbf
4 Full 8870032 21-DEC-15 /oracle/oradata/yang/users01.dbf
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Archived Log Copies for database with db_unique_name YANG
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
361 1 425 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_425_c7hpnd6m_.arc
362 1 426 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_426_c7hq44kw_.arc
363 1 427 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_427_c7hr37mf_.arc
Media recovery start SCN is 8870031
Recovery must be done beyond SCN 8870032 to clear datafile fuzziness
Finished restore at 21-DEC-15
#表空间
RMAN> restore tablespace system preview;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 599.67M DISK 00:01:53 21-DEC-15
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 8870031 21-DEC-15 /oracle/oradata/yang/system01.dbf
List of Archived Log Copies for database with db_unique_name YANG
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
361 1 425 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_425_c7hpnd6m_.arc
362 1 426 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_426_c7hq44kw_.arc
363 1 427 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_427_c7hr37mf_.arc
Media recovery start SCN is 8870031
Recovery must be done beyond SCN 8870031 to clear datafile fuzziness
Finished restore at 21-DEC-15
#归档日志
RMAN> restore archivelog from time 'sysdate - 1' preview
2> ;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Archived Log Copies for database with db_unique_name YANG
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
358 1 422 A 20-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_422_c7fobywf_.arc
359 1 423 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_423_c7fv6b00_.arc
360 1 424 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_424_c7hp7g32_.arc
361 1 425 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_425_c7hpnd6m_.arc
362 1 426 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_426_c7hq44kw_.arc
363 1 427 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_427_c7hr37mf_.arc
Finished restore at 21-DEC-15
#数据文件
RMAN> restore datafile 1,2,3 preview;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 599.67M DISK 00:01:53 21-DEC-15
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 8870031 21-DEC-15 /oracle/oradata/yang/system01.dbf
3 Full 8870031 21-DEC-15 /oracle/oradata/yang/undotbs01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 600.15M DISK 00:02:03 21-DEC-15
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp
List of Datafiles in backup set 10
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 8870032 21-DEC-15 /oracle/oradata/yang/sysaux01.dbf
List of Archived Log Copies for database with db_unique_name YANG
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
361 1 425 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_425_c7hpnd6m_.arc
362 1 426 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_426_c7hq44kw_.arc
363 1 427 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_427_c7hr37mf_.arc
Media recovery start SCN is 8870031
Recovery must be done beyond SCN 8870032 to clear datafile fuzziness
Finished restore at 21-DEC-15
#概述,加入summary
RMAN> restore database preview summary;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
9 B F A DISK 21-DEC-15 1 1 NO TAG20151221T185253
10 B F A DISK 21-DEC-15 1 1 NO TAG20151221T185253
List of Archived Log Copies for database with db_unique_name YANG
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
361 1 425 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_425_c7hpnd6m_.arc
362 1 426 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_426_c7hq44kw_.arc
363 1 427 A 21-DEC-15
Name: /oracle/flash_recovery_area/YANG/archivelog/2015_12_21/o1_mf_1_427_c7hr37mf_.arc
Media recovery start SCN is 8870031
Recovery must be done beyond SCN 8870032 to clear datafile fuzziness
Finished restore at 21-DEC-15
在恢复前检查备份文件
在恢复的时候可以起交易恢复文件的完整性,心里更有谱,以免恢复途中半途而废。
#交易备份片的中的恢复文件的头信息
RMAN> restore database validate header;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 599.67M DISK 00:01:53 21-DEC-15
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 8870031 21-DEC-15 /oracle/oradata/yang/system01.dbf
3 Full 8870031 21-DEC-15 /oracle/oradata/yang/undotbs01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 600.15M DISK 00:02:03 21-DEC-15
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20151221T185253
Piece Name: /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp
List of Datafiles in backup set 10
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 8870032 21-DEC-15 /oracle/oradata/yang/sysaux01.dbf
4 Full 8870032 21-DEC-15 /oracle/oradata/yang/users01.dbf
validation succeeded for backup piece
Finished restore at 21-DEC-15
#进一步检查(物理检查)
RMAN> restore database validate;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_2: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp
channel ORA_DISK_2: reading from backup piece /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp
channel ORA_DISK_1: piece handle=/oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp tag=TAG20151221T185253
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:35
channel ORA_DISK_2: piece handle=/oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp tag=TAG20151221T185253
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: validation complete, elapsed time: 00:00:36
Finished restore at 21-DEC-15
#前面两部都是坏块的检查,还可以进行逻辑层面的检查
RMAN> restore database validate check logical;
Starting restore at 21-DEC-15
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_2: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp
channel ORA_DISK_2: reading from backup piece /oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp
channel ORA_DISK_1: piece handle=/oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj6q1_.bkp tag=TAG20151221T185253
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:45
channel ORA_DISK_2: piece handle=/oracle/flash_recovery_area/YANG/backupset/2015_12_21/o1_mf_nnndf_TAG20151221T185253_c7hpj8dp_.bkp tag=TAG20151221T185253
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: validation complete, elapsed time: 00:00:45
Finished restore at 21-DEC-15
#来一些中文的,下面是在12C中根容器下的命令
RMAN> restore database validate header;
启动 restore 于 2015-12-21 19:45:52
使用通道 ORA_DISK_1
备份集列表
===================
BS 关键字 类型 LV 大小 设备类型 经过时间 完成时间
------- ---- -- ---------- ----------- ------------ -------------------
288 Full 1.25G DISK 00:00:11 2015-12-21 18:42:12
BP 关键字: 297 状态: AVAILABLE 已压缩: NO 标记: TAG20151221T184200
段名:C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP
备份集 288 中的数据文件列表
文件 LV 类型 Ckp SCN Ckp 时间 名称
---- -- ---- ---------- ------------------- ----
1 Full 4378551 2015-12-21 18:42:01 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCLTN26_.DBF
3 Full 4378551 2015-12-21 18:42:01 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSAUX_BYCLRWV7_.DBF
5 Full 4378551 2015-12-21 18:42:01 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_UNDOTBS1_BYCLWPHZ_.DBF
6 Full 4378551 2015-12-21 18:42:01 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_USERS_BYCLWOB1_.DBF
11 Full 4378551 2015-12-21 18:42:01 C:\APP\ORACLE\RECCATLODDIR\RECCAT01.DBF
BS 关键字 类型 LV 大小 设备类型 经过时间 完成时间
------- ---- -- ---------- ----------- ------------ -------------------
289 Full 769.02M DISK 00:00:09 2015-12-21 18:42:21
BP 关键字: 298 状态: AVAILABLE 已压缩: NO 标记: TAG20151221T184200
段名:C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.BKP
备份集 289 中的数据文件列表
容器 ID: 3, PDB 名称: PYANG1
文件 LV 类型 Ckp SCN Ckp 时间 名称
---- -- ---- ---------- ------------------- ----
7 Full 4204782 2015-12-19 13:52:03 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCMNHWC_.DBF
8 Full 4204782 2015-12-19 13:52:03 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSAUX_BYCMNHW0_.DBF
9 Full 4204782 2015-12-19 13:52:03 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_USERS_BYCMNHWP_.DBF
10 Full 4204782 2015-12-19 13:52:03 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_EXAMPLE_BYCMNHVM_.DBF
数据文件副本列表
=======================
关键字 文件 S 完成时间 Ckp SCN Ckp 时间
------- ---- - ------------------- ---------- -------------------
64 2 A 2015-12-15 20:47:00 2453693 2015-09-02 00:18:43
名称: C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\A00BB53DE42D4A6C8AC2FCFA7944681C\DATAFILE\O1_MF_SYSTEM_C702Y2G9_.DBF
标记: INCUPDATE
62 4 A 2015-12-15 20:46:52 2453693 2015-09-02 00:18:43
名称: C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\A00BB53DE42D4A6C8AC2FCFA7944681C\DATAFILE\O1_MF_SYSAUX_C702XR3H_.DBF
标记: INCUPDATE
对数据文件副本和控制文件副本的验证成功
对备份片段的验证成功
完成 restore 于 2015-12-21 19:45:53
RMAN> restore database validate ;
启动 restore 于 2015-12-21 19:46:51
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在扫描数据文件副本 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\A00BB53DE42D4A6C8AC2FCFA7944681C\DATAFILE\O1_MF_SYSTEM_C702Y2G9_.DBF
通道 ORA_DISK_1: 正在扫描数据文件副本 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\A00BB53DE42D4A6C8AC2FCFA7944681C\DATAFILE\O1_MF_SYSAUX_C702XR3H_.DBF
通道 ORA_DISK_1: 正在开始验证数据文件备份集
通道 ORA_DISK_1: 正在读取备份片段 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP
通道 ORA_DISK_1: 段句柄 = C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP 标记 = TAG20151221T184200
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 验证完成, 用时: 00:00:04
通道 ORA_DISK_1: 正在开始验证数据文件备份集
通道 ORA_DISK_1: 正在读取备份片段 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.
BKP
通道 ORA_DISK_1: 段句柄 = C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.BKP 标记
= TAG20151221T184200
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 验证完成, 用时: 00:00:03
完成 restore 于 2015-12-21 19:47:02
RMAN> restore database validate check logical;
启动 restore 于 2015-12-21 19:47:14
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在扫描数据文件副本 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\A00BB53DE42D4A6C8AC2FCFA7944681C\DATAFILE\O1_MF_SYSTEM_C702Y2G9_.DBF
通道 ORA_DISK_1: 正在扫描数据文件副本 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\A00BB53DE42D4A6C8AC2FCFA7944681C\DATAFILE\O1_MF_SYSAUX_C702XR3H_.DBF
通道 ORA_DISK_1: 正在开始验证数据文件备份集
通道 ORA_DISK_1: 正在读取备份片段 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP
通道 ORA_DISK_1: 段句柄 = C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP 标记 = TAG20151221T184200
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 验证完成, 用时: 00:00:03
通道 ORA_DISK_1: 正在开始验证数据文件备份集
通道 ORA_DISK_1: 正在读取备份片段 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.
BKP
通道 ORA_DISK_1: 段句柄 = C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.BKP 标记
= TAG20151221T184200
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 验证完成, 用时: 00:00:03
完成 restore 于 2015-12-21 19:47:24
RMAN>
其他的检查:
RMAN> restore datafile 1,2,3 validate;
RMAN> restore archivelog all validate;
RMAN> restore controlfile validate;
RMAN> restore tablespace system validate;
演示一个恢复控制文件的例子
主要演示:
1. 关闭数据库,启动到nomount、mount模式进行恢复的结果
2. 恢复控制文件
3. 恢复控制文件open数据库遇到的各种问题
4. 进行数据库还原、恢复、open过程
来说明数据库恢复助手也不是万能的,恢复信息保存到控制文件中。
#1.关闭数据库,启动到nomount模式
RMAN> shutdown immediate;
数据库已关闭
数据库已卸装
Oracle 实例已关闭
RMAN> startup nomount;
已连接到目标数据库 (未启动)
Oracle 实例已启动
系统全局区域总计 1560281088 字节
Fixed Size 3046032 字节
Variable Size 939525488 字节
Database Buffers 603979776 字节
Redo Buffers 13729792 字节
#2. 恢复控制文件,并更改数据库状态为mount模式
RMAN> restore controlfile from autobackup;
启动 restore 于 2015-12-21 20:26:44
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=242 设备类型=DISK
恢复区目标: C:\app\oracle\fast_recovery_area
用于搜索的数据库名 (或数据库的唯一名称): CYANG
通道 ORA_DISK_1: 在恢复区中找到 AUTOBACKUP C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\AUTOBACKUP\2015_12_21\O1_MF_S_899059360_C7HOX0Q3_.BKP
通道 ORA_DISK_1: 寻找以下日期的 AUTOBACKUP: 20151221
通道 ORA_DISK_1: 正在从 AUTOBACKUP C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\AUTOBACKUP\2015_12_21\O1_MF_S_899059360_C7HOX0Q3_.BKP 还原控制文件
通道 ORA_DISK_1: 从 AUTOBACKUP 还原控制文件已完成
输出文件名=C:\APP\ORACLE\ORADATA\CYANG\CONTROLFILE\O1_MF_BYCM08MV_.CTL
输出文件名=C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\CONTROLFILE\O1_MF_BYCM08PY_.CTL
完成 restore 于 2015-12-21 20:26:47
RMAN> alter database mount;
已处理语句
释放的通道: ORA_DISK_1
#3. 直接打开数据库,提示需要reset选项
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: sql statement 命令 (在 12/21/2015 20:27:38 上) 失败
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
#4. 用resetlog打开数据报错
RMAN> alter database open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: sql statement 命令 (在 12/21/2015 20:28:22 上) 失败
ORA-01152: 文件 1 没有从过旧的备份中还原
ORA-01110: 数据文件 1: 'C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCLTN26_.DBF'
#5. 关闭实例,不开启直接还原数据库报错,需要启动到nomount模式,启动到nomount进行还原还是报错
RMAN> shutdown abort;
Oracle 实例已关闭
RMAN> restore database;
启动 restore 于 2015-12-21 20:29:04
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: restore 命令 (在 12/21/2015 20:29:04 上) 失败
RMAN-12010: 自动通道分配初始化失败
RMAN-06171: 没有连接到目标数据库
RMAN> startup nomount;
已连接到目标数据库 (未启动)
Oracle 实例已启动
系统全局区域总计 1560281088 字节
Fixed Size 3046032 字节
Variable Size 939525488 字节
Database Buffers 603979776 字节
Redo Buffers 13729792 字节
RMAN> restore database;
启动 restore 于 2015-12-21 20:29:55
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=242 设备类型=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: restore 命令 (在 12/21/2015 20:29:55 上) 失败
ORA-01507: 未装载数据库
#6. 需要启动到mount模式,还原成功。因为需要读取其中的控制文件
RMAN> alter database mount;
已处理语句
释放的通道: ORA_DISK_1
RMAN> restore database;
启动 restore 于 2015-12-21 20:30:11
启动 implicit crosscheck backup 于 2015-12-21 20:30:11
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=242 设备类型=DISK
已交叉检验的 14 对象
完成 implicit crosscheck backup 于 2015-12-21 20:30:11
启动 implicit crosscheck copy 于 2015-12-21 20:30:11
使用通道 ORA_DISK_1
已交叉检验的 2 对象
完成 implicit crosscheck copy 于 2015-12-21 20:30:12
搜索恢复区中的所有文件
正在编制文件目录...
目录编制完毕
已列入目录的文件的列表
=======================
文件名: C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\AUTOBACKUP\2015_12_21\O1_MF_S_899059360_C7HOX0Q3_.BKP
使用通道 ORA_DISK_1
正在略过数据文件 2; 已还原到文件 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCM0ZWL_.DBF
正在略过数据文件 4; 已还原到文件 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSAUX_BYCM0ZW8_.DBF
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 将数据文件 00001 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCLTN26_.DBF
通道 ORA_DISK_1: 将数据文件 00003 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSAUX_BYCLRWV7_.DBF
通道 ORA_DISK_1: 将数据文件 00005 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_UNDOTBS1_BYCLWPHZ_.DBF
通道 ORA_DISK_1: 将数据文件 00006 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_USERS_BYCLWOB1_.DBF
通道 ORA_DISK_1: 将数据文件 00011 还原到 C:\APP\ORACLE\RECCATLODDIR\RECCAT01.DBF
通道 ORA_DISK_1: 正在读取备份片段 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP
通道 ORA_DISK_1: 段句柄 = C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOVS7Q_.BKP 标记 = TAG20151221T184200
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:25
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 将数据文件 00007 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCMNHWC_.DBF
通道 ORA_DISK_1: 将数据文件 00008 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSAUX_BYCMNHW0_.DBF
通道 ORA_DISK_1: 将数据文件 00009 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_USERS_BYCMNHWP_.DBF
通道 ORA_DISK_1: 将数据文件 00010 还原到 C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_EXAMPLE_BYCMNHVM_.DBF
通道 ORA_DISK_1: 正在读取备份片段 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.
BKP
通道 ORA_DISK_1: 段句柄 = C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\809378F024254A0AAF1C7D06CC6D9706\BACKUPSET\2015_12_21\O1_MF_NNNDF_TAG20151221T184200_C7HOW8P5_.BKP 标记
= TAG20151221T184200
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:15
完成 restore 于 2015-12-21 20:30:53
#7. 进行测试恢复,请用恢复顾问的建议,结果不可行执行进行恢复操作。只能恢复数据,用resetlogs打开数据库
RMAN> recover database test;
启动 recover 于 2015-12-21 20:31:00
使用通道 ORA_DISK_1
正在开始介质的恢复
线程 1 序列 88 的归档日志已作为文件 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ARCHIVELOG\2015_12_21\O1_MF_1_88_C7HOWZ1V_.ARC 存在于磁盘上
线程 1 序列 89 的归档日志已作为文件 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ONLINELOG\O1_MF_2_BYCM0FTX_.LOG 存在于磁盘上
归档日志文件名=C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ARCHIVELOG\2015_12_21\O1_MF_1_88_C7HOWZ1V_.ARC 线程=1 序列=88
归档日志文件名=C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ONLINELOG\O1_MF_2_BYCM0FTX_.LOG 线程=1 序列=89
RMAN-11006: 警告: 测试恢复结果:
ORA-10574: Test recovery did not corrupt any data block
ORA-10573: Test recovery tested redo from change 4378551 to 4380936
ORA-10572: Test recovery canceled due to errors
ORA-10585: Test recovery can not apply redo that may modify control file
介质恢复完成, 用时: 00:00:00
完成 recover 于 2015-12-21 20:31:01
#用RMAN看看出了什么问题
RMAN> list failure;
数据库角色: PRIMARY
数据库故障列表
=========================
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9145 CRITICAL OPEN 2015-12-21 20:28:23 系统数据文件 1: 'C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSTEM_BYCLTN26_.DBF' 需要介质恢复
9142 CRITICAL OPEN 2015-12-21 20:28:23 控制文件需要介质恢复
9148 HIGH OPEN 2015-12-21 20:28:23 一个或多个非系统数据文件需要介质恢复
#看下详细的信息
RMAN> list failure 9148 detail;
数据库角色: PRIMARY
数据库故障列表
=========================
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9148 HIGH OPEN 2015-12-21 20:28:23 一个或多个非系统数据文件需要介质恢复
影响: 请参阅单个子故障的影响
父故障 ID 9148 的子故障列表
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9190 HIGH OPEN 2015-12-21 20:28:23 数据文件 11: 'C:\APP\ORACLE\RECCATLODDIR\RECCAT01.DBF' 需要介质恢复
影响: 表空间 RECCAT 中的某些对象可能不可用
9163 HIGH OPEN 2015-12-21 20:28:23 数据文件 6: 'C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_USERS_BYCLWOB1_.DBF' 需要介质恢复
影响: 表空间 USERS 中的某些对象可能不可用
9157 HIGH OPEN 2015-12-21 20:28:23 数据文件 5: 'C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_UNDOTBS1_BYCLWPHZ_.DBF' 需要介质恢复
影响: 表空间 UNDOTBS1 中的某些对象可能不可用
9151 HIGH OPEN 2015-12-21 20:28:23 数据文件 3: 'C:\APP\ORACLE\ORADATA\CYANG\DATAFILE\O1_MF_SYSAUX_BYCLRWV7_.DBF' 需要介质恢复
影响: 表空间 SYSAUX 中的某些对象可能不可用
#采用恢复助手的建议
RMAN> advise failure ;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: advise 命令 (在 12/21/2015 20:37:15 上) 失败
RMAN-07259: 存在 2 个严重故障; 无法从 ADVISE FAILURE 中排除
RMAN> advise failure 9148;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: advise 命令 (在 12/21/2015 20:37:41 上) 失败
RMAN-07259: 存在 2 个严重故障; 无法从 ADVISE FAILURE 中排除
#直接进行恢复
RMAN> recover database;
启动 recover 于 2015-12-21 20:38:15
使用通道 ORA_DISK_1
正在开始介质的恢复
线程 1 序列 88 的归档日志已作为文件 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ARCHIVELOG\2015_12_21\O1_MF_1_88_C7HOWZ1V_.ARC 存在于磁盘上
线程 1 序列 89 的归档日志已作为文件 C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ONLINELOG\O1_MF_2_BYCM0FTX_.LOG 存在于磁盘上
归档日志文件名=C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ARCHIVELOG\2015_12_21\O1_MF_1_88_C7HOWZ1V_.ARC 线程=1 序列=88
归档日志文件名=C:\APP\ORACLE\FAST_RECOVERY_AREA\CYANG\ONLINELOG\O1_MF_2_BYCM0FTX_.LOG 线程=1 序列=89
介质恢复完成, 用时: 00:00:01
完成 recover 于 2015-12-21 20:38:17
#再次显示故障信息
RMAN> list failure;
数据库角色: PRIMARY
数据库故障列表
=========================
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9142 CRITICAL OPEN 2015-12-21 20:28:23 控制文件需要介质恢复
RMAN> list failure 9142;
数据库角色: PRIMARY
数据库故障列表
=========================
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9142 CRITICAL OPEN 2015-12-21 20:28:23 控制文件需要介质恢复
RMAN> list failure 9142 detail;
数据库角色: PRIMARY
数据库故障列表
=========================
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9142 CRITICAL OPEN 2015-12-21 20:28:23 控制文件需要介质恢复
影响: 无法打开数据库
RMAN> advise failure 9142;
数据库角色: PRIMARY
数据库故障列表
=========================
失败 ID 优先级状态 检测时间 概要
------- -------- --------- ------------------- -------
9142 CRITICAL OPEN 2015-12-21 20:28:23 控制文件需要介质恢复
正在分析自动修复选项; 这可能需要一些时间
使用通道 ORA_DISK_1
分析自动修复选项完成
必需的手动操作
========================
1. 如果有控制文件的正确版本, 则关闭数据库并替换旧的控制文件
2. 如果无法执行上述建议, 或者这些建议无法修复选定要修复的故障, 请与 Oracle 技术支持服务联系
可选手动操作
=======================
没有可用的手动操作
自动修复选项
========================
没有可用的自动修复选项
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: sql statement 命令 (在 12/21/2015 20:40:18 上) 失败
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
#不重置数据库联机日志打开数据库
RMAN> alter database open NORESETLOGS;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: sql statement 命令 (在 12/21/2015 20:41:49 上) 失败
ORA-01588: 要打开数据库则必须使用 RESETLOGS 选项
#重置数据库联机日志
RMAN> alter database open resetlogs;
已处理语句
RMAN>