rman 全备与恢复

虚拟机上oracle 11.2

一个RMAN模拟过程。

STEP1,

[oracle@localhost ~]$ sqlplus / as sysdba

 

SQL> create table tx1 as select  * from dba_objects where rownum<2;

 

STEP2

[oracle@localhost ~]$ rman target /

RMAN> backup database;

Starting backup at 18-APR-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=141 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/oradata/dbtest/system01.dbf

input datafile file number=00002 name=/u01/oradata/dbtest/sysaux01.dbf

input datafile file number=00003 name=/u01/oradata/dbtest/undotbs01.dbf

input datafile file number=00004 name=/u01/oradata/dbtest/users01.dbf

channel ORA_DISK_1: starting piece 1 at 18-APR-11

channel ORA_DISK_1: finished piece 1 at 18-APR-11

piece handle=/u01/flash_recovery_area/DBTEST/backupset/2011_04_18/o1_mf_nnndf_TAG20110418T001007_6tp47277_.bkp tag=TAG20110418T001007 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:38

Finished backup at 18-APR-11

 

Starting Control File and SPFILE Autobackup at 18-APR-11

piece handle=/u01/flash_recovery_area/DBTEST/autobackup/2011_04_18/o1_mf_s_748743166_6tp4d14q_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 18-APR-11

 

STEP3

SQL> create table tx2 as select * from tx1;

 

Table created.

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  627732480 bytes

Fixed Size                  1338336 bytes

Variable Size             255853600 bytes

Database Buffers          364904448 bytes

Redo Buffers                5636096 bytes

 

STEP4

[oracle@localhost ~]$ rman target /

RMAN> restore controlfile from '/u01/flash_recovery_area/DBTEST/autobackup/2011_04_18/o1_mf_s_748743166_6tp4d14q_.bkp'

2> ;

 

Starting restore at 18-APR-11

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

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

output file name=/u01/oradata/dbtest/control01.ctl

output file name=/u01/flash_recovery_area/dbtest/control02.ctl

Finished restore at 18-APR-11

 

RMAN> restore database ;

 

Starting restore at 18-APR-11

released channel: ORA_DISK_1

Starting implicit crosscheck backup at 18-APR-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=10 device type=DISK

Crosschecked 6 objects

Finished implicit crosscheck backup at 18-APR-11

 

Starting implicit crosscheck copy at 18-APR-11

using channel ORA_DISK_1

Finished implicit crosscheck copy at 18-APR-11

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

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

File Name: /u01/flash_recovery_area/DBTEST/autobackup/2011_04_18/o1_mf_s_748743166_6tp4d14q_.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 /u01/oradata/dbtest/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/dbtest/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/dbtest/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/dbtest/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/flash_recovery_area/DBTEST/backupset/2011_04_18/o1_mf_nnndf_TAG20110418T001007_6tp47277_.bkp

channel ORA_DISK_1: piece handle=/u01/flash_recovery_area/DBTEST/backupset/2011_04_18/o1_mf_nnndf_TAG20110418T001007_6tp47277_.bkp tag=TAG20110418T001007

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:56

Finished restore at 18-APR-11

 

STEP5,

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 

 

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

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

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

 

STEP6,

SQL> startup

ORACLE instance started.

 

Total System Global Area  627732480 bytes

Fixed Size                  1338336 bytes

Variable Size             255853600 bytes

Database Buffers          364904448 bytes

Redo Buffers                5636096 bytes

ORA-00214: control file '/u01/flash_recovery_area/dbtest/control02.ctl' version

1351 inconsistent with file '/u01/oradata/dbtest/control01.ctl' version 1342

 

SQL> alter system set control_files='/u01/flash_recovery_area/dbtest/control02.ctl' scope=spfile;

 

System altered.

 

RMAN> restore database datafile 1;

 

Starting restore at 18-APR-11

Starting implicit crosscheck backup at 18-APR-11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=10 device type=DISK

Crosschecked 6 objects

Finished implicit crosscheck backup at 18-APR-11

 

Starting implicit crosscheck copy at 18-APR-11

using channel ORA_DISK_1

Finished implicit crosscheck copy at 18-APR-11

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

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

File Name: /u01/flash_recovery_area/DBTEST/autobackup/2011_04_18/o1_mf_s_748743166_6tp4d14q_.bkp

 

using channel ORA_DISK_1

 

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

skipping datafile 2; already restored to file /u01/oradata/dbtest/sysaux01.dbf

skipping datafile 3; already restored to file /u01/oradata/dbtest/undotbs01.dbf

skipping datafile 4; already restored to file /u01/oradata/dbtest/users01.dbf

restore not done; all files read only, offline, or already restored

Finished restore at 18-APR-11

RMAN> sql 'alter database open resetlogs';

 

sql statement: alter database open resetlogs

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

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

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

RMAN-03009: failure of sql command on default channel at 04/18/2011 03:06:09

RMAN-11003: failure during parse/execution of SQL statement: alter database open resetlogs

ORA-01113: file 1 needs media recovery

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

STEP7

SQL> alter database open resetlogs;

 

Database altered.

这块时间稍微长点!

SQL> select count(*) from tx2;

 

  COUNT(*)

----------

         1

 

SQL> select count(*) from tx1;

 

  COUNT(*)

----------

         1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11813230/viewspace-693092/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/11813230/viewspace-693092/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值