代码改变世界

记录一则RMAN恢复到历史备份(多个incarnation)

2018-06-27 07:56  AlfredZhao  阅读(928)  评论(0编辑  收藏  举报

环境: OEL 5.7 + Oracle 11.2.0.4
1.直接restore到想要恢复的时间点报错:

RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> restore database until time '2018-06-26 09:00:00';

Starting restore at 2018-06-27 07:30:04
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/27/2018 07:30:04
RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

2.查看incarnation,尝试RESET DATABASE TO INCARNATION也不行:

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORCL     1507617844       PARENT  1          2013-08-24 11:37:30
2       2       ORCL     1507617844       CURRENT 925702     2018-06-26 16:58:31

RMAN> RESET DATABASE TO INCARNATION 1;

database reset to incarnation 1

RMAN> restore database until time '2018-06-26 09:00:00';

Starting restore at 2018-06-27 07:30:40
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/27/2018 07:30:40
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
RMAN> list backup of database;

specification does not match any backup in the repository

此时catalog start with 之前的全备也不认。
思考一下。。
3.恢复一个incarnation之前的控制文件来尝试恢复:

[ora11204@OEL-ASM orabak]$ ls -lrth |grep CTL
-rw-r----- 1 ora11204 oinstall  12M Jun 26 15:00 ORCL.656.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall  12M Jun 26 16:00 ORCL.660.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 17:00 ORCL.1.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 18:00 ORCL.3.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 19:00 ORCL.5.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 20:00 ORCL.7.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 21:00 ORCL.9.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 22:00 ORCL.11.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 26 23:00 ORCL.13.1.20180626.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 00:00 ORCL.15.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 01:00 ORCL.17.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 02:00 ORCL.25.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 03:00 ORCL.27.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 04:00 ORCL.29.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 05:00 ORCL.31.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 06:00 ORCL.33.1.20180627.CTL
-rw-r----- 1 ora11204 oinstall 9.4M Jun 27 07:00 ORCL.35.1.20180627.CTL

RMAN> restore controlfile from '/u01/orabak/ORCL.656.1.20180626.CTL';

Starting restore at 2018-06-27 07:38:03
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/oradata/orcl/control01.ctl
output file name=/u01/oradata/orcl/control02.ctl
Finished restore at 2018-06-27 07:38:07

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORCL     1506513914       PARENT  1          2013-08-24 11:37:30
2       2       ORCL     1506513914       CURRENT 925702     2018-06-13 22:19:40

RMAN> 
RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> restore database until time '2018-06-26 09:00:00';
直接可以成功转储。
RMAN> recover database until time '2018-06-26 09:00:00';
直接可以成功恢复。
RMAN> alter database open resetlogs;

可以成功恢复。