rman恢复未备份的数据文件

来源:互联网 发布:志鸿优化系列丛书2017 编辑:程序博客网 时间:2024/05/29 01:52
本文描述:模拟未备份的数据文件丢失并恢复的过程。
试验过程:
注:试验前先将数据库全备或者0级备份
全备:backup database format 'g:\rmanbak\db_%d_%T_%s.bak' plus archivelog format 'g:\rmanbak\arch_%d_%T_%s.bak';
0级备份:backup incremental level 0  database format 'g:\rmanbak\db_%d_%T_%s.bak' plus archivelog format 'g:\rmanbak\arch_%d_%T_%s.bak';

(1)创建表空间tt,并用Scott账户在tt上创建表t
C:\Users\Administrator>sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on 星期三 6月 14 14:58:11 2017Copyright (c) 1982, 2010, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> create tablespace tt datafile 'f:\oradata\tt01.dbf' size 10m;Tablespace created.SQL> conn scott/tigerConnected.SQL> create table t tablespace tt as select * from emp;Table created.SSQL> --删除表空间ttSQL> conn / as sysdbaConnected.SQL> alter system flush buffer_cache;System altered.SQL> alter system flush shared_pool;System altered.SQL> conn scott/tigerConnected.SQL> select * from  t;select * from  t               *ERROR at line 1:ORA-00376: 此时无法读取文件 12ORA-01110: 数据文件 12: 'F:\ORADATA\TT01.DBF'SQL>
(2)登录ramn进行恢复
C:\Users\Administrator>rman target /Recovery Manager: Release 11.2.0.1.0 - Production on 星期三 6月 14 15:11:55 2017Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.connected to target database: ORCL (DBID=1468451227)RMAN> run{2> sql 'alter database datafile 12 offline';3> restore datafile 12;4> recover datafile 12;5> sql 'alter database datafile 12 online';6> }using target database control file instead of recovery catalogsql statement: alter database datafile 12 offlineStarting restore at 14-6月 -17allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=134 device type=DISK--以往备份文件中并不包含此数据文件,restore时,rman先创建此文件(空的),然后再根据各种日志文件把数据恢复过来creating datafile file number=12 name=F:\ORADATA\TT01.DBFrestore not done; all files read only, offline, or already restoredFinished restore at 14-6月 -17Starting recover at 14-6月 -17using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 14-6月 -17sql statement: alter database datafile 12 onlineRMAN>
(3)登录sqlplus,数据成功恢复
SQL> conn scott/tigerConnected.SQL> select * from tab where tname='T';TNAME                          TABTYPE  CLUSTERID------------------------------ ------- ----------T                              TABLESQL>
恢复成功!
阅读全文
0 0
原创粉丝点击