ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 无备份、归档模式下数据文件的恢复

无备份、归档模式下数据文件的恢复

原创 Linux操作系统 作者:FishExpert 时间:2012-09-05 14:23:40 0 删除 编辑

看到这个话题有些童鞋提出疑问了,是所有的数据文件都可以恢复吗?答案是:SYSTEM表空间对应的数据文件,无备份是无法恢复的;临时表空间对应的数据文件,丢就丢了,当不了再重新创建一个!只是适合普通表空间对应的数据文件的恢复哦。

下面就开始模拟数据文件损坏和恢复了:

一、 模拟故障场景:

1、 确认是否归档:

SYS@ocm10g>archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/product/10.2.0/db_1/dbs/arch

Oldest online log sequence     1

Next log sequence to archive   2

Current log sequence           2

2、 创建ocm10g表空间:

SYS@ocm10g>create tablespace ocm10g datafile '/u01/app/oracle/oradata/ocm10g/ocm10g_01.dbf' size 10m;

Tablespace created.

3、 创建测试用户(test)和测试表(test_10g):

SYS@ocm10g>create user test  identified by test default tablespace ocm10g;

User created.

SYS@ocm10g>grant resource ,connect to test;

Grant succeeded.

SYS@ocm10g>conn test/test

Connected.

TEST@ocm10g>create table test_10g ( id number ,name varchar2(10));

Table created.

TEST@ocm10g>insert into test_10g values ( 201201 ,'AA');

1 row created.

TEST@ocm10g>insert into test_10g values ( 201202,'BB');

1 row created.

TEST@ocm10g>commit;

Commit complete.

4、 模拟数据文件丢失:

SYS@ocm10g>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SYS@ocm10g>!

[oracle@rhel ~]$ cd $ORACLE_BASE/oradata/ocm10g

[oracle@rhel ocm10g]$ ls

control01.ctl  example01.dbf  redo02.log    system01.dbf   users01.dbf

control02.ctl  ocm10g_01.dbf  redo03.log    temp01.dbf

control03.ctl  redo01.log     sysaux01.dbf  undotbs01.dbf

[oracle@rhel ocm10g]$ rm ocm10g_01.dbf

[oracle@rhel ocm10g]$ exit

exit

SYS@ocm10g>startup

ORACLE instance started.

Total System Global Area  176160768 bytes

Fixed Size                  1218364 bytes

Variable Size              62916804 bytes

Database Buffers          109051904 bytes

Redo Buffers                2973696 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 6 - see DBWR trace file

ORA-01110: data file 6: '/u01/app/oracle/oradata/ocm10g/ocm10g_01.dbf'

童鞋们,没有备份下,如何恢复?别着急,咱稍微思考30秒,哈哈,不是还有创建数据文件ocm10g_01.dbf之初到现在的redo日志嘛,咳咳!

二、恢复故障:

SYS@ocm10g>alter  database create datafile '/u01/app/oracle/oradata/ocm10g/ocm10g_01.dbf';

Database altered.

SYS@ocm10g>recover datafile 6;

Media recovery complete.

SYS@ocm10g>alter database open;

Database altered.

6、查看是否有数据丢失

SYS@ocm10g>conn test/test

Connected.

TEST@ocm10g>select *from test_10g;

        ID NAME

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

    201201 AA

    201202 BB

                                                                                                            BY FishExpert

                                                                                                                    2012-9-4

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26857237/viewspace-742709/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-07-17

  • 博文量
    13
  • 访问量
    33708