rman恢复实践

1) Loss of system DATAFILE
2) Loss of non-system DATAFILE
3) Loss of a DATAFILE without Backup
4) Loss of a CONTROLFILE
5) Loss of all the CONTROLFILE
6) Loss of REDOLOGs
7) Loss of CONTROLFILE, SPFILE, DATAFILEs and REDOLOGs
8) Loss of Tempfile
9) Block corruption of datafiles

1) Loss of system DATAFILE
rm -rf /u01/app/oracle/oradata/PROD1/system01.dbf
$rman target /
rman>validate database;
rman>shutdown abort
rman>startup mount
rman>restore datafile 1;
rman>recover datailfe 1;
rman>alter database open;
rman>validate database;
 
2) Loss of non-system DATAFILE
$rman target /
rman>validate database;
rman>list failure;
rman>advise failure;
rman>repair failure preview;
rman>repair failure;
rman>validate database;
 
3) Loss of a DATAFILE without Backup
$rman target /
rman>validate database;
rman>list failure;
rman>advise failure;
rman>repair failure preview;
rman>repair failure;
rman>validate database;
 
4) Loss of a CONTROLFILE
rm -rf /u01/app/oracle/oradata/PROD1/control01.ctl
sql>shutdown immediate
cp -r /u01/app/oracle/fast_recovery_area/PROD1/control02.ctl /u01/app/oracle/oradata/PROD1/control01.ctl 
sql>startup nomount
sql>alter system set control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl' scope=spfile;
sql>startup force
sql>select name from v$instance;
 
5) Loss of all the CONTROLFILE

rm /u01/app/oracle/oradata/PROD1/control01.ctl

rm /u01/app/oracle/fast_recovery_area/PROD1/control02.ctl

alter system switch logfile;
shutdown abort
-- Run the following script from RMAN
sqlplus rman/rman@emrep
SQL> select * from rc_database; --获取该 DB 的 dbid(例如: 1583199105)
rman target / catalog rman/rman@emrep
RMAN> set dbid = 1583199105;
RMAN> startup nomount;
RMAN> restore controlfile from autobackup;
RMAN> sql 'alter database mount';
RMAN> restore database;
RMAN> recover database;
RMAN> sql 'alter database open resetlogs';
new incarnation of database registered in recovery catalog
RMAN> list incarnation;
 
6) Loss of REDOLOGs

shutdown immediate;

startup

sqlplus / as sysdba
startup mount;
-- Clear all the redo logfiles
alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 2;
alter database clear unarchived logfile gorup 3;
alter database open;
 
7) Loss of CONTROLFILE, SPFILE, DATAFILEs and REDOLOGs
shutdown abort
sqlplus rman/rman@emrep
select * from rc_database;
RMAN>SET DBID=*****
RMAN>STARTUP NOMOUNT
 
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=4G;
ALTER  SYSTEM  SET  DB_RECOVERY_FILE_DEST='/u01/app/oracle/fast_recovery_area'; 
 
RMAN>RESTORE SPFILE FROM AUTOBACKUP;
RMAN>SHUTDOWN IMMEDIATE
RMAN>STARTUP NOMOUNT
RMAN>RESTORE CONTROLFILE FROM AUTOBACKUP;
RMAN>ALTER DATABASE MOUNT;
 
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select thread#, resetlogs_change#, archived, sequence#, completion_time from v$archived_log
where archived='YES' AND COMPLETION_TIME = (SELECT MAX(COMPLETION_TIME)
FROM V$ARCHIVED_LOG WHERE ARCHIVED='YES');
 

-- In RMAN, recovered until the last ARCHIVE LOG (n+1) and open with RESETLOGS

-- If the last created archived redo log has sequence n,

-- then specify UNTIL SEQUENCE n+1 so that RMAN applies n and then stops.

 
restore database until sequence 3 thread 1;
recover database until sequence 3 thread 1;
alter database open resetlogs;
 
8) Loss of Tempfile
sql>shutdown immediate
sql>startup
oracle 11g丢失临时表空间文件,重启后会自动创建临时表空间文件
 
9) Block corruption of datafiles
$rman target / catalog rman/rman@emrep
RMAN> list failure;
RMAN> advise failure;
RMAN> repair failure;
-- Check the result
RMAN> list failure all;

posted @ 2019-01-16 17:01  orcl  阅读(353)  评论(0编辑  收藏  举报