Oracle RMAN 完全恢复(一)

2014-11-24 18:02:27 · 作者: · 浏览: 2

Objective


l Describe the use of RMAN for restoration and recovery


l Perform complete recovery in ARCHIVELOG mode


l Restore datafiles to different locations


l Relocate and recover a tablespace by using archived redo log files




Restoration Using RMAN


l Restore files from backup sets or image copies by using the RMAN RESTORE command


l Recover files by using the RMAN RECOVER command




Using RMAN in ARCHIVELOG


rman target /


RMAN> STARTUP MOUNT


RMAN> RESTORE DATABASE;


RMAN> RECOVER DATABASE;


RMAN> ALTER DATABASE OPEN;




下面开始实验:



实验环境:




$ rman target sys/oracle@orcl nocatalog



Recovery Manager: Release 11.2.0.1.0 - Production on Thu Apr 14 09:03:20 2011



Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.



connected to target database: ORCL (DBID=1276064171)


using target database control file instead of recovery catalog



RMAN> list backup;



specification does not match any backup in the repository



RMAN> backup database format '/u02/backup/orcl_%U'; --准备一个全备



Starting backup at 14-APR-11


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=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf


input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf


input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf


input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf


input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/app01.dbf


input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf


channel ORA_DISK_1: starting piece 1 at 13-APR-11


channel ORA_DISK_1: finished piece 1 at 13-APR-11


piece handle=/u02/backup/orcl_04m9mqh3_1_1 tag=TAG20110413T200555 comment=NONE


channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07


Finished backup at 14-APR-11



Starting Control File and SPFILE Autobackup at 14-APR-11


piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_13/o1_mf_s_748382762_6tdl3tk7_.bkp comment=NONE


Finished Control File and SPFILE Autobackup at 14-APR-11




由于是热备,所以备份的过程中联机日志文件有可能发生变化,所以我们还需要备份一下当前的联机重做日志文件。



RMAN> sql 'alter system archive log current'; --归档当前联机重做日志文件(REDO LOG



sql statement: alter system archive log current



RMAN> list backup;




List of Backup Sets


===================




BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------


3 Full 1.06G DISK 00:00:05 13-APR-11


BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20110413T200555


Piece Name: /u02/backup/orcl_04m9mqh3_1_1


List of Datafiles in backup set 3


File LV Type Ckp SCN Ckp Time Name


---- -- ---- ---------- --------- ----


1 Full 1224029 13-APR-11 /u01/app/oracle/oradata/orcl/system01.dbf


2 Full 1224029 13-APR-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf


3 Full 1224029 13-APR-11 /u01/app/oracle/oradata/or