天天看點

RMAN恢複資料庫實戰

預設場景:

一般企業資料庫的資料都用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

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

RMAN> restore database;

Starting implicit crosscheck backup at 01-FEB-16

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

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

[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-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

starting media recovery

unable to find archive log

archive log thread=1 sequence=11

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.

已能打開資料庫,恢複成功

     本文轉自陳繼松 51CTO部落格,原文連結:http://blog.51cto.com/chenjisong/1740385,如需轉載請自行聯系原作者