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

背景:

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

真实屋漏偏逢连夜雨、船迟又遇打头风。前两天备份的磁盘坏块,如今仅仅有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/[email protected] 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)
----------------------------------------------------------------------------------------------------------------

时间: 2024-10-05 06:05:16

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

ORACLE 11G没有备份文件参数文件在异机通过rman备份恢复找回被误删的数据

背景:          同事误删除线上数据,所以需要从备份中找回数据恢复.真实屋漏偏逢连夜雨.船迟又遇打头风,前两天备份的磁盘坏块,现在只有rman全备的.bak文件,没有控制文件和参数文件,所以现在需要考虑的是如何根据bak文件在备份数据库上恢复数据,从中找出被误删的数据. 1 通过catalog start with''的方式来恢复 1.1手动创建控制文件 CREATE CONTROLFILE REUSE set DATABASE"powerdes" RESETLOGS ARCH

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

(一)基础环境   主库 备库 操作系统 RedHat6.7 RedHat6.7 服务器名称 primarydb1primarydb2 standbydb1standbydb2 IP地址规划 192.168.10.31    primarydb1192.168.10.32    primarydb2192.168.10.33    primarydb1-vip192.168.10.34    primarydb2-vip192.168.10.30    primarydb-scan 10.10.

ORACLE 參数文件介绍

ORACLE数据库启动以后.通过select * from v$parameter这个语句能够查看到oracle数据库使用的全部參数. 对于oracle的參数文件,分为spfile 二进制文件和pfile 文本文件.如今的数据库一般都是使用spfile二进制文件作为启动oracle的參数文件.对于spfile和pfile之间的差别: 1 spfile是二进制文件(能够通过 string spfileorcl.ora进行二进制的文件查看),不能够使用文本编辑器改动.仅仅能在sqlplus中使用命令

Oracle RMAN备份恢复2-案例篇_超越OCP精通Oracle视频教程培训18

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库如何设计一个TB级数据库的RMAN备份策略,RMAN备份与恢复案例-丢失所有文件,丢失单个数据文件,丢失整个数据和system表空间,丢失控制文件和参数文件,存储损坏数据丢失,丢失REDO重做日志文件,基于时间点,scn,cancel,备份控制文件的不完成恢复案例. 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址: http://edu.51c

第22章 oracle RMAN备份恢复

2015-10-24 目录 参考资料 [1] 林树泽.Oracle 11g R2 DBA操作指南[M].北京:清华大学出版社,2013 [2] Oracle备份与恢复介绍(物理备份与逻辑备份) [3] Oracle备份与恢复案例 [4] ORACLE 备份与恢复 [5] Oracle数据库的备份方法 [6] oracle之rman入门指南 [7] ORACLE RMAN备份及还原 [8] rman备份恢复实例(经典) [9] RMAN 备份详解 [10] RMAN 还原与恢复 [11] RMAN

Oracle RMAN备份恢复1-基础篇_超越OCP精通Oracle视频教程培训17

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库RMAN备份恢复基础,如rman作用与体系架构,nocatalog和catalog介绍与catalog配置,详解rman的使用,详解rman常用的命令list,report, backup,configure,set,crosscheck,validate,change,delete,restore,recover,switch,blockrecover,convert等使用. 适用人群 IT相关从

Oracle RMAN备份恢复3-高级篇_超越OCP精通Oracle视频课程培训19

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库关于RMAN内存缓冲与块跟踪,DBMS_BACKUP_RESTORE,使用RMAN BlockRecover恢复坏块,RMAN Recovery Advisor 案例,RMAN备份压缩技术,RMAN增量备份恢复,RMAN备份加密,RMAN克隆数据库,生产环境RMAN异机恢复的几种经典场景案例 . 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址:

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

1.副总裁需要裸恢复的严峻现实 集团总部的信息部负责人给我打电话说为了找一年前的记录,所以需要对一年前2015年5月1日的数据进行恢复.而2016年初因为进行迁移,所以有些文件可能丢失,手上只有rman全备文件,希望在一天之内找回,集团一个副总裁在等着这个数据有急用. 我在电话里面说马上去做,接完电话,想到只有rman备份文件,而且是备份的数据文件,没有控制文件没有参数文件的备份,所以普通的 (1)      先恢复控制文件restore controlfile from '-bak'; (2)

Oracle RMAN备份恢复指导书

目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库... 3 4.1.3 查看备份信息... 3 4.1.4 备份数据库... 5 4.1.5 备份数据文件... 6 4.1.6 备份表空间... 6 4.1.7 备份控制文件... 6 4.1.8 备份归档日志文件... 7 4.1.9 备份闪回区... 8 4.1.10 增量备份... 8 4.2