本文主要介绍非归档模式下offline数据文件的恢复,测试过程如下:

SQL> select * from v$version where rownum<3;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/prod_arch
Oldest online log sequence     17
Current log sequence           19

---控件文件中的SCN
SQL> select file#,status,checkpoint_change# from v$datafile order by 1;

FILE# STATUS  CHECKPOINT_CHANGE#
---------- ------- ------------------
         1 SYSTEM              554606
         2 ONLINE              554606
         3 ONLINE              554606
         4 ONLINE              554606
         5 ONLINE              554606

--数据文件头中的SCN

SQL> select file#,status,checkpoint_change# from v$datafile_header order by 1;

FILE# STATUS  CHECKPOINT_CHANGE#
---------- ------- ------------------
         1 ONLINE              554606
         2 ONLINE              554606
         3 ONLINE              554606
         4 ONLINE              554606
         5 ONLINE              554606

--日志文件的情况

SQL> select * from v$Log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC   STATUS           FIRST_CHANGE#    FIRST_TIM
     ----------        ----------      ----------              ----------      ----------       ---    ----------------            -------------                  ---------
         1                    1             19                  52428800          1         NO     CURRENT                 543593            29-OCT-13
         2                    1             17                  52428800          1        YES     INACTIVE                500547             29-OCT-13
         3                    1             18                  52428800          1        YES     INACTIVE                521183             29-OCT-13

--offline数据文件5,在为进行日志切换的i情况下直接rcover然后在online就可以恢复。

SQL> alter database datafile 5 offline drop;

Database altered.

SQL> alter database datafile 5 online;
alter database datafile 5 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery if it was restored from backup, or END BACKUP if it was not
ORA-01110: data file 5: '/u01/app/oracle/oradata/ptod/zxy01.dbf'

SQL> recover datafile 5;
Media recovery complete.
SQL> alter database datafile 5 online;

Database altered.

二、在日志被覆盖的情况下:

SQL> alter system switch logfile;

System altered.

SQL> select file#,checkpoint_change# from v$datafile;

FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1             554973
         2             554973
         3             554973
         4             554973
         5             554973

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES       MEMBERS     ARC     STATUS        FIRST_CHANGE#     FIRST_TIM
     ----------         ----------          ----------          ----------         ----------         ---      ----------------           -------------                   ---------
         1                    1                  22              52428800          1               NO     INACTIVE                554969               30-OCT-13
         2                    1                  23              52428800          1               NO     INACTIVE                554971               30-OCT-13
         3                    1                  24              52428800          1               NO     CURRENT               554973               30-OCT-13

SQL> alter database datafile 5 offline drop;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS     ARC      STATUS           FIRST_CHANGE#      FIRST_TIM
     ----------        ----------          ----------           ----------      ----------          ---       ----------------             -------------                    ---------
         1                    1                  28             52428800          1              NO      CURRENT               555067                  30-OCT-13
         2                    1                  26             52428800          1              NO      INACTIVE                555052                  30-OCT-13
         3                    1                  27             52428800          1              NO      INACTIVE                555055                  30-OCT-13

SQL> alter database datafile 5 online;
alter database datafile 5 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery if it was restored from backup, or END BACKUP if it was not
ORA-01110: data file 5: '/u01/app/oracle/oradata/ptod/zxy01.dbf'

SQL> recover datafile 5;
ORA-00279: change 554973 generated at 10/30/2013 23:28:26 needed for thread 1
ORA-00289: suggestion : /u01/prod_arch/1_24_829999096.dbf
ORA-00280: change 554973 for thread 1 is in sequence #24

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.

SQL> alter database datafile 5 online;
alter database datafile 5 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery if it was restored from backup, or END BACKUP if it was not
ORA-01110: data file 5: '/u01/app/oracle/oradata/ptod/zxy01.dbf'

---下面用bbed来检查点信息:

BBED> info
 File#  Name                                                        Size(blks)
 -----  ----                                                        ----------
     1  /u01/app/oracle/oradata/ptod/system01.dbf                            0
     2  /u01/app/oracle/oradata/ptod/undotbs03.dbf                           0
     3  /u01/app/oracle/oradata/ptod/sysaux01.dbf                            0
     4  /u01/app/oracle/oradata/ptod/users01.dbf                             0
     5  /u01/app/oracle/oradata/ptod/zxy01.dbf                               0

BBED> set file 5 block 1
        FILE#           5
        BLOCK#          1

BBED> p kcvfhckp
struct kcvfhckp, 36 bytes                   @484    
   struct kcvcpscn, 8 bytes                 @484    
      ub4 kscnbas                           @484      0x000877dd---数据文件头的SCN低4字节值
      ub2 kscnwrp                           @488      0x0000
   ub4 kcvcptim                             @492      0x317c161a
   ub2 kcvcpthr                             @496      0x0001
   union u, 12 bytes                        @500    
      struct kcvcprba, 12 bytes             @500    
         ub4 kcrbaseq                       @500      0x00000018---数据文件当前写的redolog sequence。
         ub4 kcrbabno                       @504      0x00000002---数据文件当前写的redolog的block号
         ub2 kcrbabof                       @508      0x0010
   ub1 kcvcpetb[0]                          @512      0x02
   ub1 kcvcpetb[1]                          @513      0x00
   ub1 kcvcpetb[2]                          @514      0x00
   ub1 kcvcpetb[3]                          @515      0x00
   ub1 kcvcpetb[4]                          @516      0x00
   ub1 kcvcpetb[5]                          @517      0x00
   ub1 kcvcpetb[6]                          @518      0x00
   ub1 kcvcpetb[7]                          @519      0x00

因此我只需要把红色部分的信息改成与正常的数据文件的值一样,骗过oracle的检测。

BBED> set file 4 blcok 1
        FILE#           4
BBED-00202: invalid parameter (blcok)

BBED> set file 4 block 1
        FILE#           4
        BLOCK#          1

BBED> p kcvfhckp
struct kcvfhckp, 36 bytes                   @484    
   struct kcvcpscn, 8 bytes                 @484    
      ub4 kscnbas                           @484      0x0008783b
      ub2 kscnwrp                           @488      0x0000
   ub4 kcvcptim                             @492      0x317c1711
   ub2 kcvcpthr                             @496      0x0001
   union u, 12 bytes                        @500    
      struct kcvcprba, 12 bytes             @500    
         ub4 kcrbaseq                       @500      0x0000001c
         ub4 kcrbabno                       @504      0x00000002
         ub2 kcrbabof                       @508      0x0010
   ub1 kcvcpetb[0]                          @512      0x02
   ub1 kcvcpetb[1]                          @513      0x00
   ub1 kcvcpetb[2]                          @514      0x00
   ub1 kcvcpetb[3]                          @515      0x00
   ub1 kcvcpetb[4]                          @516      0x00
   ub1 kcvcpetb[5]                          @517      0x00
   ub1 kcvcpetb[6]                          @518      0x00
   ub1 kcvcpetb[7]                          @519      0x00

BBED> d /v offset 484 count 16
 File: /u01/app/oracle/oradata/ptod/users01.dbf (4)
 Block: 1       Offsets:  484 to  499  Dba:0x01000001
-------------------------------------------------------
 3b780800 0000af76 11177c31 01008e00 l ;x....|1....

<16 bytes per line>

BBED> set file 5 block 1
        FILE#           5
        BLOCK#          1

BBED> modify /x 3b7808 offset 484
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
 File: /u01/app/oracle/oradata/ptod/zxy01.dbf (5)
 Block: 1                Offsets:  484 to  499           Dba:0x01400001
------------------------------------------------------------------------
 3b780800 0000af76 1a167c31 01008e00

<32 bytes per line>

BBED> d /v offset 484 count 16
 File: /u01/app/oracle/oradata/ptod/zxy01.dbf (5)
 Block: 1       Offsets:  484 to  499  Dba:0x01400001
-------------------------------------------------------
 3b780800 0000af76 1a167c31 01008e00 l ;x....|1....

<16 bytes per line>

BBED> modify /x 18 offset 500
 File: /u01/app/oracle/oradata/ptod/zxy01.dbf (5)
 Block: 1                Offsets:  500 to  515           Dba:0x01400001
------------------------------------------------------------------------
 18000000 02000000 10000000 02000000

<32 bytes per line>

BBED> sum apply
Check value for File 5, Block 1:
current = 0x9989, required = 0x9989

BBED> exit

----在查看SCN的情况,试着recover

SQL> select file#,checkpoint_change# from v$datafile;

FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1             555687
         2             555687
         3             555687
         4             555687
         5             554973

SQL> select file#,checkpoint_change# from v$datafile_header;

FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1             555687
         2             555687
         3             555687
         4             555687
         5             555067

SQL> alter database datafile 5 online;
alter database datafile 5 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery if it was restored from backup, or END BACKUP if it was not
ORA-01110: data file 5: '/u01/app/oracle/oradata/ptod/zxy01.dbf'

SQL> recover datafile 5;
Media recovery complete.
SQL> alter database datafile 5 online;

Database altered.

成功online数据文件5!

非归档数据文件offline的恢复的更多相关文章

  1. 表空间与数据文件Offline,online的区别

    首先明确,表空间与数据文件的关系:Oracle数据库表空间有两种,一种smallfile小文件表空间(默认),另一种bigfile大文件表空间: 默认表空间与数据文件的关系:允许一对多的处理方式,一个 ...

  2. 非系统数据文件损坏,rman备份恢复

    实验前提:已经做好备份. SQL> col file_name for a50select file_id,file_name from dba_data_files; FILE_ID FILE ...

  3. linux删除数据文件无备份恢复

    参考 : http://www.lunar2013.com/2013/06/linux-%E8%AF%AF%E5%88%A0%E9%99%A4%E6%96%87%E4%BB%B6%E6%81%A2%E ...

  4. 数据文件offline 时oracle 干了那些事?

    SQL> oradebug setmypid Statement processed. SQL> oradebug unlimit Statement processed. SQL> ...

  5. 1、通过CP数据文件的方式恢复MySQL 从库 启动后报错:Last_IO_Errno: 1236:A slave with the same server_uuid/server_id as this slave has connected to the master;

    1.问题: MySQL从库中查看主从状态: show slave status\G,发现出现IO的报错: Last_IO_Errno: Last_IO_Error: Got fatal error f ...

  6. rman数据库恢复;关键/非重要文件、影像副本、控制文件、还原点、非归档、增量、新数据库、灾难性回复

    运行全然恢复:在 ARCHIVELOG 模式下 丢失了系统重要数据文件: 假设某个数据文件丢失或损坏.且该文件属于 SYSTEM 或 UNDO 表空间,请运行下面步骤: 1. 实例可能会也可能不会自己 ...

  7. 测试Oracle 11gr2 RAC 非归档模式下,offline drop数据文件后的数据库的停止与启动测试全过程

    测试Oracle 11gr2 RAC 非归档模式下,offline drop数据文件后的数据库的停止与启动测试全过程 最近系统出现问题,由于数据库产生的日志量太大无法开启归档模式,导致offline的 ...

  8. 【Oracle】非RMAN恢复数据文件、控制文件

    实验环境:OEL 5.6 oracle 11g(11.2.0.4.0) 注意: system表空间数据文件不能在线recover,需要启动到mount状态再recover: undo表空间数据文件可以 ...

  9. 05 使用bbed跳过归档恢复数据文件

    5 使用BBED跳过归档 在归档模式下,缺失了一部分的归档日志文件,对数据文件进行恢复 1 开启归档 --shutdown immediate --startup mount --alter data ...

随机推荐

  1. HTTP缓存了解(一)

    引言 HTTP/1.1 200 OK X-Powered-By: Express Content-Type: text/html; charset=utf-8 Content-Length: 3 ET ...

  2. 洛谷P2147 [SDOI2008] 洞穴勘探 [LCT]

    题目传送门 洞穴勘探 题目描述 辉辉热衷于洞穴勘测. 某天,他按照地图来到了一片被标记为JSZX的洞穴群地区.经过初步勘测,辉辉发现这片区域由n个洞穴(分别编号为1到n)以及若干通道组成,并且每条通道 ...

  3. Web API 自定义文件内容的定制类

    public class FileContent : HttpContent { private readonly Stream _stream; public FileContent(string ...

  4. 应用服务攻击工具clusterd

    应用服务攻击工具clusterd   clusterd是一款Python语言编写的开源应用服务攻击工具.该工具支持七种不同的应用服务平台,如JBoss.ColdFusion.WebLogic.Tomc ...

  5. 搭建samba 共享openstack开发环境

    centos7.2 openstack环境为allinone 模式,这样跑代码好处理 安装smb [root@controller ~]# yum install -y samba samba-cli ...

  6. Python并发编程-进程

    由于GIL(全局解释锁)的问题,多线程并不能充分利用多核处理器,如果是一个CPU计算型的任务,应该使用多进程模块 multiprocessing .它的工作方式与线程库完全不同,但是两种库的语法和接口 ...

  7. java8新特性——并行流与顺序流

    在我们开发过程中,我们都知道想要提高程序效率,我们可以启用多线程去并行处理,而java8中对数据处理也提供了它得并行方法,今天就来简单学习一下java8中得并行流与顺序流. 并行流就是把一个内容分成多 ...

  8. 【BZOJ 3160】 3160: 万径人踪灭 (FFT)

    3160: 万径人踪灭 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 1440  Solved: 799 Description Input Outp ...

  9. 温故而知新---Java(一)

    学习不仅要学习新的东西,而且还要时不时的回过头捡漏... 本文参考老马说编程系列等文,在此推荐大家关注老马说编程系列文章 正文 基础知识 数据类型主要是为了对数据进行分类,方便理解和操作,在Java中 ...

  10. jquery加载解析XML文件

    xml文件 <?xml version="1.0" encoding="utf-8" ?> <taxrates> <taxrate ...