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)的更多相关文章

  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 ...

  2. 如何使用T-SQL备份还原数据库及c#如何调用执行? C#中索引器的作用和实现。 jquery控制元素的隐藏和显示的几种方法。 localStorage、sessionStorage用法总结 在AspNetCore中扩展Log系列 - 介绍开源类库的使用(一) span<T>之高性能字符串操作实测

    如何使用T-SQL备份还原数据库及c#如何调用执行? 准备材料:Microsoft SQL Server一部.需要还原的bak文件一只 一.备份 数据库备份语句:user master backup ...

  3. SQL Server 在缺少文件组的情况下如何还原数据库

    SQL Server 在缺少文件组的情况下如何还原数据库 一.背景 我有一个A库,由于a,b两张表的数据量比较大,所以对表进行分区:在把A库迁移到一个新的集群上去,我只备份了A库的主分区过去进行还原为 ...

  4. SQL2005:SQL Server 2005还原数据库时出现“不能选择文件或文件组XXX_log用于此操作的解决办法

    SQL2005 还原数据库失败,提示如下: SQL Server 2005还原数据库时出现“不能选择文件或文件组XXX_log用于此操作的解决办法 出现错误时操作步骤为:右击数据库--->任务- ...

  5. sql server 还原数据库时提示数据库正在使用,无法进行操作的解决方法

    这个问题的原因在于有用户连接了当前要做还原的数据库,这里的用户甚至包括当前要做还原的用户.解决办法就是关闭与要还原数据库的所有连接. 脚本之家小编推荐的一个方法:到服务里面重启下sqlserver服务 ...

  6. 还原数据库备份文件时,关于“System.Data.SqlClient.SqlError:媒体集有2个媒体簇,但只提供了1个。必须提供所有成员”的处理方式

    好久没写博客了,最近在做毕设的权限管理模块,今天在还原数据库文件时,遇到了“System.Data.SqlClient.SqlError:媒体集有2个媒体簇,但只提供了1个.必须提供所有成员”这个错误 ...

  7. 还原数据库“XXX”时失败。System.Data.SqlClient.SqlError: 无法执行 BACKUP LOG,因为当前没有数据库备份。

    标题: Microsoft SQL Server Management Studio------------------------------ 还原数据库“GoldBellXZDepot”时失败. ...

  8. sqlserver 2008 还原数据库时,提示有用户正在使用,无法取得使用占有权

    sqlserver 2008 还原数据库时,提示有用户正在使用,无法取得使用占有权 这个时候,只需要把数据库分离出去,再附加,然后还原即可 分离数据库的时候能看到有几个数据连接

  9. 在SQL SERVER 2005中还原数据库时出现错误:system.data.sqlclient.sqlerror 媒体集有 2 个媒体簇 但只提供了 1 个。必须提供所有成员。 (microsoft.sqlserver.smo)

    问题:在SQL SERVER 2005中还原数据库时出现错误:system.data.sqlclient.sqlerror 媒体集有 2 个媒体簇 但只提供了 1 个.必须提供所有成员. (micro ...

随机推荐

  1. 富士通 DX90 S2存储分配映射盘

    屁话不多说,直接开操: 1.连接存储 用pc连接到存储管理口,如192.168.1.101 登录管理账号:默认root/root 创建Volume, 点击create开始创建新的volume 按需填写 ...

  2. 使用 Docker 和 Nginx 打造高性能的二维码服务

    使用 Docker 和 Nginx 打造高性能的二维码服务 本文将演示如何使用 Docker 完整打造一个基于 Nginx 的高性能二维码服务,以及对整个服务镜像进行优化的方法.如果你的网络状况良好, ...

  3. juc-2.1-模拟CAS算法

    package com.wf.zhang.juc; /* * 模拟 CAS 算法 */ public class TestCompareAndSwap { public static void mai ...

  4. 集合系列 Queue(十一):ArrayDeque

    从名字我们可以看出,其实一个双向队列实现,而且底层采用数组实现. public class ArrayDeque<E> extends AbstractCollection<E> ...

  5. promise和axios

    1.接口调用方式 原生ajax 基于jQuery的ajax fetch axios 异步 JavaScript的执行环境是「单线程」 所谓单线程,是指JS引擎中负责解释和执行JavaScript代码的 ...

  6. vue组件常用声明方式

    一.前言 这是自己重新写的一个,感觉以前的太写了很多不必要的方式 实际当中基本不会用的 所以自己写了一个常用的组件什么方式 更加的通俗易懂 二.代码如下 <!DOCTYPE html> & ...

  7. Prometheus学习系列(四)之Prometheus 配置说明

    前言 本文来自Prometheus官网手册 和 Prometheus简介 说明 Prometheus通过命令行和配置文件进行配置,命令行配置不能修改的系统参数(例如存储位置,要保留在磁盘和内存中的数据 ...

  8. 如何在asm上定位数据块

    转自 https://blogs.oracle.com/database4cn/%e5%a6%82%e4%bd%95%e5%9c%a8asm%e4%b8%8a%e5%ae%9a%e4%bd%8d%e6 ...

  9. docker容器虚拟化技术

    简单来说,在Windows系统下安装各种运行环境的坑简直不要太多了(● ̄(エ) ̄●),并不仅限于docker.Nginx.PHP.Python等等,我会尽详细写出实际过程中遇到的各种各样的奇葩问题 1 ...

  10. HTTP 请求夹带(smuggling)攻击

    什么是HTTP请求夹带(smuggling)攻击 HTTP请求走私是一种干扰网站处理从一个或多个用户接收的HTTP请求序列的方式的技术. 请求夹带漏洞危害,允许攻击者绕过安全控制,获取对敏感数据的未授 ...