1.备份数据库
RMAN> backup database plus archivelog;
Starting backup at 24-DEC-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=24 RECID=473 STAMP=899281739
input archived log thread=1 sequence=25 RECID=474 STAMP=899281848
input archived log thread=1 sequence=26 RECID=475 STAMP=899282024
channel ORA_DISK_1: starting piece 1 at 24-DEC-15
channel ORA_DISK_1: finished piece 1 at 24-DEC-15
piece handle=/u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_annnn_TAG20151224T083344_c7phc91t_.bkp tag=TAG20151224T083344 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 24-DEC-15
Starting backup at 24-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/oradata/orcl/system01.dbf
input datafile file number=00006 name=/oradata/orcl/undotbs02.dbf
input datafile file number=00005 name=/oradata/orcl/tom01.dbf
input datafile file number=00003 name=/oradata/orcl/test01.dbf
input datafile file number=00011 name=/oradata/orcl/assm01.dbf
input datafile file number=00004 name=/oradata/orcl/users01.dbf
input datafile file number=00007 name=/oradata/orcl/tbspart01.dbf
input datafile file number=00008 name=/oradata/orcl/tbspart02.dbf
input datafile file number=00009 name=/oradata/orcl/tbspart03.dbf
input datafile file number=00012 name=/oradata/orcl/tbspart04.dbf
input datafile file number=00013 name=/oradata/orcl/rman01.dbf
input datafile file number=00014 name=/oradata/orcl/test1.dbf
input datafile file number=00015 name=/oradata/orcl/test2.dbf
input datafile file number=00016 name=/oradata/orcl/linktbs01.dbf
input datafile file number=00010 name=/oradata/orcl/tom09.dbf
channel ORA_DISK_1: starting piece 1 at 24-DEC-15
channel ORA_DISK_1: finished piece 1 at 24-DEC-15
piece handle=/u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_nnndf_TAG20151224T083346_c7phcbq3_.bkp tag=TAG20151224T083346 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 24-DEC-15
Starting backup at 24-DEC-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=476 STAMP=899282072
channel ORA_DISK_1: starting piece 1 at 24-DEC-15
channel ORA_DISK_1: finished piece 1 at 24-DEC-15
piece handle=/u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_annnn_TAG20151224T083432_c7phdrcf_.bkp tag=TAG20151224T083432 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-DEC-15
Starting Control File and SPFILE Autobackup at 24-DEC-15
piece handle=/u2/oracle/fast_recovery_area/ORCL/autobackup/2015_12_24/o1_mf_s_899282073_c7phdsrq_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 24-DEC-15
2.查看对应物
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORCL 1414106639 PARENT 1 17-SEP-11
2 2 ORCL 1414106639 PARENT 995548 29-JUL-15
3 3 ORCL 1414106639 PARENT 81596990663 18-DEC-15
4 4 ORCL 1414106639 PARENT 81596993344 18-DEC-15
5 5 ORCL 1414106639 PARENT 81597043948 19-DEC-15
6 6 ORCL 1414106639 CURRENT 81597059029 19-DEC-15
3.关闭数据库,删除数据文件,然后使用备份恢复数据库。
3.1关闭数据库
RMAN> shutdown immediate;
database closed
database dismounted
Oracle instance shut down
3.2.删除数据文件:
[oracle@CS-SI-DG01 orcl]$ cd /oradata/
[oracle@CS-SI-DG01 oradata]$ ls
arch backup matrix ogg orcl orcl1 rman
[oracle@CS-SI-DG01 oradata]$ cd orcl
orcl/ orcl1/
[oracle@CS-SI-DG01 oradata]$ cd orcl
[oracle@CS-SI-DG01 orcl]$ ls
assm01.dbf redo01.log sysaux01.dbf tbspart03.dbf test1.dbf undotbs02.dbf
control01.ctl redo02.log system01.dbf tbspart04.dbf test2.dbf users01.dbf
control02.ctl redo03.log tbspart01.dbf temp01.dbf tom01.dbf
linktbs01.dbf rman01.dbf tbspart02.dbf test01.dbf tom09.dbf
[oracle@CS-SI-DG01 orcl]$ rm *
[oracle@CS-SI-DG01 orcl]$
3.3.启动数据库到mount状态:
RMAN> startup nomount;
Oracle instance started
Total System Global Area 509411328 bytes
Fixed Size 2229824 bytes
Variable Size 385878464 bytes
Database Buffers 113246208 bytes
Redo Buffers 8056832 bytes
3.4.从之前的备份中恢复控制文件:
RMAN> restore controlfile from '/u2/oracle/fast_recovery_area/ORCL/autobackup/2015_12_24/o1_mf_s_899282073_c7phdsrq_.bkp';
Starting restore at 24-DEC-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/orcl/control01.ctl
output file name=/oradata/orcl/control02.ctl
Finished restore at 24-DEC-15
3.5.将数据启动到mount状态:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
3.6.还原数据库:
RMAN> restore database;
Starting restore at 24-DEC-15
Starting implicit crosscheck backup at 24-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 24-DEC-15
Starting implicit crosscheck copy at 24-DEC-15
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 24-DEC-15
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u2/oracle/fast_recovery_area/ORCL/autobackup/2015_12_24/o1_mf_s_899282073_c7phdsrq_.bkp
using channel ORA_DISK_1
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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/orcl/test01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /oradata/orcl/tom01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /oradata/orcl/undotbs02.dbf
channel ORA_DISK_1: restoring datafile 00007 to /oradata/orcl/tbspart01.dbf
channel ORA_DISK_1: restoring datafile 00008 to /oradata/orcl/tbspart02.dbf
channel ORA_DISK_1: restoring datafile 00009 to /oradata/orcl/tbspart03.dbf
channel ORA_DISK_1: restoring datafile 00010 to /oradata/orcl/tom09.dbf
channel ORA_DISK_1: restoring datafile 00011 to /oradata/orcl/assm01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /oradata/orcl/tbspart04.dbf
channel ORA_DISK_1: restoring datafile 00013 to /oradata/orcl/rman01.dbf
channel ORA_DISK_1: restoring datafile 00014 to /oradata/orcl/test1.dbf
channel ORA_DISK_1: restoring datafile 00015 to /oradata/orcl/test2.dbf
channel ORA_DISK_1: restoring datafile 00016 to /oradata/orcl/linktbs01.dbf
channel ORA_DISK_1: reading from backup piece /u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_nnndf_TAG20151224T083346_c7phcbq3_.bkp
channel ORA_DISK_1: piece handle=/u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_nnndf_TAG20151224T083346_c7phcbq3_.bkp tag=TAG20151224T083346
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 24-DEC-15
3.6.恢复数据库:
[oracle@CS-SI-DG01 orcl]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Dec 24 09:34:03 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 81597400320 generated at 12/24/2015 08:34:31 needed for
thread 1
ORA-00289: suggestion : /oradata/arch/orcl/1_28_898869075.dbf
ORA-00280: change 81597400320 for thread 1 is in sequence #28
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL>
3.7.resetlogs方式打开数据库:
RMAN> alter database open resetlogs;
database opened
3.8.查看对应物(此时相比之前又产生了一个对应物):
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORCL 1414106639 PARENT 1 17-SEP-11
2 2 ORCL 1414106639 PARENT 995548 29-JUL-15
3 3 ORCL 1414106639 PARENT 81596990663 18-DEC-15
4 4 ORCL 1414106639 PARENT 81596993344 18-DEC-15
5 5 ORCL 1414106639 PARENT 81597043948 19-DEC-15
6 6 ORCL 1414106639 PARENT 81597059029 19-DEC-15
7 7 ORCL 1414106639 CURRENT 81597400321 24-DEC-15
4.恢复对应物6:
4.1.关闭数据,然后启动到mount状态:
[oracle@CS-SI-DG01 ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Dec 24 09:40:33 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1414106639)
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 509411328 bytes
Fixed Size 2229824 bytes
Variable Size 385878464 bytes
Database Buffers 113246208 bytes
Redo Buffers 8056832 bytes
4.2.复位对应为6:
RMAN> reset database to incarnation 6;
database reset to incarnation 6
4.3.还原数据:
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORCL 1414106639 PARENT 1 17-SEP-11
2 2 ORCL 1414106639 PARENT 995548 29-JUL-15
3 3 ORCL 1414106639 PARENT 81596990663 18-DEC-15
4 4 ORCL 1414106639 PARENT 81596993344 18-DEC-15
5 5 ORCL 1414106639 PARENT 81597043948 19-DEC-15
6 6 ORCL 1414106639 CURRENT 81597059029 19-DEC-15
7 7 ORCL 1414106639 ORPHAN 81597400321 24-DEC-15
RMAN> restore database until scn 81597400320;
Starting restore at 24-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/orcl/test01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /oradata/orcl/tom01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /oradata/orcl/undotbs02.dbf
channel ORA_DISK_1: restoring datafile 00007 to /oradata/orcl/tbspart01.dbf
channel ORA_DISK_1: restoring datafile 00008 to /oradata/orcl/tbspart02.dbf
channel ORA_DISK_1: restoring datafile 00009 to /oradata/orcl/tbspart03.dbf
channel ORA_DISK_1: restoring datafile 00010 to /oradata/orcl/tom09.dbf
channel ORA_DISK_1: restoring datafile 00011 to /oradata/orcl/assm01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /oradata/orcl/tbspart04.dbf
channel ORA_DISK_1: restoring datafile 00013 to /oradata/orcl/rman01.dbf
channel ORA_DISK_1: restoring datafile 00014 to /oradata/orcl/test1.dbf
channel ORA_DISK_1: restoring datafile 00015 to /oradata/orcl/test2.dbf
channel ORA_DISK_1: restoring datafile 00016 to /oradata/orcl/linktbs01.dbf
channel ORA_DISK_1: reading from backup piece /u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_nnndf_TAG20151224T083346_c7phcbq3_.bkp
channel ORA_DISK_1: piece handle=/u2/oracle/fast_recovery_area/ORCL/backupset/2015_12_24/o1_mf_nnndf_TAG20151224T083346_c7phcbq3_.bkp tag=TAG20151224T083346
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 24-DEC-15
4.4.恢复数据库:
RMAN> recover database until scn 81597400320;
Starting recover at 24-DEC-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 27 is already on disk as file /oradata/arch/orcl/1_27_898869075.dbf
archived log file name=/oradata/arch/orcl/1_27_898869075.dbf thread=1 sequence=27
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-DEC-15
4.5.resetlogs打开数据库:
RMAN> alter database open resetlogs;
database opened
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORCL 1414106639 PARENT 1 17-SEP-11
2 2 ORCL 1414106639 PARENT 995548 29-JUL-15
3 3 ORCL 1414106639 PARENT 81596990663 18-DEC-15
4 4 ORCL 1414106639 PARENT 81596993344 18-DEC-15
5 5 ORCL 1414106639 PARENT 81597043948 19-DEC-15
6 6 ORCL 1414106639 PARENT 81597059029 19-DEC-15
7 7 ORCL 1414106639 ORPHAN 81597400321 24-DEC-15
8 8 ORCL 1414106639 CURRENT 81597400321 24-DEC-15