恢复之破坏一个控制文件

本文详细介绍使用 Oracle RMAN 工具进行数据库备份与恢复的过程。包括配置自动备份控制文件、执行完全备份并删除过期归档、从自动备份中恢复控制文件、还原及恢复数据库等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

--自动备份控制文件

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

--完全备份,删除过期归档
backup database plus archivelog delete input;

--4个备份集,spfile与控制文件在一个备份集中
 list backupset;
[oracle@linuxoracle orcl]$ ls
arc.dbf        example01.dbf  redo02.log  sde.dbf       system01.dbf  test.txt       users01.dbf
control01.ctl  redo01.log     redo03.log  sysaux01.dbf  temp01.dbf    undotbs01.dbf
[oracle@linuxoracle orcl]$ cp test.txt control01.ctl

--nomount状态

RMAN> startup nomount

Oracle instance started

Total System Global Area     417546240 bytes

Fixed Size                     2228944 bytes
Variable Size                318770480 bytes
Database Buffers              88080384 bytes
Redo Buffers                   8466432 bytes

--从自动备份中恢复控制文件

RMAN> restore controlfile from autobackup;    

Starting restore at 07-NOV-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK

recovery area destination: /home/gyh/oracle/fast_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /home/gyh/oracle/fast_recovery_area/ORCL/autobackup/2012_11_07/o1_mf_s_798688228_89ncq6xr_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /home/gyh/oracle/fast_recovery_area/ORCL/autobackup/2012_11_07/o1_mf_s_798688228_89ncq6xr_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/home/gyh/oracle/oradata/orcl/control01.ctl
output file name=/home/gyh/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 07-NOV-12

--mount状态

RMAN> startup mount;

database is already started
database mounted
released channel: ORA_DISK_1

--不能打开

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/07/2012 02:01:02
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

--resetlogs模式打开

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/07/2012 02:01:12
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/home/gyh/oracle/oradata/orcl/system01.dbf'

--还原数据库

RMAN> restore database;

Starting restore at 07-NOV-12
Starting implicit crosscheck backup at 07-NOV-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 07-NOV-12

Starting implicit crosscheck copy at 07-NOV-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 07-NOV-12

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

List of Cataloged Files
=======================
File Name: /home/gyh/oracle/fast_recovery_area/ORCL/autobackup/2012_11_07/o1_mf_s_798688228_89ncq6xr_.bkp

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/gyh/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/gyh/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/gyh/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/gyh/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/gyh/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/gyh/oracle/oradata/orcl/sde.dbf
channel ORA_DISK_1: restoring datafile 00007 to /home/gyh/oracle/oradata/orcl/arc.dbf
channel ORA_DISK_1: reading from backup piece /home/gyh/oracle/fast_recovery_area/ORCL/backupset/2012_11_07/o1_mf_nnndf_TAG20121107T014751_89ncl7ol_.bkp
channel ORA_DISK_1: piece handle=/home/gyh/oracle/fast_recovery_area/ORCL/backupset/2012_11_07/o1_mf_nnndf_TAG20121107T014751_89ncl7ol_.bkp tag=TAG20121107T014751
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:36
Finished restore at 07-NOV-12

--恢复数据库

RMAN> recover database;

Starting recover at 07-NOV-12
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 4 is already on disk as file /home/gyh/oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 5 is already on disk as file /home/gyh/oracle/oradata/orcl/redo02.log
archived log file name=/home/gyh/oracle/oradata/orcl/redo01.log thread=1 sequence=4
archived log file name=/home/gyh/oracle/oradata/orcl/redo02.log thread=1 sequence=5
media recovery complete, elapsed time: 00:00:03
Finished recover at 07-NOV-12

--resetlogs方式打开

RMAN> alter database open resetlogs;


 

 

 


 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值