控制文件的备份与恢复(RMAN工具)

本篇说明控制文件在全部丢失的情况下,利用Rman工具自动备份的控制文件转储并恢复数据库;

之前写过一篇关于手动“控制文件的备份与恢复” ,请查阅http://blog.csdn.net/perfect_db/article/details/8805111


数据库版本

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production


C:\Documents and Settings\Administrator>rman target / catalog rm_user/rm_user

恢复管理器: Release 11.2.0.1.0 - Production on 星期日 8月 11 16:00:49 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
连接到目标数据库: ORCL (DBID=1318810635)
连接到恢复目录数据库


查看rman 配置

RMAN> show all;
db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'f:\rmanbackup\controlfile\%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   'd:\backup\%d_%s.bak';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFORCL.ORA'; # default


说明控制文件的备份策略为自动备份;那么就先任意备份一个数据文件(本次就用备份此数据文件时自动备份的控制文件)

RMAN> backup datafile 7;


启动 backup 于 11-8月 -13
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集内的数据文件
输入数据文件: 文件号=00007 名称=E:\RMAN.DBF
通道 ORA_DISK_1: 正在启动段 1 于 11-8月 -13
通道 ORA_DISK_1: 已完成段 1 于 11-8月 -13
段句柄=D:\BACKUP\ORCL_167.BAK 标记=TAG20130811T152451 注释=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:03
完成 backup 于 11-8月 -13


启动 Control File and SPFILE Autobackup 于 11-8月 -13
段 handle=F:\RMANBACKUP\CONTROLFILE\C-1318810635-20130811-00comment=NONE
完成 Control File and SPFILE Autobackup 于 11-8月 -13


RMAN> shutdown immediate;
数据库已关闭
数据库已卸装
Oracle 实例已关闭


手动删除所有控制文件;


以下是恢复步骤;


RMAN> startup nomount;
数据库已经启动


RMAN> restore controlfile from autobackup;


启动 restore 于 11-8月 -13
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: restore 命令 (在 08/11/2013 15:28:47 上) 失败
RMAN-06004: 恢复目录数据库发生 ORACLE 错误: ORA-03114: 未连接到 ORACLE


说明关闭数据库之后已经断开了与数据库的链接;

RMAN> exit

恢复管理器完成。

Blog:    http://blog.csdn.net/perfect_db

由于数据库启动不了,所以恢复目录用不了,那么就只连接到目标数据库;
C:\Documents and Settings\Administrator>rman target /

恢复管理器: Release 11.2.0.1.0 - Production on 星期日 8月 11 15:30:05 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
连接到目标数据库: ORCL (未装载)

RMAN> startup nomount;

数据库已经启动

RMAN> restore controlfile from autobackup;


启动 restore 于 11-8月 -13
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=133 设备类型=DISK

恢复区目标: F:\rmanbackup
用于搜索的数据库名 (或数据库的唯一名称): ORCL
通道 ORA_DISK_1: 在恢复区中没有找到 AUTOBACKUP
由于未设置 DBID 而未尝试使用格式 "%F" 搜索 AUTOBACKUP
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: restore 命令 (在 08/11/2013 15:30:20 上) 失败
RMAN-06172: 没有找到 AUTOBACKUP, 或者指定的句柄不是有效副本或片段


RMAN> restore controlfile from 'f:\rmanbackup\controlfile\C-1318810635-20130811-00';


启动 restore 于 11-8月 -13
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在还原控制文件
通道 ORA_DISK_1: 还原完成, 用时: 00:00:03
输出文件名=E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL
输出文件名=E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL

完成 restore 于 11-8月 -13


经查看,发现控制文件已经被转储到目标位置;

RMAN> alter database mount;


数据库已装载
释放的通道: ORA_DISK_1


RMAN> recover database;


启动 recover 于 11-8月 -13
启动 implicit crosscheck backup 于 11-8月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=133 设备类型=DISK
已交叉检验的 2 对象
完成 implicit crosscheck backup 于 11-8月 -13

启动 implicit crosscheck copy 于 11-8月 -13
使用通道 ORA_DISK_1
完成 implicit crosscheck copy 于 11-8月 -13

搜索恢复区中的所有文件
正在编制文件目录...
没有为文件编制目录

使用通道 ORA_DISK_1

正在开始介质的恢复

线程 1 序列 190 的归档日志已作为文件 E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG 存在于磁盘上
归档日志文件名=E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG 线程=1 序列=190
介质恢复完成, 用时: 00:00:03
完成 recover 于 11-8月 -13


RMAN> alter database open resetlogs;


数据库已打开

 

其中OCP 有一道考察这样的题目:

Q606. You realize that the control file is damaged in your production database. After restoring the control file from autobackup, what is the next step that you must do to proceed with the database recovery?

 

A. Mount the database

B. Open the database in NORMAL mode

C. Open the database in RESTRICTED mode

D. Open the database with the RESETLOGS option

 

Answer: A


Recovering Using RMAN Backups Restoring the Control File from the Autobackup

Restoring the control file from an autobackup is similar to the steps you use to restore an SPFILE from an autobackup.

RMAN> startup nomount;

RMAN> restore controlfile from autobackup;

RMAN> alter database mount;

RMAN> recover database;

RMAN> alter database open resetlogs;

Note that since there is no control file, you have to open the database with NOMOUNT and then restore the control file. After you mount the database, you must recover the database, because the backup control file contains information about an older version of the database. For the same  reason, you must open the database  with RESETLOGS. RMAN restores the control file to all locations specified by theinitialization parameter CONTROL_FILES. If one or more of those locations are still not available, you will have to edit the CONTROL_FILES parameter to specify alternative locations or temporarily restore the control file to adifferent location;


-----------------------------------------------------------------------------------------------------------------------

博文所有内容均属原创,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

Blog:    http://blog.csdn.net/perfect_db

Email:   perfect_db@sina.com

   QQ:   787266309


  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搞怪的索引

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值