缺少控制文件备份时如何还原数据库 (Doc ID 1438776.1)
How to restore database when controlfile backup missing (Doc ID 1438776.1)
APPLIES TO:
Oracle Database - Enterprise Edition - Version 9.2.0.1 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Information in this document applies to any platform.
***Checked for relevance on 16-NOV-2015***
GOAL
This article will help in the case when customer have all backup pieces of database except controlfile backup which is mandatory to mount the database and start restore.
当客户拥有数据库的所有备份集(控制文件备份除外)时,本文将有帮助。控制文件备份是安装数据库和开始还原所必需的。
SOLUTION
Here we are giving one test case where we have current database structure and simulate the customer environment where he/she missing controlfile backup
在这里,我们给出一个测试用例,其中我们拥有当前的数据库结构并模拟客户环境中缺少控制文件备份的客户
1. See the current database structure 查看当前的数据库结构
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 510 SYSTEM *** +DATA/ora102/datafile/system.257.775126603
2 595 UNDOTBS1 *** +DATA/ora102/datafile/undotbs1.256.775126561
3 250 SYSAUX *** +DATA/ora102/datafile/sysaux.258.775126637
4 28 USERS *** +DATA/ora102/datafile/users.259.775126653
5 50 USERS *** +DATA/ora102/datafile/users.262.776000421 List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 /u01/app/oracle/oradata/ora102/ORA102/datafile/o1_mf_temp_7lqq1qko_.tmp RMAN> exit Recovery Manager complete.
2. Create a dummy instance/ can use existing database to extract datafile 1 from backup piece and restore datafile 1 from backup piece
创建一个虚拟实例/可以使用现有数据库从备份文件中提取数据文件1并从备份文件中恢复数据文件1
SQL> DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');
dbms_backup_restore.RestoreSetDatafile;
dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/u03/datafile1.dbf');
dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/u03/backup/2cn5blrn_1_1', params => null);
dbms_backup_restore.DeviceDeallocate;
END;
/
3. Create controlfile with datafile 1 使用数据文件1创建控制文件
SQL>!cat /u03/1.ctl
CREATE CONTROLFILE REUSE DATABASE "ORA102" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_1_7lqq1m62_.log' SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_2_7lqq1myr_.log' SIZE 50M,
GROUP 3 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_3_7lqq1nr0_.log' SIZE 50M
DATAFILE
'/u03/datafile1.dbf'
CHARACTER SET WE8ISO8859P1
;
SQL> @/u03/1.ctl Control file created. SQL> select name from v$datafile; NAME
--------------------------------------------------------------------------------
/u03/datafile1.dbf SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
4. Catalog all the backup piece Catalog所有备份集
[oracle@oel57 ~]$ rman target / Recovery Manager: Release 10.2.0.5.0 - Production on Thu Mar 8 11:55:58 2012 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORA102 (DBID=396070408, not open) RMAN> catalog start with '/u03/backup/' noprompt; using target database control file instead of recovery catalog
searching for all files that match the pattern /u03/backup/ List of Files Unknown to the Database
=====================================
File Name: /u03/backup/28n5bki6_1_1
File Name: /u03/backup/ORA1122-backup-080312.log
File Name: /u03/backup/2dn5blsq_1_1
File Name: /u03/backup/2cn5blrn_1_1
File Name: /u03/backup/ora102-080312.log
File Name: /u03/backup/27n5bkd0_1_1
cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: /u03/backup/2dn5blsq_1_1
File Name: /u03/backup/2cn5blrn_1_1 List of Files Which Where Not Cataloged
=======================================
File Name: /u03/backup/28n5bki6_1_1
RMAN-07518: Reason: Foreign database file DBID: 2353175563 Database Name: ORA1122
File Name: /u03/backup/ORA1122-backup-080312.log
RMAN-07517: Reason: The file header is corrupted
File Name: /u03/backup/ora102-080312.log
RMAN-07517: Reason: The file header is corrupted
File Name: /u03/backup/27n5bkd0_1_1
RMAN-07518: Reason: Foreign database file DBID: 2353175563 Database Name: ORA1122 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
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 1.05M DISK 00:00:00 08-MAR-12
BP Key: 1 Status: AVAILABLE Compressed: YES Tag: TAG20120308T101415
Piece Name: /u03/backup/2dn5blsq_1_1
Control File Included: Ckp SCN: 1320981 Ckp time: 08-MAR-12
SPFILE Included: Modification time: 08-MAR-12 BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 107.40M DISK 00:00:00 08-MAR-12
BP Key: 2 Status: AVAILABLE Compressed: YES Tag: TAG20120308T101415
Piece Name: /u03/backup/2cn5blrn_1_1
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1320981 08-MAR-12 +DATA/ora102/datafile/system.257.775126603
2 Full 1320981 08-MAR-12
3 Full 1320981 08-MAR-12
4 Full 1320981 08-MAR-12
5 Full 1320981 08-MAR-12 RMAN>
5. Now restore the datafiles using DBMS_BACKUP_RESTORE package . Please note name of datafiles are not important here we can give any unique name to restore the datafiles
现在,使用 DBMS_BACKUP_RESTORE 包还原数据文件。请注意,数据文件的名称并不重要,我们可以使用任何唯一的名称来恢复数据文件
SQL> -- use script DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');
dbms_backup_restore.RestoreSetDatafile;
dbms_backup_restore.RestoreDatafileTo(dfnumber => 4,toname => '/u03/datafile4.dbf');
dbms_backup_restore.RestoreDatafileTo(dfnumber => 2,toname => '/u03/datafile2.dbf');
dbms_backup_restore.RestoreDatafileTo(dfnumber => 3,toname => '/u03/datafile3.dbf');
dbms_backup_restore.RestoreDatafileTo(dfnumber => 5,toname => '/u03/datafile5.dbf');
dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/u03/datafile1.dbf');
dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/u03/backup/2cn5blrn_1_1', params => null);
dbms_backup_restore.DeviceDeallocate;
END;
/ PL/SQL procedure successfully completed.
Metadata will show only datafile 1 . We need to re-create control file with all relevant restored dataifiles
元数据将仅显示数据文件1。我们需要使用所有相关的已还原数据重新创建控制文件
SQL> select name from v$datafile; NAME
--------------------------------------------------------------------------------
+DATA/ora102/datafile/system.257.775126603 SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started. Total System Global Area 209715200 bytes
Fixed Size 1272864 bytes
Variable Size 142607328 bytes
Database Buffers 58720256 bytes
Redo Buffers 7114752 bytes
SQL>!cat /u03/1.ctl
CREATE CONTROLFILE REUSE DATABASE "ORA102" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_1_7lqq1m62_.log' SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_2_7lqq1myr_.log' SIZE 50M,
GROUP 3 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_3_7lqq1nr0_.log' SIZE 50M
DATAFILE
'/u03/datafile1.dbf',
'/u03/datafile4.dbf',
'/u03/datafile2.dbf',
'/u03/datafile3.dbf',
'/u03/datafile5.dbf'
CHARACTER SET WE8ISO8859P1
; SQL> @/u03/1.ctl Control file created. SQL> select name from v$datafile; NAME
--------------------------------------------------------------------------------
/u03/datafile1.dbf
/u03/datafile2.dbf
/u03/datafile3.dbf
/u03/datafile4.dbf
/u03/datafile5.dbf
6. If the backup what we restored is not the cold backup then we need to recover the database,hence, we can catalog the backup pieces which contains archives ,restore archives and then do recovery
如果我们还原的备份不是冷备份,那么我们需要恢复数据库,因此,我们可以对包含归档文件的备份目录进行分类,还原归档文件然后进行恢复
SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
SQL>
7. Once database in consistent status we can open database with resetlogs option
一旦数据库处于一致状态,我们可以使用resetlogs选项打开数据库
SQL>alter database open resetlogs;
Database altered.
SQL>
Note: In case of Multisection backup we need to consider all the backup pieces (all sections) and use function initmsr as below to restore datafile
注意:如果是多部分备份,我们需要考虑所有备份片(所有部分),并使用如下所示的函数initmsr来还原数据文件
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');
dbms_backup_restore.RestoreSetDatafile;
dbms_backup_restore.initmsr(1,'/ud1001/PROD/oradata/system01-test.dbf');
dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/ud1001/PROD/oradata/system01-test.dbf');
dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/backup/Oracle-DB-8-7-2014/db_L0_PROD_e6pf7too_1_1.rman', params => null);
dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/backup/Oracle-DB-8-7-2014/db_L0_PROD_e6pf7too_2_1.rman', params => null);
END;
/
缺少控制文件备份时如何还原数据库 (Doc ID 1438776.1)的更多相关文章
- 12.2新特性 使用DBCA duplicate创建物理备用数据库 (Doc ID 2283697.1)
Creating a Physical Standby database using DBCA duplicate (Doc ID 2283697.1) APPLIES TO: Oracle Data ...
- 如何使用T-SQL备份还原数据库及c#如何调用执行? C#中索引器的作用和实现。 jquery控制元素的隐藏和显示的几种方法。 localStorage、sessionStorage用法总结 在AspNetCore中扩展Log系列 - 介绍开源类库的使用(一) span<T>之高性能字符串操作实测
如何使用T-SQL备份还原数据库及c#如何调用执行? 准备材料:Microsoft SQL Server一部.需要还原的bak文件一只 一.备份 数据库备份语句:user master backup ...
- SQL Server 在缺少文件组的情况下如何还原数据库
SQL Server 在缺少文件组的情况下如何还原数据库 一.背景 我有一个A库,由于a,b两张表的数据量比较大,所以对表进行分区:在把A库迁移到一个新的集群上去,我只备份了A库的主分区过去进行还原为 ...
- SQL2005:SQL Server 2005还原数据库时出现“不能选择文件或文件组XXX_log用于此操作的解决办法
SQL2005 还原数据库失败,提示如下: SQL Server 2005还原数据库时出现“不能选择文件或文件组XXX_log用于此操作的解决办法 出现错误时操作步骤为:右击数据库--->任务- ...
- sql server 还原数据库时提示数据库正在使用,无法进行操作的解决方法
这个问题的原因在于有用户连接了当前要做还原的数据库,这里的用户甚至包括当前要做还原的用户.解决办法就是关闭与要还原数据库的所有连接. 脚本之家小编推荐的一个方法:到服务里面重启下sqlserver服务 ...
- 还原数据库备份文件时,关于“System.Data.SqlClient.SqlError:媒体集有2个媒体簇,但只提供了1个。必须提供所有成员”的处理方式
好久没写博客了,最近在做毕设的权限管理模块,今天在还原数据库文件时,遇到了“System.Data.SqlClient.SqlError:媒体集有2个媒体簇,但只提供了1个.必须提供所有成员”这个错误 ...
- 还原数据库“XXX”时失败。System.Data.SqlClient.SqlError: 无法执行 BACKUP LOG,因为当前没有数据库备份。
标题: Microsoft SQL Server Management Studio------------------------------ 还原数据库“GoldBellXZDepot”时失败. ...
- sqlserver 2008 还原数据库时,提示有用户正在使用,无法取得使用占有权
sqlserver 2008 还原数据库时,提示有用户正在使用,无法取得使用占有权 这个时候,只需要把数据库分离出去,再附加,然后还原即可 分离数据库的时候能看到有几个数据连接
- 在SQL SERVER 2005中还原数据库时出现错误:system.data.sqlclient.sqlerror 媒体集有 2 个媒体簇 但只提供了 1 个。必须提供所有成员。 (microsoft.sqlserver.smo)
问题:在SQL SERVER 2005中还原数据库时出现错误:system.data.sqlclient.sqlerror 媒体集有 2 个媒体簇 但只提供了 1 个.必须提供所有成员. (micro ...
随机推荐
- 针对base64编码和URIEncode的一点研究
Base64编码的作用 将任意的二进制比特串编码成由ASCii码中的64个可显示字符组成的字符串. 为什么需要base64编码? 所有的文件,本质上都是0.1组成的比特串,文本文件.二进制文件的区别只 ...
- XGBoost缺失值引发的问题及其深度分析
1. 背景 XGBoost模型作为机器学习中的一大“杀器”,被广泛应用于数据科学竞赛和工业领域,XGBoost官方也提供了可运行于各种平台和环境的对应代码,如适用于Spark分布式训练的XGBoost ...
- MongoDB(一):NoSQL简介、MongoDB简介
1. NoSQL简介 1.1 什么是NoSQL NoSQL(NoSQL= Not Only SQL),意即“不仅仅是SQL",是一项全新的数据库理念,泛指非关系型的数据库. 1.2 为什么需 ...
- tesseract-OCR + pytesseract安装
1. tesseract-OCR下载安装 地址:https://digi.bib.uni-mannheim.de/tesseract/ 选择一个版本下载,下载完成点击**.exe进行安装,若无其他需求 ...
- Python-根据照片信息获取用户详细信息(微信发原图或泄露位置信息)
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 蒙娜丽胖 PS:如有需要Python学习资料的小伙伴可以加点击下方 ...
- Dynamics CRM 2013开始推出的服务器端同步来配置邮件服务
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...
- SAP_ECC6_EHP7_IDES安装文档ORACLE11G+WINDOWS2012 R2 问题总结
SAP_ECC6_EHP7_IDES安装文档ORACLE11G+WINDOWS2012 R2 问题总结 1.注意密码不能带@等特殊符号,否则会报如下错误,因为ORACLE数据是不容许密码带@的.@是一 ...
- arcgis api for javascript 学习(一) 调用在线发布的动态地图
1.图中显示为arcgis软件中显示的地图文件 2.调用动态地图主要的是知道动态地图的URL地址 3.通过IDE(webstorm)调用动态地图,如图 4.话不多说,直接上代码 <!DOCTYP ...
- iOS多线程知识梳理
iOS多线程知识梳理 线程进程基础概念 进程 进程是指在系统中正在运行的一个应用程序 每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内 线程 1个进程要想执行任务,必须得有线程(每1个 ...
- 软工第八次实验——Git
hiahiahia我又来作恶了,莫名其妙的第八次实验还要更新! 文章目录 一.Git 1.1 概述 1.1.1 Git 1.1.2 分布式版本控制系统 1.1.3 指令集 1.2 版本控制系统 1.2 ...