【oracle】rman 控制文件恢复

Posted on 2012-12-19 16:04  雅飞士  阅读(520)  评论(0编辑  收藏  举报


1.重命名控制文件:

[oracle@yfs orcl]$ ll | grep ctl
-rw-r-----. 1 oracle oinstall   10960896 Dec 17 16:22 control01.ctl
[oracle@yfs orcl]$ mv control01.ctl control01.ctl_bak

2.启动数据库,发现出错了:

SQL> startup
ORACLE instance started.
Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             281018648 bytes
Database Buffers           25165824 bytes
Redo Buffers                4747264 bytes
ORA-00205: error in identifying control file, check alert log for more info

3.这时候就可以用rman恢复了

[oracle@yfs log]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Dec 17 17:15:33 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (not mounted)
RMAN> set dbid 1325071312
executing command: SET DBID

由于 配置了 CONFIGURE CONTROLFILE AUTOBACKUP ON;

所以执行下面命令即可:
RMAN> restore controlfile from autobackup;
Starting restore at 20121217171629
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
recovery area destination: /s01/fast_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /s01/fast_recovery_area/ORCL/autobackup/2012_12_17/o1_mf_s_802282180_8dxo2ng2_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20121217
channel ORA_DISK_1: restoring control file from AUTOBACKUP /s01/fast_recovery_area/ORCL/autobackup/2012_12_17/o1_mf_s_802282180_8dxo2ng2_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/oradata/orcl/control01.ctl
output file name=/s01/fast_recovery_area/orcl/control02.ctl
Finished restore at 20121217171635
如果没配置该默认选项,测可以这样:‘controlfile’

restore controlfile from ‘controlfile’;

4.挂载数据库:

RMAN> sql 'alter database mount';
sql statement: alter database mount
released channel: ORA_DISK_1

[oracle@yfs orcl]$ ll | grep ctl                    
-rw-r-----. 1 oracle oinstall   10960896 Dec 17 17:17 control01.ctl
-rw-r-----. 1 oracle oinstall   10960896 Dec 17 16:22 control01.ctl_bak

5.修复数据库:

RMAN> restore database;


6.恢复数据库:

RMAN> recover database;
Starting recover at 20121217172026
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file /oradata/orcl/redo01.log
archived log file name=/oradata/orcl/redo01.log thread=1 sequence=1
media recovery complete, elapsed time: 00:00:07
Finished recover at 20121217172039

7.resetlog 方式打开数据库:
RMAN> sql 'alter database open resetlogs';
sql statement: alter database open resetlogs

8.查看数据库状态:

SQL> select instance_name,status from v$instance
  2  /
INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

--EOF

 

原文地址:http://blog.yafeishi.net/2012/12/oracle-rman-simple-controlfile-restore.html

Copyright © 2024 雅飞士
Powered by .NET 9.0 on Kubernetes