rman恢复未备份的数据文件

本文描述:模拟未备份的数据文件丢失并恢复的过程。
试验过程:
注:试验前先将数据库全备或者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 sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 6月 14 14:58:11 2017

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create tablespace tt datafile 'f:\oradata\tt01.dbf' size 10m;

Tablespace created.

SQL> conn scott/tiger
Connected.
SQL> create table t tablespace tt as select * from emp;

Table created.

SSQL> --删除表空间tt
SQL> conn / as sysdba
Connected.
SQL> alter system flush buffer_cache;

System altered.

SQL> alter system flush shared_pool;

System altered.
SQL> conn scott/tiger
Connected.
SQL> select * from  t;
select * from  t
               *
ERROR at line 1:
ORA-00376: 此时无法读取文件 12
ORA-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 2017

Copyright (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 catalog
sql statement: alter database datafile 12 offline

Starting restore at 14-6月 -17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
--以往备份文件中并不包含此数据文件,restore时,rman先创建此文件(空的),然后再根据各种日志文件把数据恢复过来
creating datafile file number=12 name=F:\ORADATA\TT01.DBF
restore not done; all files read only, offline, or already restored
Finished restore at 14-6月 -17

Starting recover at 14-6月 -17
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 14-6月 -17

sql statement: alter database datafile 12 online

RMAN>
(3)登录sqlplus,数据成功恢复
SQL> conn scott/tiger
Connected.
SQL> select * from tab where tname='T';

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
T                              TABLE

SQL>
恢复成功!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sky@sea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值