您的位置:首页 > 博客中心 > 数据库 >

RMAN恢复数据库实战

时间:2022-03-14 18:00

预设场景:

一般企业数据库的数据都用rman工具进行了全库备份,那么当数据库里面的控制文件,重做日志文件等全部丢失了之后怎么办呢?以下是解答思路:

1、利用全库备份的备份片恢复控制文件

2、恢复数据文件

3、挂载数据库

以下是详细步骤:

1 、先用rman restore备份的全库,找回控制文件:

RMAN>  restore controlfile from ‘/u01/app/oracle/flash_recovery_area/JIAGULUN/backupset/2016_02_01/o1_mf_ncsnf_TAG20160201T122728_cbxqp0go_.bkp‘;


Starting restore at 01-FEB-16

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:03

output filename=/u01/app/oracle/oradata/jiagulun/control01.ctl

output filename=/u01/app/oracle/oradata/jiagulun/control02.ctl

output filename=/u01/app/oracle/oradata/jiagulun/control03.ctl

Finished restore at 01-FEB-16


RMAN> alter database mount;


database mounted

released channel: ORA_DISK_1

##########################################################################################################################################################################################################################################################################################################################################################################################

验证:

[oracle@oracle ~]$ cd /u01/app/oracle/oradata/jiagulun/

[oracle@oracle jiagulun]$ ll                             ----控制文件已找回

total 20688

-rw-r----- 1 oracle oinstall 7061504 Feb  1 12:32 control01.ctl

-rw-r----- 1 oracle oinstall 7061504 Feb  1 12:32 control02.ctl

-rw-r----- 1 oracle oinstall 7061504 Feb  1 12:32 control03.ctl

#############################################################################################################################################################################################

#############################################################################################################################################################################################

#############################################################################################################################################################################################

2、恢复数据文件

RMAN> restore database;


Starting restore at 01-FEB-16

Starting implicit crosscheck backup at 01-FEB-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 01-FEB-16


Starting implicit crosscheck copy at 01-FEB-16

using channel ORA_DISK_1

Crosschecked 8 objects

Finished implicit crosscheck copy at 01-FEB-16


searching for all files in the recovery area

cataloging files...

cataloging done


List of Cataloged Files

=======================

File Name: /u01/app/oracle/flash_recovery_area/JIAGULUN/backupset/2016_02_01/o1_mf_ncsnf_TAG20160201T122728_cbxqp0go_.bkp


using channel ORA_DISK_1


channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/app/oracle/oradata/jiagulun/system01.dbf

restoring datafile 00002 to /u01/app/oracle/oradata/jiagulun/undotbs01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/jiagulun/sysaux01.dbf

restoring datafile 00004 to /u01/app/oracle/oradata/jiagulun/users01.dbf

restoring datafile 00005 to /u01/app/oracle/oradata/jiagulun/example01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/JIAGULUN/backupset/2016_02_01/o1_mf_nnndf_TAG20160201T122728_cbxqok7r_.bkp

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/app/oracle/flash_recovery_area/JIAGULUN/backupset/2016_02_01/o1_mf_nnndf_TAG20160201T122728_cbxqok7r_.bkp tag=TAG20160201T122728

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

Finished restore at 01-FEB-16

##########################################################################################################################################################################################################################################################################################################################################################################################

验证:

[oracle@oracle ~]$ cd /u01/app/oracle/oradata/jiagulun/

[oracle@oracle jiagulun]$ ll

total 911612

-rw-r----- 1 oracle oinstall   7061504 Feb  1 12:40 control01.ctl

-rw-r----- 1 oracle oinstall   7061504 Feb  1 12:40 control02.ctl

-rw-r----- 1 oracle oinstall   7061504 Feb  1 12:40 control03.ctl

-rw-r----- 1 oracle oinstall 104865792 Feb  1 12:37 example01.dbf

-rw-r----- 1 oracle oinstall 262152192 Feb  1 12:37 sysaux01.dbf

-rw-r----- 1 oracle oinstall 503324672 Feb  1 12:37 system01.dbf

-rw-r----- 1 oracle oinstall  36708352 Feb  1 12:37 undotbs01.dbf

-rw-r----- 1 oracle oinstall   5251072 Feb  1 12:37 users01.dbf

#############################################################################################################################################################################################

#############################################################################################################################################################################################

#############################################################################################################################################################################################

RMAN> alter database open resetlogs;


RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of alter db command at 02/01/2016 12:41:48

ORA-01152: file 1 was not restored from a sufficiently old backup 

ORA-01110: data file 1: ‘/u01/app/oracle/oradata/jiagulun/system01.dbf‘


RMAN> recover database;


Starting recover at 01-FEB-16

using channel ORA_DISK_1


starting media recovery


unable to find archive log

archive log thread=1 sequence=11

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 02/01/2016 12:42:06

RMAN-06054: media recovery requesting unknown log: thread 1 seq 11 lowscn 653723


RMAN> alter database open resetlogs;                  -------------与可以打开数据库


database opened

##########################################################################################################################################################################################################################################################################################################################################################################################

验证是否恢复成功:

[oracle@oracle jiagulun]$ sqlplus / as sysdba


SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 1 12:45:31 2016


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



Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options


SQL> startup force;

ORACLE instance started.


Total System Global Area 1174405120 bytes

Fixed Size                  2020288 bytes

Variable Size             301993024 bytes

Database Buffers          855638016 bytes

Redo Buffers               14753792 bytes

Database mounted.

Database opened.


已能打开数据库,恢复成功

本文出自 “” 博客,谢绝转载!

本类排行

今日推荐

热门手游