探索ORACLE之RMAN_04非一致性备份

来源:互联网 发布:用户画像数据来源 编辑:程序博客网 时间:2024/06/05 13:40

探索ORACLERMAN_04非一致性备份

作者:吴伟龙

 

在上一篇博文中提到了数据库的一致性备份,操作非常的简单。只需要一条很短的命令即可完成,但是如果要创建一正式库的备份,一般不建议用一致性备份,也不建议用很简单的名来完成。而是更多的采用脚本实现非一致性备份,这样将可通过backup+archive log+redo有效的将数据恢复到最近一次改变的状态,可以达到数据的丢失最小化。

创建非一致性备份

 创建非一致性备份数据库必须处于归档(archivelog)模式,因为非一致性备份的数据库文件和控制文件的SCN号可能会不一致。并且可以在数据库打开并不影响业务的情况下完成数据的备份工作;那么这样的备份将是不一致性的备份,那么如果要恢复可以通过backup+archive log+redo恢复到最近一次日志切换时候的数据,而不是最后一次备份时候的数据。

1.1检查归档状态:

SQL> archive log list;

Database log mode           No Archive Mode

Automaticarchival             Disabled

Archivedestination           USE_DB_RECOVERY_FILE_DEST

Oldest onlinelog sequence      9

Current logsequence           11

SQL>

 

必须打开归档归档

SQL> shutdown immediate   -----打开归档必须将数据库重启到mount状态

Databaseclosed.

Databasedismounted.

ORACLE instanceshut down.

SQL> startup mount;

ORACLE instancestarted.

 

Total SystemGlobal Area  285212672 bytes

Fixed Size                  1218968 bytes

VariableSize              79693416 bytes

DatabaseBuffers          197132288 bytes

RedoBuffers                7168000 bytes

Databasemounted.

 

SQL> alter database archivelog;     ----执行开启归档命令

 

Databasealtered.

 

SQL> alter database open;          -----打开数据库

 

Databasealtered.

 

SQL> colinstance_name format a15

SQL> select instance_name,status from v$instance;    ----查看数据库状态

INSTANCE_NAME  STATUS

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

WWL            OPEN

SQL>

SQL> archive log list;                   ------查看归档状态,已经是归档状态了

Database log mode             Archive Mode

Automatic archival            Enabled

Archivedestination           USE_DB_RECOVERY_FILE_DEST

Oldest onlinelog sequence     9

Next logsequence to archive   11

Current logsequence           11

SQL>

 

1.2执行备份  (执行备份命令实际上是跟一致性备份是一样的)

1.2.1       备份数据库

RMAN> backup database;

 

Starting backupat 23-MAY-12

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=145 devtype=DISK

channelORA_DISK_1: starting full datafile backupset

channelORA_DISK_1: specifying datafile(s) in backupset

input datafilefno=00001 name=/DBData/WWL/system01.dbf

input datafilefno=00003 name=/DBData/WWL/sysaux01.dbf

input datafilefno=00002 name=/DBData/WWL/undotbs01.dbf

input datafilefno=00004 name=/DBData/WWL/users01.dbf

channelORA_DISK_1: starting piece 1 at 23-MAY-12

channelORA_DISK_1: finished piece 1 at 23-MAY-12

piecehandle=/DBBak/bak_WWL_05_23_0anbmtkr_1_1 tag=TAG20120523T121210 comment=NONE

channelORA_DISK_1: backup set complete, elapsed time: 00:01:46

Finished backupat 23-MAY-12

 

Starting ControlFile and SPFILE Autobackup at 23-MAY-12

piecehandle=/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-00 comment=NONE

Finished ControlFile and SPFILE Autobackup at 23-MAY-12

 

RMAN>

 

 

1.2.2       备份USER表空间

RMAN> backuptablespace users;

 

Starting backupat 23-MAY-12

using channelORA_DISK_1

channelORA_DISK_1: starting full datafile backupset

channelORA_DISK_1: specifying datafile(s) in backupset

input datafilefno=00004 name=/DBData/WWL/users01.dbf

channelORA_DISK_1: starting piece 1 at 23-MAY-12

channelORA_DISK_1: finished piece 1 at 23-MAY-12

piecehandle=/DBBak/bak_WWL_05_23_0cnbn2a3_1_1 tag=TAG20120523T133147 comment=NONE

channelORA_DISK_1: backup set complete, elapsed time: 00:00:04

Finished backupat 23-MAY-12

 

Starting ControlFile and SPFILE Autobackup at 23-MAY-12

piece handle=/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-01comment=NONE

Finished ControlFile and SPFILE Autobackup at 23-MAY-12

 

RMAN>

 

1.2.3       备份数据文件

RMAN> backup datafile 1,2,3;

 

Starting backupat 23-MAY-12

using channelORA_DISK_1

channelORA_DISK_1: starting full datafile backupset

channelORA_DISK_1: specifying datafile(s) in backupset

input datafilefno=00001 name=/DBData/WWL/system01.dbf

input datafilefno=00003 name=/DBData/WWL/sysaux01.dbf

input datafile fno=00002name=/DBData/WWL/undotbs01.dbf

channelORA_DISK_1: starting piece 1 at 23-MAY-12

channelORA_DISK_1: finished piece 1 at 23-MAY-12

piecehandle=/DBBak/bak_WWL_05_23_0enbn2bk_1_1 tag=TAG20120523T133235 comment=NONE

channelORA_DISK_1: backup set complete, elapsed time: 00:01:48

Finished backupat 23-MAY-12

 

Starting ControlFile and SPFILE Autobackup at 23-MAY-12

piecehandle=/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-02 comment=NONE

Finished ControlFile and SPFILE Autobackup at 23-MAY-12

 

RMAN>

 

1.2.4       备份控制文件

RMAN> backup current controlfile;

 

Starting backupat 23-MAY-12

using channelORA_DISK_1

channelORA_DISK_1: starting full datafile backupset

channelORA_DISK_1: specifying datafile(s) in backupset

includingcurrent control file in backupset

channelORA_DISK_1: starting piece 1 at 23-MAY-12

channelORA_DISK_1: finished piece 1 at 23-MAY-12

piecehandle=/DBBak/bak_WWL_05_23_0gnbn2je_1_1 tag=TAG20120523T133645 comment=NONE

channelORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backupat 23-MAY-12

 

Starting ControlFile and SPFILE Autobackup at 23-MAY-12

piecehandle=/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-03 comment=NONE

Finished ControlFile and SPFILE Autobackup at 23-MAY-12

 

RMAN>

 

1.2.5       备份spfile文件

RMAN> backup spfile;

 

Starting backupat 23-MAY-12

using channelORA_DISK_1

channelORA_DISK_1: starting full datafile backupset

channelORA_DISK_1: specifying datafile(s) in backupset

includingcurrent SPFILE in backupset

channelORA_DISK_1: starting piece 1 at 23-MAY-12

channelORA_DISK_1: finished piece 1 at 23-MAY-12

piecehandle=/DBBak/bak_WWL_05_23_0inbn2l2_1_1 tag=TAG20120523T133737 comment=NONE

channelORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backupat 23-MAY-12

 

Starting ControlFile and SPFILE Autobackup at 23-MAY-12

piecehandle=/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-04 comment=NONE

Finished ControlFile and SPFILE Autobackup at 23-MAY-12

 

RMAN>

 

1.2.6         查看我们刚才备份的信息:

RMAN> list backup;

如下信息是之前做的备份:

using target database control file instead of recoverycatalog

 

List of Backup Sets

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

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

2      Full    522.59M   DISK        00:00:59     18-MAY-12     

       BP Key:2   Status: AVAILABLE  Compressed: NO  Tag: TAG20120518T185700

       Piece Name:/DBBak/bak_WWL_05_18_04nbaffs_1_1

 List of Datafilesin backup set 2

 File LV Type CkpSCN    Ckp Time  Name

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

 1       Full 618100     18-MAY-12 /DBData/WWL/system01.dbf

 2       Full 618100     18-MAY-12 /DBData/WWL/undotbs01.dbf

 3       Full 618100     18-MAY-12 /DBData/WWL/sysaux01.dbf

 4       Full 618100     18-MAY-12 /DBData/WWL/users01.dbf

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

3      Full    6.80M     DISK        00:00:02     18-MAY-12     

       BP Key:3   Status: AVAILABLE  Compressed: NO  Tag: TAG20120518T185806

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120518-01

 Control FileIncluded: Ckp SCN: 618100       Ckp time:18-MAY-12

 SPFILE Included:Modification time: 18-MAY-12

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

4      Full    523.54M   DISK        00:01:09     21-MAY-12     

       BP Key:4   Status: AVAILABLE  Compressed: NO  Tag: TAG20120521T145403

       Piece Name:/DBBak/bak_WWL_05_21_06nbhucb_1_1

 List of Datafilesin backup set 4

 File LV Type CkpSCN    Ckp Time  Name

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

 1       Full 622304     21-MAY-12 /DBData/WWL/system01.dbf

 2       Full 622304     21-MAY-12 /DBData/WWL/undotbs01.dbf

 3       Full 622304     21-MAY-12 /DBData/WWL/sysaux01.dbf

 4       Full 622304     21-MAY-12 /DBData/WWL/users01.dbf

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

5      Full    6.80M     DISK        00:00:01     21-MAY-12     

       BP Key:5   Status: AVAILABLE  Compressed: NO  Tag: TAG20120521T145520

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120521-00

 Control FileIncluded: Ckp SCN: 622304       Ckp time:21-MAY-12

 SPFILE Included:Modification time: 21-MAY-12

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

6      Full    368.00K   DISK        00:00:00     21-MAY-12     

       BP Key:6   Status: AVAILABLE  Compressed: NO  Tag: TAG20120521T151349

       Piece Name:/DBBak/bak_WWL_05_21_08nbhvhe_1_1

 List of Datafilesin backup set 6

 File LV Type CkpSCN    Ckp Time  Name

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

 4       Full 622968     21-MAY-12 /DBData/WWL/users01.dbf

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

7      Full    6.80M     DISK        00:00:01     21-MAY-12     

       BP Key:7   Status: AVAILABLE  Compressed: NO  Tag: TAG20120521T151351

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120521-01

 Control FileIncluded: Ckp SCN: 622968       Ckp time:21-MAY-12

 SPFILE Included:Modification time: 21-MAY-12

 

今天的备份信息如下:

如下是全库备份信息:

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

8      Full    524.66M   DISK        00:01:36     23-MAY-12     

       BP Key:8   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T121210

       Piece Name:/DBBak/bak_WWL_05_23_0anbmtkr_1_1

 List of Datafilesin backup set 8

 File LV Type CkpSCN    Ckp Time  Name

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

 1       Full 649219     23-MAY-12 /DBData/WWL/system01.dbf

 2       Full 649219     23-MAY-12 /DBData/WWL/undotbs01.dbf

 3       Full 649219     23-MAY-12 /DBData/WWL/sysaux01.dbf

 4       Full 649219     23-MAY-12 /DBData/WWL/users01.dbf

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

9      Full    6.80M     DISK        00:00:01     23-MAY-12     

       BP Key:9   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T121358

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-00

 Control FileIncluded: Ckp SCN: 649233       Ckp time:23-MAY-12

 SPFILE Included:Modification time: 23-MAY-12

 

 

如下是备份USER表空间信息:

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

10     Full    432.00K   DISK        00:00:01     23-MAY-12     

       BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133147

       Piece Name:/DBBak/bak_WWL_05_23_0cnbn2a3_1_1

 List of Datafilesin backup set 10

 File LV Type CkpSCN    Ckp Time  Name

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

 4       Full 651081     23-MAY-12 /DBData/WWL/users01.dbf

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

11     Full    6.80M     DISK        00:00:03     23-MAY-12      

       BP Key:11   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133151

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-01

 Control FileIncluded: Ckp SCN: 651086       Ckp time:23-MAY-12

 SPFILE Included:Modification time: 23-MAY-12

 

 

如下是备份数据文件123的信息:

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

12     Full    524.61M   DISK        00:01:42     23-MAY-12     

       BP Key:12   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133235

       Piece Name:/DBBak/bak_WWL_05_23_0enbn2bk_1_1

 List of Datafilesin backup set 12

 File LV Type CkpSCN    Ckp Time  Name

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

 1       Full 651104     23-MAY-12 /DBData/WWL/system01.dbf

 2       Full 651104     23-MAY-12 /DBData/WWL/undotbs01.dbf

 3       Full 651104     23-MAY-12 /DBData/WWL/sysaux01.dbf

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

13     Full    6.80M     DISK        00:00:01     23-MAY-12     

       BP Key:13   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133424

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-02

 Control FileIncluded: Ckp SCN: 651119       Ckp time:23-MAY-12

 SPFILE Included:Modification time: 23-MAY-12

 

 

如下备份的是控制文件信息:

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

14     Full    6.77M     DISK        00:00:01     23-MAY-12     

       BP Key:14   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133645

       Piece Name:/DBBak/bak_WWL_05_23_0gnbn2je_1_1

 Control FileIncluded: Ckp SCN: 651150       Ckp time:23-MAY-12

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

15     Full    6.80M     DISK        00:00:01     23-MAY-12     

       BP Key:15   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133648

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-03

 Control FileIncluded: Ckp SCN: 651154       Ckp time:23-MAY-12

 SPFILE Included:Modification time: 23-MAY-12

 

 

如下是备份spfile文件的信息:

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

16     Full    80.00K    DISK        00:00:01     23-MAY-12     

       BP Key:16   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133737

       Piece Name:/DBBak/bak_WWL_05_23_0inbn2l2_1_1

 SPFILE Included:Modification time: 23-MAY-12

 

BS Key Type LVSize       Device Type Elapsed TimeCompletion Time

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

17     Full    6.80M     DISK        00:00:02     23-MAY-12     

       BP Key:17   Status: AVAILABLE  Compressed: NO  Tag: TAG20120523T133740

       Piece Name:/DBSoft/product/10.2.0/db_1/dbs/c-5520179-20120523-04

 Control FileIncluded: Ckp SCN: 651175       Ckp time:23-MAY-12

 SPFILE Included:Modification time: 23-MAY-12

 

RMAN>

 

恢复大综合:

     介于Rman恢复的自动性,我们刚才对数据库的全库,单表空间,数据文件控制文件和参数文件都做了备份,这些备份的内容是数据库运行不可缺少的必要元素,通常情况下我们在生产库中只需要备份这些内容即可。有了这些备份,即使数据库的的任何信息丢失,我们都可以得以恢复使得数据库的正常运行,当然如果我们将archive log 也备份,当然就会更好了,一般情况下这个可以不用备份,备份archive log占用空间非常大。如果有海量的储存,当然备份也无妨咯。

 

Egg:

2.1  删除数据库的所有文件,仅保留redo日志和archivelog文件

 

删除控制文件:

[oracle@wwldb WWL]$ pwd

/DBData/oradata/WWL

[oracle@wwldb WWL]$ ls

control02.ctl  control03.ctl

[oracle@wwldb WWL]$ rm -rf *.ctl

[oracle@wwldbWWL]$

[oracle@wwldb WWL]$ pwd

/DBSoft/oradata/WWL

[oracle@wwldb WWL]$ ls

control01.ctl

[oracle@wwldb WWL]$ rm -rf control01.ctl

[oracle@wwldbWWL]$

 

删除数据文件:

[oracle@wwldb WWL]$ ls

redo01.log  redo02.log redo03.log  sysaux01.dbf  system01.dbf temp01.dbf  undotbs01.dbf  users01.dbf

[oracle@wwldb WWL]$ rm -rf *.dbf

[oracle@wwldb WWL]$ ls

redo01.log  redo02.log redo03.log

[oracle@wwldbWWL]$

 

删除参数文件:

[oracle@wwldb dbs]$ cd $ORACLE_HOME/dbs

[oracle@wwldb dbs]$ rm -rf spfileWWL.ora

[oracle@wwldbdbs]$

 

执行大恢复

1、现在数据库是关闭状态

[oracle@wwldb dbs]$ ps -ef|grep ora

root      2910 2888  0 10:02 ?        00:00:15 hald-addon-storage: polling/dev/hdc

root     28954 3478  0 11:38 pts/1    00:00:00 su - oracle

oracle   28955 28954 0 11:38 pts/1    00:00:00 -bash

root     29361 3438  0 13:41 pts/2    00:00:00 su - oracle

oracle   29362 29361 0 13:41 pts/2    00:00:01 -bash

oracle   29988 29362 0 16:06 pts/2    00:00:00sqlplus   as sysdba

oracle   30102 28955 0 17:03 pts/1    00:00:00 ps -ef

oracle   30103 28955 0 17:03 pts/1    00:00:00 grep ora

[oracle@wwldbdbs]$

 

2、要恢复首先要将数据库启动到mount状态才能恢复

[oracle@wwldb dbs]$ sqlplus / as sysdba

SQL*Plus:Release 10.2.0.1.0 - Production on Wed May 23 17:03:42 2012

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

Connected to anidle instance.

 

SQL> startup

ORA-01078:failure in processing system parameters

LRM-00109: couldnot open parameter file '/DBSoft/product/10.2.0/db_1/dbs/initWWL.ora'

SQL>

 

3、因为数据库没有参数文件,起不来,只能能启动到nomount状态

[oracle@wwldb dbs]$ rman target /

RecoveryManager: Release 10.2.0.1.0 - Production on Wed May 23 17:06:32 2012

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

connected totarget database (not started)

 

RMAN> startup force nomount;

startup failed:ORA-01078: failure in processing system parameters

LRM-00109: couldnot open parameter file '/DBSoft/product/10.2.0/db_1/dbs/initWWL.ora'

starting Oracleinstance without parameter file for retrival of spfile

Oracle instancestarted

 

Total System GlobalArea     159383552 bytes

Fixed Size                     1218244 bytes

VariableSize                 58722620 bytes

DatabaseBuffers              92274688 bytes

RedoBuffers                   7168000 bytes

 

RMAN>

 

4、开始恢复参数文件,只有恢复了参数文件和控制文件数据库才能到mount状态来恢复数据文件:

 

RMAN> restorespfile from autobackup;

 

Starting restoreat 23-MAY-12

using targetdatabase control file instead of recovery catalog

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=36 devtype=DISK

 

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

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

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

RMAN-03002:failure of restore command at 05/23/2012 17:08:42

RMAN-06495: mustexplicitly specify DBID with SET DBID command

 

RMAN>

注意:这里有问题了,spfile无法恢复,必须指定DBID。我记得在每次登录到rman的时候都会显示一个数据库的DBID,但是为什么这里要我们指定DBID呢???原因很简单,因为我们登录RMAN的时候,数据库已经宕机了,而且参数文件,控制文件,数据文件都没有了,它到哪里去找DBID;所以需要我们手动来指定,问题是现在既然登录的时候不显示,我们也不知道在哪里呀,如下:

 

[oracle@wwldb dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on WedMay 23 17:06:32 2012

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

connected to targetdatabase (not started)

 

没关系的因为我们的控制文件做了自动备份,在自动备份的控制文件里面已经存在了DBID,我们现在去找找吧,默认就备份在如下位置:

[oracle@wwldb dbs]$ pwd

/DBSoft/product/10.2.0/db_1/dbs

[oracle@wwldb dbs]$ ls

c-5520179-20120518-01  c-5520179-20120523-01  hc_WWL.dat lkWWL

 

其中5520179就是DBID了,我们只需要通过指定这个DBID,就可以将spfile恢复并将数据库启动到mount状态。

 

RMAN> set DBID=5520179

executingcommand: SET DBID

 

RMAN> restore spfile from autobackup;

Starting restoreat 23-MAY-12

using targetdatabase control file instead of recovery catalog

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=39 devtype=DISK

 

channelORA_DISK_1: looking for autobackup on day: 20120523

channelORA_DISK_1: autobackup found: c-5520179-20120523-04

channelORA_DISK_1: SPFILE restore from autobackup complete

Finished restoreat 23-MAY-12

 

RMAN>

 

5、恢复控制文件

RMAN> restore controlfile from autobackup;

 

Starting restoreat 23-MAY-12

using channelORA_DISK_1

 

channelORA_DISK_1: looking for autobackup on day: 20120523

channelORA_DISK_1: autobackup found: c-5520179-20120523-04

channelORA_DISK_1: control file restore from autobackup complete

outputfilename=/DBSoft/product/10.2.0/db_1/dbs/cntrlWWL.dbf

Finished restoreat 23-MAY-12

 

RMAN>

 

重启数据库到mount状态  ---很重要

SQL> startup mount;

ORACLE instancestarted.

Total SystemGlobal Area  285212672 bytes

Fixed Size                  1218968 bytes

VariableSize              79693416 bytes

DatabaseBuffers          197132288 bytes

RedoBuffers                7168000 bytes

Databasemounted.

 

SQL> exit

Disconnectedfrom Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With thePartitioning, OLAP and Data Mining options

 

[oracle@wwldb dbs]$ rman target /

RecoveryManager: Release 10.2.0.1.0 - Production on Wed May 23 19:04:15 2012

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

connected totarget database: WWL (DBID=5520179, not open)

 

注意:详细参考如下:

http://blog.csdn.net/wuweilong/article/details/7596056

http://space.itpub.net/?uid-20674423-action-viewspace-itemid-730717

 

6、恢复数据库其它的数据文件:

RMAN> restore database;

Starting restoreat 23-MAY-12

using targetdatabase control file instead of recovery catalog

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=156 devtype=DISK

 

channelORA_DISK_1: starting datafile backupset restore

channelORA_DISK_1: specifying datafile(s) to restore from backup set

restoringdatafile 00004 to /DBData/WWL/users01.dbf

channelORA_DISK_1: reading from backup piece /DBBak/bak_WWL_05_23_0cnbn2a3_1_1

channelORA_DISK_1: restored backup piece 1

piece handle=/DBBak/bak_WWL_05_23_0cnbn2a3_1_1tag=TAG20120523T133147

channelORA_DISK_1: restore complete, elapsed time: 00:00:02

channelORA_DISK_1: starting datafile backupset restore

channelORA_DISK_1: specifying datafile(s) to restore from backup set

restoringdatafile 00001 to /DBData/WWL/system01.dbf

restoringdatafile 00002 to /DBData/WWL/undotbs01.dbf

restoringdatafile 00003 to /DBData/WWL/sysaux01.dbf

channelORA_DISK_1: reading from backup piece /DBBak/bak_WWL_05_23_0enbn2bk_1_1

channelORA_DISK_1: restored backup piece 1

piecehandle=/DBBak/bak_WWL_05_23_0enbn2bk_1_1 tag=TAG20120523T133235

channelORA_DISK_1: restore complete, elapsed time: 00:01:05

Finished restoreat 23-MAY-12

 

RMAN>

RMAN> recover database;

Starting recoverat 23-MAY-12

using channel ORA_DISK_1

starting mediarecovery

media recovery complete,elapsed time: 00:00:05

Finished recoverat 23-MAY-12

 

RMAN> alter database open;  ---------我们看到数据库已经打开了处于open状态

database opened

 

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS

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

WWL             OPEN

 

SQL>

 

注意:

restore:是将物理的数据文件从备份集中恢复出到原来的位置

recover:是利用redo日志,将备份点后的数据库通过redo日志重做

原创粉丝点击