ITPub博客

首页 > 数据库 > Oracle > RMAN 恢复之控制文件篇(2/5)

RMAN 恢复之控制文件篇(2/5)

原创 Oracle 作者:djb1008 时间:2011-06-07 11:25:40 0 删除 编辑

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 数据库restore和recover

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博客 ” ,链接:https://blog.itpub.net/32980/viewspace-1050879/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-27

  • 博文量
    175
  • 访问量
    778866