备份恢复之数据文件丢失

一、实验环境

运行环境:

[root@localhost ~]# lsb_release -a

LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch

Distributor ID: RedHatEnterpriseServer

Description:    Red Hat Enterprise Linux Server release 5.4 (Tikanga)

Release:        5.4

Codename:       Tikanga

数据库版本:

SQL> select * from v$version;

 

BANNER

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

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

归档状态:

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

二、实验步骤

     1、对数据库进行一次全备

     2、将数据库文件任一删除一个(system表空间的数据文件或者undo表空间的数据文件)

    3、通过RMAN对进行恢复

 三、具体过程

1、查看数据文件

 

SQL>  select t.name tname,d.name dname from v$datafile d,v$tablespace t

  2   where t.ts#=d.ts#;

 

TNAME   DNAME

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

SYSTEM  /u01/app/oracle/oradata/lzcdb/system01.dbf

UNDOTBS /u01/app/oracle/oradata/lzcdb/undotbs01.dbf

1

 

SYSAUX  /u01/app/oracle/oradata/lzcdb/sysaux01.dbf

USERS   /u01/app/oracle/oradata/lzcdb/users01.dbf

LZCDB01 /u01/app/oracle/oradata/lzcdb/lzcdb0101

LZCDB01 /u01/app/oracle/oradata/lzcdb/lzcdb0102

2、将控制文件删除

SQL> !rm /u01/app/oracle/oradata/lzcdb/system01.dbf

SQL> !ls /u01/app/oracle/oradata/lzcdb/system01.dbf

ls: /u01/app/oracle/oradata/lzcdb/system01.dbf: No such file or directory

成功删除

3、在删除数据文件之后数据库有可能会直接挂掉,但由于我的实验数据库没有任何负载所以现在手动将其关闭

     (注意同时动态查看alert日子)

 

SQL> shutdown abort;

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              96470608 bytes

Database Buffers          184549376 bytes

Redo Buffers                2973696 bytes

Database mounted.

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

ORA-01110: data file 1: '/u01/app/oracle/oradata/lzcdb/system01.dbf'

在有mount状态启动到open状态是会出现如上错误,此时查看alert日志会看到如下信息

ALTER DATABASE OPEN

Thu Jun 14 17:25:03 2012

ORA-01110: data file 1: '/u01/app/oracle/oradata/lzcdb/system01.dbf'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

我们可以看到错误信息提示我们system01.dbf文件找不到

4、使用RMAN恢复

[oracle@localhost ~]$ rman target sys/oracle/lzcdb

 

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jun 14 17:28:33 2012

 

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

 

connected to target database: LZCDB (DBID=404353836, not open)

 

RMAN> list backup;

 

using target database control file instead of recovery catalog

 

List of Backup Sets

===================

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

3       Full    920.27M    DISK        00:01:58     14-JUN-12

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20120614T091107

        Piece Name: /u01/app/oracle/flash_recovery_area/03ndgj9b_1_1

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time  Name

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

  1       Full 682642     14-JUN-12 /u01/app/oracle/oradata/lzcdb/system01.dbf

  2       Full 682642     14-JUN-12 /u01/app/oracle/oradata/lzcdb/undotbs01.dbf

  3       Full 682642     14-JUN-12 /u01/app/oracle/oradata/lzcdb/sysaux01.dbf

  4       Full 682642     14-JUN-12 /u01/app/oracle/oradata/lzcdb/users01.dbf

可以看到我的实验库的备份信息如上

RMAN> restore datafile 1;          ------这儿我用的是system01.dbf文件号

RMAN> recover database;           

将数据库启动!

四、实验总结

 在实验的过程中遇到了一些小插曲,由于自己捣鼓的时候有部分归档日志被我删掉了却且没有其他备份。

所以当我执行

RMAN> recover database;   

恢复数据库时告诉我

 

RMAN-03002: failure of recover command at 06/14/2012 18:18:06

RMAN-06053: unable to perform. media recovery because of missing log

RMAN-06025: no backup of log thread 1 seq 36 lowscn 730729 found to restore

这样我就只能将整个数据库恢复到我上次的全备点了,这就造成了大量数据的丢失

所以体会就是归档日志不要随便删除,除非你已经确定它没有用了或者你有备份!

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

转载于:http://blog.itpub.net/26723566/viewspace-732848/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值