我是靠谱客的博主 呆萌小白菜,最近开发中收集的这篇文章主要介绍RMAN恢复案例之三,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

RMAN恢复丢失控制文件,但是数据文件和联机日志没丢的实验

 

如果控制文件设置了自动备份,则可以通过如下的方法做恢复:
控制文件是否做了自动备份可以通过如下查看:

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
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'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
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 MAXPIECESIZE 500 M;
CONFIGURE MAXSETSIZE TO 1 G;
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_test.f'; # default

模拟控制文件全部丢失:
[oracle@even test]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 27 16:43:06 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

[oracle@even test]$ ll
total 1766284
-rw-r----- 1 oracle oinstall   5251072 Dec 27 16:43 cf_bck_test01.dbf
-rw-r----- 1 oracle oinstall   7061504 Dec 27 16:44 control01.ctl
-rw-r----- 1 oracle oinstall   7061504 Dec 27 16:44 control02.ctl
-rw-r----- 1 oracle oinstall   7061504 Dec 27 16:44 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Dec 27 16:43 example01.dbf
-rw-r----- 1 oracle oinstall 104865792 Dec 27 16:43 example02.dbf
-rw-r----- 1 oracle oinstall 104865792 Dec 27 14:48 example02.dbf.bak
-rw-r----- 1 oracle oinstall 104865792 Dec 27 16:43 MYTBS01.dbf
-rw-r----- 1 oracle oinstall  52429312 Dec 27 16:43 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Dec 27 16:43 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Dec 27 16:43 redo03.log
-rw-r----- 1 oracle oinstall   1056768 Dec 27 16:43 smalltbs01.dbf
-rw-r----- 1 oracle oinstall   1056768 Dec 27 16:43 smalltbs02.dbf
-rw-r----- 1 oracle oinstall 398467072 Dec 27 16:43 sysaux01.dbf
-rw-r----- 1 oracle oinstall 597696512 Dec 27 16:43 system01.dbf
-rw-r----- 1 oracle oinstall  20979712 Dec 23 12:07 temp01.dbf
-rw-r----- 1 oracle oinstall  89137152 Dec 27 16:43 undotbs01.dbf
-rw-r----- 1 oracle oinstall  98312192 Dec 27 16:43 users01.dbf
[oracle@even test]$ rm -rf control01.ctl
[oracle@even test]$ rm -rf control02.ctl                                                                                       
[oracle@even test]$ rm -rf control03.ctl 

[oracle@even 2012_12_27]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 27 16:48:15 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size          1218992 bytes
Variable Size         109053520 bytes
Database Buffers      171966464 bytes
Redo Buffers            2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info

找到最新的自动备份的控制文件进行还原:
RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_27/o1_mf_s_803147791_8fr24j8m_.bkp';

Starting restore at 27-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/app/oracle/oradata/test/control01.ctl
output filename=/u01/app/oracle/oradata/test/control02.ctl
output filename=/u01/app/oracle/oradata/test/control03.ctl
Finished restore at 27-DEC-12

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 27-DEC-12
Starting implicit crosscheck backup at 27-DEC-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=154 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=153 devtype=DISK
Crosschecked 48 objects
Finished implicit crosscheck backup at 27-DEC-12

Starting implicit crosscheck copy at 27-DEC-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Finished implicit crosscheck copy at 27-DEC-12

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_27/o1_mf_s_803147791_8fr24j8m_.bkp

using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

starting media recovery

archive log thread 1 sequence 1 is already on disk as file /u01/app/oracle/oradata/test/redo03.log
archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=1
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-DEC-12

RMAN> sql' alter database open resetlogs';

sql statement:  alter database open resetlogs

现在再次查看数据库的状态是open的了,证明恢复成功。
SQL> select status,instance_name from v$instance;

STATUS       INSTANCE_NAME
------------ ----------------
OPEN         test

最后

以上就是呆萌小白菜为你收集整理的RMAN恢复案例之三的全部内容,希望文章能够帮你解决RMAN恢复案例之三所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部