背景:

         同事误删除线上数据。所以须要从备份中找回数据恢复。

真实屋漏偏逢连夜雨、船迟又遇打头风。前两天备份的磁盘坏块,如今仅仅有rman全备的.bak文件,没有控制文件和參数文件,所以如今须要考虑的是怎样依据bak文件在备份数据库上恢复数据,从中找出被误删的数据。

1 通过catalog start with’’的方式来恢复

1.1手动创建控制文件

CREATE CONTROLFILE REUSE set DATABASE"powerdes" RESETLOGS ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 454

DATAFILE

'/home/oradata/powerdes/system01.dbf',

'/home/oradata/powerdes/sysaux01.dbf',

'/home/oradata/powerdes/undotbs01.dbf',

'/home/oradata/powerdes/users01.dbf',

'/home/oradata/powerdes/powerdesk01.dbf',

'/home/oradata/powerdes/plas01.dbf',

'/home/oradata/powerdes/pl01.dbf',

'/home/oradata/powerdes/help01.dbf',

'/home/oradata/powerdes/adobelc01.dbf',

'/home/oradata/powerdes/sms01.dbf',

'/home/oradata/powerdes/plcrm01.dbf'

LOGFILE

GROUP 1('/home/oradata/powerdes/redo03.log') SIZE 10M,

GROUP 2('/home/oradata/powerdes/redo02.log') SIZE 10M,

GROUP 3('/home/oradata/powerdes/redo01.log')  SIZE10M,

GROUP 4('/home/oradata/powerdes/redo_dg_01.log') SIZE 10M,

GROUP 5('/home/oradata/powerdes/redo_dg_02.log') SIZE 10M,

GROUP 6('/home/oradata/powerdes/redo_dg_03.log') SIZE 10M

CHARACTER SET ZHS16GBK;

1.2,设置catalog start with 路径

searching for all files that match the pattern/tmp/2015-03-30/

List of Files Unknown to the Database

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

File Name:/tmp/2015-03-30/full_POWERDES_20150330_3395.bak

File Name: /tmp/2015-03-30/rman_backup.log

File Name:/tmp/2015-03-30/arch_POWERDES_20150330_3396.bak

File Name:/tmp/2015-03-30/arch_POWERDES_20150330_3394.bak

Do you really want to catalog the abovefiles (enter YES or NO)?

yes

cataloging files...

cataloging done

List of Cataloged Files

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

File Name:/tmp/2015-03-30/full_POWERDES_20150330_3395.bak

File Name:/tmp/2015-03-30/arch_POWERDES_20150330_3396.bak

File Name:/tmp/2015-03-30/arch_POWERDES_20150330_3394.bak

List of Files Which Where Not Cataloged

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

File Name: /tmp/2015-03-30/rman_backup.log

RMAN-07517: Reason: The file header is corrupted

1.3 開始restore database恢复数据库

RMAN> restore database;

Starting restore at 01-APR-15

using channel ORA_DISK_1

RMAN-00571:===========================================================

RMAN-00569: =============== ERROR MESSAGESTACK FOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002: failure of restore command at04/01/2015 03:39:01

RMAN-06026: some targets not found -aborting restore

RMAN-06023: no backup or copy of datafile12 found to restore

RMAN-06023: no backup or copy of datafile11 found to restore

RMAN-06023: no backup or copy of datafile10 found to restore

RMAN-06023: no backup or copy of datafile 9found to restore

RMAN-06023: no backup or copy of datafile 8found to restore

RMAN-06023: no backup or copy of datafile 7found to restore

RMAN-06023: no backup or copy of datafile 5found to restore

RMAN-06023: no backup or copy of datafile 4found to restore

RMAN-06023: no backup or copy of datafile 3found to restore

RMAN-06023: no backup or copy of datafile 2found to restore

RMAN-06023: no backup or copy of datafile 1found to restore

RMAN>

PS:遗憾的是恢复失败,google了非常久,发现仅仅能通过sys.dbms_backup_restore.restoreDatafileTo的方式来做不全然一致恢复。

2,使用sys.dbms_backup_restore.restoreDatafileTo来做不全然一致数据恢复

2.1。先做restoreDatafileTo的数据抽取工作。也就是将数据文件从备份集中抽取出来,记得数据文件路径要与线上保持一致。

运行命令例如以下:

SQL> DECLARE

devtype varchar2(256);

doneboolean;

BEGIN

devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'t1');

sys.dbms_backup_restore.restoreSetDatafile;

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,toname=>'/home/oradata/powerdes/system01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>02,toname=>'/home/oradata/powerdes/sysaux01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>03,toname=>'/home/oradata/powerdes/undotbs01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>04,toname=>'/home/oradata/powerdes/users01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>05,toname=>'/home/oradata/powerdes/powerdesk01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>06,toname=>'/home/oradata/powerdes/plas01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>07,toname=>'/home/oradata/powerdes/pl01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>08,toname=>'/home/oradata/powerdes/help01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>09,toname=>'/home/oradata/powerdes/adobelc01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>10,toname=>'/home/oradata/powerdes/sms01.dbf');

sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>11,toname=>'/home/oradata/powerdes/plcrm01.dbf');

sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/pddata2/oracle/backup/data/2015-03-30/full_POWERDES_20150330_3395.bak',params=>null);

sys.dbms_backup_restore.deviceDeallocate;

END;

/

PS:handle是运行备份的bak文件;最后的/不能少。

SQL>

运行过程须要一段时间,慢慢等待。后台的alert日志会依次有例如以下信息显示出来提示抽取成功:

Full restore complete of datafile 7 to datafilecopy /home/oradata/powerdes/pl01.dbf. Elapsed time: 0:00:41

checkpoint is 11029786628

last deallocation scn is 11022714700

Full restore complete of datafile 8 todatafile copy /home/oradata/powerdes/help01.dbf.  Elapsed time: 0:00:01

checkpoint is 11029786628

last deallocation scn is 9881798870

Wed Apr 01 05:01:54 2015

Full restore complete of datafile 9 todatafile copy /home/oradata/powerdes/adobelc01.dbf.  Elapsed time: 0:00:00

checkpoint is 11029786628

Wed Apr 01 05:02:12 2015

Full restore complete of datafile 10 todatafile copy /home/oradata/powerdes/sms01.dbf. Elapsed time: 0:00:12

checkpoint is 11029786628

Wed Apr 01 05:05:15 2015

Full restore complete of datafile 3 todatafile copy /home/oradata/powerdes/undotbs01.dbf.  Elapsed time: 0:04:45

checkpoint is 11029786628

last deallocation scn is 11029784977

Undo Optimization current scn is 11029779851

Wed Apr 01 05:06:04 2015

Full restore complete of datafile 11 todatafile copy /home/oradata/powerdes/plcrm01.dbf.  Elapsed time: 0:06:01

checkpoint is 11029786628

last deallocation scn is 11007637870

Wed Apr 01 05:06:27 2015

Full restore complete of datafile 4 todatafile copy /home/oradata/powerdes/users01.dbf.  Elapsed time: 0:06:24

checkpoint is 11029786628

last deallocation scn is 11029437543

Wed Apr 01 05:10:33 2015

Full restore complete of datafile 1 todatafile copy /home/oradata/powerdes/system01.dbf.  Elapsed time: 0:09:27

checkpoint is 11029786628

last deallocation scn is 10910611499

Undo Optimization current scn is 11029779851

Wed Apr 01 05:13:39 2015

Full restore complete of datafile 2 todatafile copy /home/oradata/powerdes/sysaux01.dbf.  Elapsed time: 0:13:29

checkpoint is 11029786628

last deallocation scn is 11028968586

Wed Apr 01 05:14:44 2015

Full restore complete of datafile 6 todatafile copy /home/oradata/powerdes/plas01.dbf.  Elapsed time: 0:14:37

checkpoint is 11029786628

last deallocation scn is 11028348038

Wed Apr 01 05:39:30 2015

Full restore complete of datafile 5 todatafile copy /home/oradata/powerdes/powerdesk01.dbf.  Elapsed time: 0:39:12

checkpoint is 11029786628

last deallocation scn is 11029438448

2.2 数据抽取成功后,要创新创建控制文件

假设不知道怎样创建controlfile的命令,能够在线上生成trace文件

一般默认的控制文件是二进制的,打开来是乱码的 ,备份一个trace出来 能够打开看到语句了,$ORACLE_BASE/admin/$ORACLE_SID/udump文件夹下。生成的新的 trace 文件中。trace文件有生成控制文件的脚本。使用例如以下命令alter database backup controlfile to trace as'/oracle/app/oracle/admin/powerdes/pfile/control.sql';能够得到创建控制文件的sql命令。

整理出来创建控制文件命令例如以下:

CREATE CONTROLFILE REUSE SET DATABASE"POWERDES" RESETLOGS ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 2920

DATAFILE

'/home/oradata/powerdes/system01.dbf',

'/home/oradata/powerdes/sysaux01.dbf',

'/home/oradata/powerdes/undotbs01.dbf',

'/home/oradata/powerdes/users01.dbf',

'/home/oradata/powerdes/powerdesk01.dbf',

'/home/oradata/powerdes/plas01.dbf',

'/home/oradata/powerdes/pl01.dbf',

'/home/oradata/powerdes/help01.dbf',

'/home/oradata/powerdes/adobelc01.dbf',

'/home/oradata/powerdes/sms01.dbf',

'/home/oradata/powerdes/plcrm01.dbf'

LOGFILE

GROUP 1 '/home/oradata/powerdes/redo01.log'  SIZE 50M BLOCKSIZE 512,

GROUP 2 '/home/oradata/powerdes/redo02.log'  SIZE 50M BLOCKSIZE 512,

GROUP 3 '/home/oradata/powerdes/redo03.log'  SIZE 50M BLOCKSIZE 512

CHARACTER SET ZHS16GBK;

2.3 恢复数据而且打开数据库

RMAN> recover database;

Starting recover at 02-APR-15

using target database control file insteadof recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=767 devicetype=DISK

starting media recovery

unable to find archived log

archived log thread=1 sequence=31023

RMAN-00571:===========================================================

RMAN-00569: =============== ERROR MESSAGESTACK FOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002: failure of recover command at04/02/2015 13:35:40

RMAN-06054: media recovery requestingunknown archived log for thread 1 with sequence 31023 and starting SCN of11029786628

RMAN>

RMAN> restore database from'/pddata2/oracle/backup/data/2015-03-30/full_POWERDES_20150330_3395.bak';

Starting restore at 02-APR-15

using channel ORA_DISK_1

RMAN-00571:===========================================================

RMAN-00569: =============== ERROR MESSAGESTACK FOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002: failure of restore command at04/02/2015 13:37:05

RMAN-06509: only SPFILE or control file canbe restored from AUTOBACKUP

RMAN>

看到打开都报错了。所以试试直接open打开吧

SQL> SQL> alter database open resetlogs
  2  ;

Database altered.

SQL> 

3。然后exp导出表数据,imp导入到生产环境

导出:exp system/manager@myoracle file=/tmp/qd.dmp tables=(hr_resume_qingdao)    system是用户名,manager 是password,myoracle 是数据库名。

数据传输:scp /tmp/qd.dmp 192.168.120.217:/tmp/

导入:imp username/pwd[@sid] file=/tmp/ qd.dmp  tables=( hr_resume_qingdao)

4,一些报错记录

找到数据文件

ERROR at line 1:

ORA-01503: CREATE CONTROLFILE failed

ORA-01200: actual file size of 128679 issmaller than correct size of 340480

blocks

ORA-01110: data file 2:'/home/oradata/powerdes/sysaux01.dbf'

解决方法:

dd if=/dev/zeroof=/home/oradata/powerdes/sysaux01.dbf bs=8192 count=1 seek=340480

  ----------------------------------------------------------------------------------------------------------------
<版权全部,文章同意转载。但必须以链接方式注明源地址,否则追究法律责任!>
原博客地址:       http://blog.itpub.net/26230597/viewspace-1484099/
原作者:黄杉 (mchdba)
----------------------------------------------------------------------------------------------------------------

ORACLE 11G没有备份文件參数文件在异机通过rman备份恢复找回被误删的数据的更多相关文章

  1. Oracle 11g RAC to RAC ADG搭建(一)采用rman备份恢复方式

    (一)基础环境   主库 备库 操作系统 RedHat6.7 RedHat6.7 服务器名称 primarydb1primarydb2 standbydb1standbydb2 IP地址规划 192. ...

  2. ORACLE 參数文件介绍

    ORACLE数据库启动以后.通过select * from v$parameter这个语句能够查看到oracle数据库使用的全部參数. 对于oracle的參数文件,分为spfile 二进制文件和pfi ...

  3. ORACLE11G 将dataguard的rman备份恢复到測试环境的单机oracle中的具体过程

    . 也就是说此时数据库仅仅能进行不全然恢复了,在打开数据库时得使用resetlogs打开. recover database until scn 11412370952; RMAN> recov ...

  4. oracle动态注冊參数local_listener

    local_listener參数有两种书写格式,提供了不同的功能. 监听文件上,1521和1526port上都有动态监听port. [oracle@dbsv admin]$ cat listener. ...

  5. Oracle 自己主动内存參数依赖性

    图例:在该图中使用了下面參数名称缩写: MT = MEMORY_TARGET MMT = MEMORY_MAX_TARGET ST = SGA_TARGET PAT = PGA_AGGREGATE_T ...

  6. ORACLE模拟一个数据文件坏块并使用RMAN备份来恢复

    1.创建一个实验用的表空间并在此表空间上创建表 create tablespace blocktest datafile '/u01/oradata/bys1/blocktest.dbf' size ...

  7. Oracle RMAN备份恢复指导书

    目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库. ...

  8. ORACLE11g 没有控制文件如何通过rman备份恢复数据的详细实战过程

    1.副总裁需要裸恢复的严峻现实 集团总部的信息部负责人给我打电话说为了找一年前的记录,所以需要对一年前2015年5月1日的数据进行恢复.而2016年初因为进行迁移,所以有些文件可能丢失,手上只有rma ...

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

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

随机推荐

  1. Swift - 使用UIScrollView实现页面滚动切换

    UIScrollView提供了以页面为单位滚动显示各个子页面内容的功能,每次手指滑动后会滚动一屏的内容.   要实现该功能,需要如下操作: 1,将UIScrollView的pagingEnabled属 ...

  2. HealthKit开发教程Swift版:起步

    原文:HealthKit Tutorial with Swift: Getting Started 作者:Ernesto García 译者:Mr_cyz ) HealthKit是iOS 8中的新的A ...

  3. android之写文件到sd卡

    1.main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a ...

  4. HTML中Id和Name的区别

    源地址:http://www.cnblogs.com/laodai/articles/2244215.html 在html中:name指的是用户名称,ID指的是用户注册是系统自动分配给用户的一个序列号 ...

  5. Delphi动态申请数组内存的方法(不使用SetLength,采用和C相似的方式)

    procedure TForm1.Button1Click(Sender: TObject);type  TArr = array [0..0] of Integer;  PArr = ^TArr;v ...

  6. [Android学习笔记]Android中多线程开发的一些概念

    线程安全: 在多线程的情况下,不会因为线程之间的操作而导致数据错误. 线程同步: 同一个资源,可能在同一时间被多个线程操作,这样会导致数据错误.这是一个现象,也是一个问题,而研究如何解决此类问题的相关 ...

  7. JAVA的extends使用方法

    理解继承是理解面向对象程序设计的关键.在Java中,通过keywordextends继承一个已有的类,被继承的类称为父类(超类,基类),新的类称为子类(派生类).在Java中不同意多继承. (1)继承 ...

  8. maven使用.02.一些概念

    在上一篇POST中,简要的介绍了一下maven的特点,优势,安装.并建立了一个简单地Hello world工程.这一篇POST中,将主要会介绍一下Maven的一些约定. pom.xml文件 Maven ...

  9. AdaBoost中利用Haar特征进行人脸识别算法分析与总结1——Haar特征与积分图

    原地址:http://blog.csdn.net/watkinsong/article/details/7631241 目前因为做人脸识别的一个小项目,用到了AdaBoost的人脸识别算法,因为在网上 ...

  10. Java学习笔记4

    Java学习笔记4 1. JDK.JRE和JVM分别是什么,区别是什么? 答: ①.JDK 是整个Java的核心,包括了Java运行环境.Java工具和Java基础类库. ②.JRE(Java Run ...