ITPub博客

首页 > 数据库 > Oracle > 当前控制文件全部丢失恢复

当前控制文件全部丢失恢复

原创 Oracle 作者:orclwujian 时间:2015-04-28 16:15:16 1 删除 编辑

当前控制文件全部丢失恢复实验、
(该情况模拟所有在线控制文件丢失,正常情况下控制文件有多份放在不同的磁盘上,如果损坏当前的控制文件,可以将其他在线控制文件CP过去就行了)
先给数据库做个全备
[orcl@gitiracb ~]$ rman target/

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Apr 28 14:53:33 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1405653344)

RMAN> run{
         allocate channel c1 type disk;
         allocate channel c2 type disk;
         backup incremental level 0 tag 'db0' format '/backup/db0%d_%s_%p_%t'
         database skip inaccessible;
         sql 'alter system archive log current';
         backup format '/backup/arch%d_%s_%p_%t'
         archivelog all delete input;
         backup format '/backup/ctl%d_%s_%p_%t' current controlfile;
         release channel c1;
         release channel c2;
         }

之后再到数据库里创建一些数据
SQL> create table test as select * from dba_objects where rownum<=2000;

Table created.

SQL> select count(*) from test;

  COUNT(*)
----------
      2000
查询在线控制文件所在目录
SQL> set linesize100;
SQL> show parameter control_files;

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
control_files                        string                 /home/orcl/app/oradata/orcl/co
                                                            ntrol01.ctl, /home/orcl/app/fa
                                                            st_recovery_area/orcl/control0
                                                            2.ctl
可以看到有两个在线控制文件
我们用rm掉两个控制文件
我可以在alter文件中看到下面的错误
Errors in file /home/orcl/app/diag/rdbms/orcl/orcl/trace/orcl_m001_11273.trc:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/home/orcl/app/oradata/orcl/control01.ctl'
ORA-27041: unable to open file

关闭数据库
SQL> shutdown immediate;
Database closed.
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/home/orcl/app/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
尝试用abort关闭
SQL> shutdown abort;
ORACLE instance shut down.
成功关闭
尝试startup打开数据库
SQL> startup;
ORACLE instance started.

Total System Global Area 3373858816 bytes
Fixed Size                  2233040 bytes
Variable Size            1845497136 bytes
Database Buffers         1509949440 bytes
Redo Buffers               16179200 bytes
ORA-00205: error in identifying control file, check alert log for more info
无法打开,只能从之前的备份中恢复控制文件,并执行不完全恢复

RMAN> restore controlfile from '/backup/ctlORCL_26_1_878223591';

Starting restore at 28-APR-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=98 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/home/orcl/app/oradata/orcl/control01.ctl
output file name=/home/orcl/app/fast_recovery_area/orcl/control02.ctl
Finished restore at 28-APR-15
利用备份恢复控制文件
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1
无法open控制文件是用之前的备份还原的,与当前数据库的物理结构和SCN号不一致,需restore数据库,再用归档日志recover database;
RMAN> restore database;
RMAN> recover database;  

RMAN> alter database open resetlogs;
database opened

SQL> select count(*) from test;

  COUNT(*)
----------
      2000

可以看到数据正常



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29989552/viewspace-1609027/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-10-29

  • 博文量
    95
  • 访问量
    322711