开启 控制文件自动备份下,参数文件、控制文件全部丢失恢复

简介:

环境说明:本实验在开启 控制文件自动备份的前提下,利用 autobackup 模拟恢复参数文件全部丢失与控制文件全部丢失。
1.开启 AUTOBACKUP 功能
--查看 CONTROLFILE AUTOBACKUP 参数
RMAN> show all;
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
--开启 CONTROLFILE AUTOBACKUP 参数 
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;
new RMAN configuration parameters are successfully stored
--查看 CONTROLFILE AUTOBACKUP 参数
RMAN> show all;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
--做个全库+归档备份
[oracle@11g ~]$ mkdir rmanback
[oracle@11g ~]$ cd rmanba
[oracle@11g rmanbak]$ pwd
/home/oracle/rmanbak
RMAN>
run{
sql 'alter system archive log current';
allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2;
}
说明: autobackup 开启的时候, spfile 与 controlfile 的默认备份位置在 FRA ,而不是 format 指定的备份路径。

2.模拟 SPFILE 丢失 ,恢复 。
--模拟 SPFILE 丢失,且 shutdown
[oracle@11g rmanbak]$ cd $ORACLE_HOME/dbs
[oracle@11g dbs]$ ll
total 9852
-rw-rw----. 1 oracle oinstall 1544 Mar 18 05:05 hc_orcl.dat
-rw-r--r--. 1 oracle oinstall 5955 Mar 11 18:10 init.ora
-rw-r--r--. 1 oracle oinstall 5949 Mar 15 11:05 initorcl.ora
-rw-r-----. 1 oracle oinstall 24 Mar 11 16:54 lkORCL
-rw-r-----. 1 oracle oinstall 1536 Mar 11 16:35 orapworcl
-rw-r-----. 1 oracle oinstall 10043392 Mar 18 14:51 snapcf_orcl.f
-rw-r-----. 1 oracle oinstall 13824 Mar 18 14:48 spfileorcl.ora
[oracle@11g dbs]$ rm -rf spfileorcl.ora
[oracle@11g dbs]$ rm -rf initorcl.ora
[oracle@11g dbs]$ rm -rf init.ora
SQL> shutdown immediate;
SQL> startup;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/oracle/app/oracle/product/11.2.0.4/dbhome_1/dbs/initorcl.ora'
RMAN> set dbid= 1388303183

executing command: SET DBID
RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/oracle/app/oracle/product/11.2.0.4/dbhome_1/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 281019272 bytes
Database Buffers 780140544 bytes
Redo Buffers 5517312 bytes

RMAN> list backup of spfile;
--通过自动备份恢复
RMAN> restore spfile to '/home/oracle/spfileorcl.ora' from autobackup;
--通过某个备份文件恢复
RMAN> restore spfile to '/home/oracle/spfileorcl.ora' from '/home/oracle/app/flash_recovery_area/ORCL/autobackup/2015_03_18/o1_mf_s_874680707_bjmlb45y_.bkp'; 
Finished restore at 18-MAR-15
[oracle@11g ~]$ pwd
/home/oracle
[oracle@11g dbs]$ ll
-rw-r-----. 1 oracle oinstall 13824 Mar 18 15:38 spfileorcl.ora
[oracle@11g ~]$ cp spfileorcl.ora $ORACLE_HOME/dbs
RMAN> shutdown immediate;
RMAN> startup;
database opened

3. 模拟Controlfile全部丢失,恢复 。
SQL> show parameter control_file
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /home/oracle/app/oradata/orcl/
control01.ctl, /home/oracle/ap
p/flash_recovery_area/orcl/con
trol02.ctl

[oracle@11g dbs]$ cd /home/oracle/app/oradata/orcl
[oracle@11g orcl]$ mv control01.ctl control01.ctl.bak
[oracle@11g orcl]$ cd /home/oracle/app/flash_recovery_area/orcl/
[oracle@11g orcl]$ mv control02.ctl control02.ctl.bak
SQL> startup;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
ORA-00205: error in identifying control file, check alert log for more info
-- 有 ORACLE 进程,说明已经启动到 nomount 
[oracle@11g ~]$ ps -ef|grep ora_
oracle 25331 1 0 11:23 ? 00:00:00 ora_pmon_orcl
oracle 25333 1 0 11:23 ? 00:00:00 ora_psp0_orcl
[oracle@11g ~]$ rman target /
说明:控制文件恢复 如果有控制文件自动备份 直接通过 autobackup 恢复,没有的话就通过指定控制文件备份集恢复。
--通过自动备份恢复 
RMAN>restore controlfile from autobackup;
Finished restore at 18-MAR-15
--通过某个备份文件恢复
RMAN> list backup of controlfile;
RMAN> restore controlfile from '/u01/backup/ctl_file_1lo65676_1_1_20130403';
RMAN>alter database mount;
RMAN>recover database;
archived log for thread 1 with sequence 1 is already on disk as file /home/oracle/app/oradata/orcl/redo01.log
archived log file name=/home/oracle/app/oradata/orcl/redo01.log thread=1 sequence=1
media recovery complete, elapsed time: 00:00:01
Finished recover at 19-MAR-15
RMAN>alter database open resetlogs;
Database altered.

 

文章可以转载,必须以链接形式标明出处。


本文转自 张冲andy 博客园博客,原文链接: http://www.cnblogs.com/andy6/p/6755788.html如需转载请自行联系原作者
相关文章
|
Oracle 关系型数据库 数据库
2、参数文件的备份与恢复
参数文件的备份与恢复
156 0
|
SQL Oracle 关系型数据库
3、控制文件的备份与恢复
控制文件的备份与恢复
138 0
|
Oracle 关系型数据库 数据库
4、数据文件的备份与恢复
数据文件的备份与恢复
136 0
|
SQL Oracle 关系型数据库
oracle数据库控制文件的备份和恢复之一手动备份和恢复
实验步骤:手动备份和恢复oracle控制文件
592 0
|
Oracle 关系型数据库 数据库
oracle数据库控制文件的备份和恢复之三RMAN自动备份和恢复
使用RMAN自动备份的控制文件向数据库中恢复控制文件
380 0
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库 数据库