RMAN 恢復之控制檔案篇(2/5)

djb1008發表於2011-06-07

1.2 場景一:使用舊的控制檔案進行備份恢復

1.2.1 模擬災難發生

異常停止資料庫:

Sqlplus / as sysdba

Sql>shutdown abort;

刪除所有資料庫檔案:

$Rm –rf /oradata/gcwz_web/*

[@more@]

1.2.2 恢復控制檔案

以舊的控制檔案為模板恢復控制檔案。

本案例如果沒有舊的控制檔案,可以使用附件二的方法,建立全新的控制檔案,恢復的方法與本案例完全相同。

Sqlplus / as sysdba

Startup nomount

或者startup nomount pfile=’ /oracle/product/10.2.0/db_1/dbs/initgcwz_web.ora’;

Rman target /

RMAN> restore controlfile from '/rman/cntrl_69_1_709899322'; ##使用全備份前的控制檔案備份進行恢復

Starting restore at 02-FEB-10

output filename=/oradata/gcwz_web/control01.ctl

output filename=/oradata/gcwz_web/control02.ctl

output filename=/oradata/gcwz_web/control03.ctl

Finished restore at 02-FEB-10

1.2.3 登記最新的rman備份資訊

Rman>sql ‘alter database mount’;

Rman>list backup of database;

BS Key Type LV Size Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

47 Incr 1 52.25M SBT_TAPE 00:00:59 28-JAN-10

BP Key: 47 Status: AVAILABLE Compressed: NO Tag: HOT_DB_BK_LEVEL0

Handle: bk_65_1_709485972 Media:

List of Datafiles in backup set 47

File LV Type Ckp SCN Ckp Time Name

---- -- ---- ---------- --------- ----

1 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/system01.dbf

2 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/undotbs01.dbf

3 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/sysaux01.dbf

4 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/users01.dbf

舊的控制檔案裡只能檢視舊的全庫備份的資訊,所以需要執行下面的命令將新的全庫備份資訊匯入到控制檔案中.

RMAN> catalog start with '/rman/';

searching for all files that match the pattern /rman/

List of Files Unknown to the Database

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

File Name: /rman/cntrl_69_1_709899322

File Name: /rman/full_72_709900586_1

File Name: /rman/full_71_709900579_1

File Name: /rman/control_73

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

List of Cataloged Files

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

File Name: /rman/cntrl_69_1_709899322

File Name: /rman/full_72_709900586_1

File Name: /rman/full_71_709900579_1

File Name: /rman/control_73

RMAN> list backup of database;

---- -- ---- ---------- --------- ----

1 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/system01.dbf

2 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/undotbs01.dbf

3 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/sysaux01.dbf

4 1 Incr 915570 28-JAN-10 /oradata/gcwz_web/users01.dbf

---- -- ---- ---------- --------- ----

1 Full 1129995 02-FEB-10 /oradata/gcwz_web/system01.dbf

2 Full 1129995 02-FEB-10 /oradata/gcwz_web/undotbs01.dbf

3 Full 1129995 02-FEB-10 /oradata/gcwz_web/sysaux01.dbf

4 Full 1129995 02-FEB-10 /oradata/gcwz_web/users01.dbf

5 Full 1129995 02-FEB-10 /oradata/gcwz_web/test01.dbf

1.2.4 資料庫restorerecover

RMAN> run{

2> allocate channel d1 type disk;

3> restore database;

4> release channel d1;}

restoring datafile 00001 to /oradata/gcwz_web/system01.dbf

restoring datafile 00002 to /oradata/gcwz_web/undotbs01.dbf

restoring datafile 00003 to /oradata/gcwz_web/sysaux01.dbf

restoring datafile 00004 to /oradata/gcwz_web/users01.dbf

restoring datafile 00005 to /oradata/gcwz_web/test01.dbf

Finished restore at 02-FEB-10

released channel: d1

RMAN> catalog start with '/archivelog/';

searching for all files that match the pattern /archivelog/

List of Files Unknown to the Database

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

File Name: /archivelog/1_60_690800133.dbf

File Name: /archivelog/1_59_690800133.dbf

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

List of Cataloged Files

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

File Name: /archivelog/1_60_690800133.dbf

File Name: /archivelog/1_59_690800133.dbf

RMAN> recover database;

archive log thread 1 sequence 60 is already on disk as file /archivelog/1_60_690800133.dbf

archive log filename=/archivelog/1_59_690800133.dbf thread=1 sequence=59

Oracle Error:

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

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

ORA-01110: data file 1: '/oradata/gcwz_web/system01.dbf'

RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/archivelog/1_59_690800133.dbf'

ORA-00328: archived log ends at change 1129917, need later change 1129959

ORA-00334: archived log: '/archivelog/1_59_690800133.dbf'

RMAN> restore datafile 1;

Starting restore at 02-FEB-10

using channel ORA_DISK_1

skipping datafile 1; already restored to file /oradata/gcwz_web/system01.dbf

restore not done; all files readonly, offline, or already restored

Finished restore at 02-FEB-10

本次實驗的最大收穫,當出現datafile 1 或者其它檔案(users01.dbf) RECOVER succeeded but OPEN RESETLOGS would get error below 的問題時,其實根本不需要重新進行RESTORE DB的操作(這個操作是最耗時間的操作)。上面的問題是因為使用了舊的控制檔案,所以需要使用下面的命令進行recover操作。

Sql>recover database using backup controlfile;

/archivelog/1_60_690800133.dbf

media recovery ok

Sql>alter database open resetlogs;

Database opened.

上一篇: RMAN 恢復之控制檔案篇(1/5)

下一篇: RMAN 恢復之控制檔案篇(3/5)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/32980/viewspace-1050879/,如需轉載,請註明出處,否則將追究法律責任。

相關文章