RMAN完全恢复案例(三)


案例3:

--表空间数据文件全部丢失,恢复数据文件(open)


1)测试环境

07:37:23 SQL> insert into scott.test values (6);

1 row created.

07:39:18 SQL> insert into scott.test values (7);

1 row created.

07:39:20 SQL> insert into scott.test values (8);

1 row created.

07:39:21 SQL> commit;

Commit complete.

07:39:23 SQL> select * from scott.test;

ID

----------

6

7

8

1

2

3

4

5

8 rows selected.

07:40:06 SQL>

----在open 状态下datafile 被破坏

[oracle@work ~]$ rm /u01/app/oracle/oradata/prod/test0*.dbf

[oracle@work ~]$

07:41:19 SQL> alter system flush buffer_cache;

System altered.

07:41:25 SQL> conn scott/tiger

Connected.

07:41:28 SQL>

07:41:28 SQL> insert into scott.test values (10);

insert into scott.test values (10)

*

ERROR at line 1:

ORA-01116: error in opening database file 8

ORA-01110: data file 8: '/u01/app/oracle/oradata/prod/test02.dbf'

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3

07:41:31 SQL>


2)利用rman 恢复

RMAN> run {

2> sql 'alter database datafile 6,8 offline';

3> restore datafile 6,8;

4> recover datafile 6,8;

5> sql 'alter database datafile 6,8 online';

6> }



3)验证

07:41:31 SQL> insert into scott.test values (10);

1 row created.

07:45:58 SQL> commit;

Commit complete.

07:46:01 SQL> select * from test;

ID

----------

10

6

7

8

9

1

2

3

4

5

10 rows selected.

07:46:04 SQL>


oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html