目录(?)[+]
RMAN 备份分2种,Catalog 和Nocatalog,对于Nocatalog,oracle 会使用控制文件来保存RMAN备份的一些记录。 而且实际上多数也是使用Nocatalog来备份。因为使用Nocatalog比较方便。
但对于使用Nocatalog的情况就会让RMAN 恢复的时候依赖与控制文件中记录的备份的信息。如果不一致,就会导致不能进行有效的恢复。
我们这里演示二种情况:
(1) 使用RMAN 的nocatalog 进行备份,然后将备份转移到其他的目录, 在进行恢复。
(2) 使用Nocatalog 备份,然后重建控制文件,在使用RMAN 备份进行恢复。
两种方法都是使用catalog 命令把RMAN备份集的信息重新注册到控制文件。
在我们RMAN 进行异地恢复的时候,就会遇到路径的问题,如果路径不同,就没办法进行有效的恢复,我们看这时候怎么处理。
Nocatalog 下的RMAN 增量备份 shell脚本
http://blog.csdn.net/tianlesoftware/article/details/6164931
[oracle@dave scripts]$ exportNLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
[oracle@dave scripts]$ rman target /
Recovery Manager: Release 11.2.0.3.0 -Production on Tue Apr 16 04:49:49 2013
Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.
connected to target database: ANQING(DBID=743034417)
RMAN> list backup summary;
using target database control file insteadof recovery catalog
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ------------------------------ ------- ------- ---------- ---
18 B 0 A DISK 2013-04-16 04:25:53 1 1 NO DAVE_LEV0
19 B 0 A DISK 2013-04-16 04:26:01 1 1 NO DAVE_LEV0
21 B 0 A DISK 2013-04-16 04:26:16 1 1 NO DAVE_LEV0
22 B A A DISK 2013-04-16 04:26:26 1 1 NO ARC_BAK
24 B F A DISK 2013-04-16 04:26:31 1 1 NO BAK_CTLFILE
这里通过list 命令查看,也可以通过如下视图来查看详细信息:
V$BACKUP_PIECE,
V$BACKUP_SET,
V$BACKUP_DATAFILE,
V$BACKUP_REDOLOG,
V$BACKUP_SPFILE.
通过V$BACKUP_PIECE 查询出来的备份集:
/u01/backup/dave_lev0_0jo76nh7_1_1_20130416
/u01/backup/dave_lev0_0io76nh7_1_1_20130416
/u01/backup/dave_lev0_0ko76nim_1_1_20130416
/u01/backup/arch_0no76njh_1_1_20130416
/u01/backup/ctl_file_0oo76njm_1_1_20130416
我这里备份集保存在/u01/backup的目录:
[oracle@dave admin]$ cd /u01/backup
[oracle@dave backup]$ ls
arch_0no76njh_1_1_20130416 block_change_tracking.f dave_lev0_0io76nh7_1_1_20130416 dave_lev0_22o687qp_1_1_20130404
arch_1ho6566m_1_1_20130403 ctl_file_0oo76njm_1_1_20130416 dave_lev0_0jo76nh7_1_1_20130416 dave_spfile_1mo65679_1_1_20130403
arch_1io6566n_1_1_20130403 ctl_file_1lo65676_1_1_20130403 dave_lev0_0ko76nim_1_1_20130416 dave_spfile_29o687sc_1_1_20130404
arch_26o687rp_1_1_20130404 ctl_file_28o687sa_1_1_20130404 dave_lev0_20o687pl_1_1_20130404
arch_27o687s8_1_1_20130404 ctl_file_2ao6vobb_1_1_20130413 dave_lev0_21o687pl_1_1_20130404
[oracle@dave u01]$ mv backup bak
[oracle@dave u01]$ cd bak
[oracle@dave bak]$ ls
arch_0no76njh_1_1_20130416 block_change_tracking.f dave_lev0_0io76nh7_1_1_20130416 dave_lev0_22o687qp_1_1_20130404
arch_1ho6566m_1_1_20130403 ctl_file_0oo76njm_1_1_20130416 dave_lev0_0jo76nh7_1_1_20130416 dave_spfile_1mo65679_1_1_20130403
arch_1io6566n_1_1_20130403 ctl_file_1lo65676_1_1_20130403 dave_lev0_0ko76nim_1_1_20130416 dave_spfile_29o687sc_1_1_20130404
arch_26o687rp_1_1_20130404 ctl_file_28o687sa_1_1_20130404 dave_lev0_20o687pl_1_1_20130404
arch_27o687s8_1_1_20130404 ctl_file_2ao6vobb_1_1_20130413 dave_lev0_21o687pl_1_1_20130404
--使用RMAN 进行效验:
RMAN> list backupset summary;
using target database control file insteadof recovery catalog
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ---------------------- ------- ---------- ---
18 B 0 A DISK 16-APR-13 1 1 NO DAVE_LEV0
19 B 0 A DISK 16-APR-13 1 1 NO DAVE_LEV0
21 B 0 A DISK 16-APR-13 1 1 NO DAVE_LEV0
22 B A A DISK 16-APR-13 1 1 NO ARC_BAK
24 B F A DISK 16-APR-13 1 1 NO BAK_CTLFILE
备份集有两种状态:
A(Available,RMAN认为该项存在于备份介质上),
X(Expired,备份存在于控制文件或恢复目录中,但是并没有物理存在于备份介质上)
这里的状态是A。
RMAN> crosscheckbackup;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=54 device type=DISK
crosschecked backup piece: found to be'EXPIRED'
backup piecehandle=/u01/backup/dave_lev0_0jo76nh7_1_1_20130416 RECID=18 STAMP=812867112
crosschecked backup piece: found to be'EXPIRED'
backup piecehandle=/u01/backup/dave_lev0_0io76nh7_1_1_20130416 RECID=19 STAMP=812867111
crosschecked backup piece: found to be'EXPIRED'
backup piecehandle=/u01/backup/dave_lev0_0ko76nim_1_1_20130416 RECID=21 STAMP=812867158
crosschecked backup piece: found to be'EXPIRED'
backup piecehandle=/u01/backup/arch_0no76njh_1_1_20130416 RECID=22 STAMP=812867185
crosschecked backup piece: found to be'EXPIRED'
backup piecehandle=/u01/backup/ctl_file_0oo76njm_1_1_20130416 RECID=24 STAMP=812867191
Crosschecked 5 objects
RMAN> list backupsetsummary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ---------------------- ------- ---------- ---
18 B 0 X DISK 16-APR-13 1 1 NO DAVE_LEV0
19 B 0 X DISK 16-APR-13 1 1 NO DAVE_LEV0
21 B 0 X DISK 16-APR-13 1 1 NO DAVE_LEV0
22 B A X DISK 16-APR-13 1 1 NO ARC_BAK
24 B F X DISK 16-APR-13 1 1 NO BAK_CTLFILE
--当我们corsscheck 之后,状态就都变成X了。
--因为备份集物理不存在,这些都被标记为expired:
RMAN> list expired backup;
List of Backup Sets
===================
BS Key Type LV Size Device TypeElapsed Time Completion Time
------- ---- -- ---------- ----------------------- ---------------
18 Incr 0 633.95M DISK 00:00:42 16-APR-13
BP Key: 18 Status: EXPIRED Compressed: NO Tag: DAVE_LEV0
Piece Name: /u01/backup/dave_lev0_0jo76nh7_1_1_20130416
List of Datafiles in backup set 18
File LV Type Ckp SCN CkpTime Name
---- -- ---- ---------- --------- ----
2 0 Incr 3136508 16-APR-13/u01/app/oracle/oradata/dave/sysaux01.dbf
3 0 Incr 3136508 16-APR-13/u01/app/oracle/oradata/dave/undotbs01.dbf
4 0 Incr 3136508 16-APR-13/u01/app/oracle/oradata/dave/users01.dbf
8 0 Incr 3136508 16-APR-13 /u01/app/oracle/oradata/dave/FDA01.dbf
9 0 Incr 3136508 16-APR-13/u01/app/oracle/oradata/dave/FDA02.dbf
BS Key Type LV Size Device TypeElapsed Time Completion Time
------- ---- -- ---------- ----------------------- ---------------
19 Incr 0 908.19M DISK 00:00:50 16-APR-13
BP Key: 19 Status: EXPIRED Compressed: NO Tag: DAVE_LEV0
Piece Name: /u01/backup/dave_lev0_0io76nh7_1_1_20130416
List of Datafiles in backup set 19
File LV Type Ckp SCN CkpTime Name
------ ---- ---------- --------- ----
1 0 Incr 3136507 16-APR-13/u01/app/oracle/oradata/dave/system01.dbf
10 0 Incr 3136507 16-APR-13/u01/app/oracle/oradata/dave/FDA03.dbf
11 0 Incr 3136507 16-APR-13 /u01/app/oracle/oradata/dave/FDA04.dbf
12 0 Incr 3136507 16-APR-13/u01/app/oracle/oradata/dave/ts01.dbf
13 0 Incr 3136507 16-APR-13/u01/app/oracle/oradata/dave/ts02.dbf
BS Key Type LV Size Device TypeElapsed Time Completion Time
------- ---- -- ---------- ----------------------- ---------------
21 Incr 0 426.01M DISK 00:00:18 16-APR-13
BP Key: 21 Status: EXPIRED Compressed: NO Tag: DAVE_LEV0
Piece Name: /u01/backup/dave_lev0_0ko76nim_1_1_20130416
List of Datafiles in backup set 21
File LV Type Ckp SCN CkpTime Name
---- -- ---- ---------- --------- ----
5 0 Incr 3136645 16-APR-13/u01/app/oracle/oradata/dave/example01.dbf
6 0 Incr 3136645 16-APR-13/u01/app/oracle/oradata/dave/mssm01.dbf
7 0 Incr 3136645 16-APR-13/u01/app/oracle/oradata/dave/assm01.dbf
14 0 Incr 3136645 16-APR-13/u01/app/oracle/oradata/dave/dave01.dbf
15 0 Incr 3136645 16-APR-13/u01/app/oracle/oradata/dave/anqing01.dbf
BS Key Size Device Type ElapsedTime Completion Time
------- ---------- ----------- ---------------------------
22 40.93M DISK 00:00:01 16-APR-13
BP Key: 22 Status: EXPIRED Compressed: NO Tag: ARC_BAK
Piece Name: /u01/backup/arch_0no76njh_1_1_20130416
List of Archived Logs in backup set 22
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 23 3120875 15-APR-13 3136670 16-APR-13
1 24 3136670 16-APR-13 3136678 16-APR-13
BS Key Type LV Size Device TypeElapsed Time Completion Time
------- ---- -- ---------- ----------------------- ---------------
24 Full 9.64M DISK 00:00:01 16-APR-13
BP Key: 24 Status: EXPIRED Compressed: NO Tag: BAK_CTLFILE
Piece Name: /u01/backup/ctl_file_0oo76njm_1_1_20130416
Control File Included: Ckp SCN: 3136695 Ckp time: 16-APR-13
RMAN>
--删除这些过期的信息:
RMAN> delete noprompt expired backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ---------------------- ----------
18 18 1 1 EXPIRED DISK /u01/backup/dave_lev0_0jo76nh7_1_1_20130416
19 19 1 1 EXPIRED DISK /u01/backup/dave_lev0_0io76nh7_1_1_20130416
21 21 1 1 EXPIRED DISK /u01/backup/dave_lev0_0ko76nim_1_1_20130416
22 22 1 1 EXPIRED DISK /u01/backup/arch_0no76njh_1_1_20130416
24 24 1 1 EXPIRED DISK /u01/backup/ctl_file_0oo76njm_1_1_20130416
deleted backup piece
backup piecehandle=/u01/backup/dave_lev0_0jo76nh7_1_1_20130416 RECID=18 STAMP=812867112
deleted backup piece
backup piecehandle=/u01/backup/dave_lev0_0io76nh7_1_1_20130416 RECID=19 STAMP=812867111
deleted backup piece
backup piecehandle=/u01/backup/dave_lev0_0ko76nim_1_1_20130416 RECID=21 STAMP=812867158
deleted backup piece
backup piece handle=/u01/backup/arch_0no76njh_1_1_20130416RECID=22 STAMP=812867185
deleted backup piece
backup piecehandle=/u01/backup/ctl_file_0oo76njm_1_1_20130416 RECID=24 STAMP=812867191
Deleted 5 EXPIRED objects
RMAN>
--RMAN 验证:
RMAN> list backupset summary;
specification does not match any backup inthe repository
因为之前备份集的位置发生改变,导致corsscheck之后,将之前备份的记录标记为expired,我们后来手工删除了这些expired的备份集信息。
现在我们要进行恢复,必须将之前的备份信息重新注册到控制文件中来。
RMAN> CATALOG BACKUPPIECE '/u01/bak/arch_0no76njh_1_1_20130416','/u01/bak/ctl_file_0oo76njm_1_1_20130416';
cataloged backup piece
backup piecehandle=/u01/bak/arch_0no76njh_1_1_20130416 RECID=25 STAMP=812872014
cataloged backup piece
backup piece handle=/u01/bak/ctl_file_0oo76njm_1_1_20130416RECID=26 STAMP=812872014
--可以正常查看:
RMAN> list backupset summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ---------------------- ------- ---------- ---
25 B A A DISK 16-APR-13 1 1 NO ARC_BAK
26 B F A DISK 16-APR-13 1 1 NO BAK_CTLFILE
RMAN> catalog start with'/data01/';
---ASM:
CATALOG START WITH '+disk'; # catalog allfiles from an ASM disk group
--本地目录:最后一定要加/
CATALOG START WITH '/fs1/datafiles/'; #catalog all files in directory
--有多个目录,注册多次:
RMAN> catalog start with'/data01/';
RMAN>catalog start with '/data02/';
RMAN>catalog start with '/data03/';
--示例:
RMAN> catalog start with '/u01/bak';
searching for all files that match thepattern /u01/bak
List of Files Unknown to the Database
=====================================
File Name: /u01/bak/dave_lev0_0io76nh7_1_1_20130416
File Name:/u01/bak/dave_lev0_21o687pl_1_1_20130404
File Name:/u01/bak/dave_spfile_1mo65679_1_1_20130403
File Name:/u01/bak/arch_27o687s8_1_1_20130404
File Name:/u01/bak/ctl_file_2ao6vobb_1_1_20130413
File Name: /u01/bak/arch_26o687rp_1_1_20130404
File Name:/u01/bak/arch_1ho6566m_1_1_20130403
File Name:/u01/bak/dave_lev0_20o687pl_1_1_20130404
File Name:/u01/bak/arch_1io6566n_1_1_20130403
File Name:/u01/bak/dave_spfile_29o687sc_1_1_20130404
File Name: /u01/bak/ctl_file_1lo65676_1_1_20130403
File Name: /u01/bak/block_change_tracking.f
File Name:/u01/bak/ctl_file_28o687sa_1_1_20130404
File Name:/u01/bak/dave_lev0_0ko76nim_1_1_20130416
File Name:/u01/bak/dave_lev0_22o687qp_1_1_20130404
File Name: /u01/bak/dave_lev0_0jo76nh7_1_1_20130416
Do you really want to catalog the abovefiles (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name:/u01/bak/dave_lev0_0io76nh7_1_1_20130416
File Name: /u01/bak/ctl_file_2ao6vobb_1_1_20130413
File Name:/u01/bak/dave_lev0_0ko76nim_1_1_20130416
File Name:/u01/bak/dave_lev0_0jo76nh7_1_1_20130416
List of Files Which Where Not Cataloged
=======================================
File Name: /u01/bak/dave_lev0_21o687pl_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_spfile_1mo65679_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name: /u01/bak/arch_27o687s8_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/arch_26o687rp_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name: /u01/bak/arch_1ho6566m_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_lev0_20o687pl_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name: /u01/bak/arch_1io6566n_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_spfile_29o687sc_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/ctl_file_1lo65676_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name: /u01/bak/block_change_tracking.f
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/bak/ctl_file_28o687sa_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_lev0_22o687qp_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
RMAN>
--验证:
RMAN> list backupset summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ---------------------- ------- ---------- ---
25 B A A DISK 16-APR-13 1 1 NO ARC_BAK
26 B F A DISK 16-APR-13 1 1 NO BAK_CTLFILE
27 B 0 A DISK 16-APR-13 1 1 NO DAVE_LEV0
28 B F A DISK 13-APR-13 1 1 NO BAK_CTLFILE
29 B 0 A DISK 16-APR-13 1 1 NO DAVE_LEV0
30 B 0 A DISK 16-APR-13 1 1 NO DAVE_LEV0
RMAN> startup mount force
Oracle instance started
database mounted
Total System Global Area 818401280 bytes
Fixed Size 2232800 bytes
Variable Size 482348576 bytes
Database Buffers 331350016 bytes
Redo Buffers 2469888 bytes
RMAN> restore database;
Starting restore at 16-APR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00001 to /u01/app/oracle/oradata/dave/system01.dbf
channel ORA_DISK_1: restoring datafile00010 to /u01/app/oracle/oradata/dave/FDA03.dbf
channel ORA_DISK_1: restoring datafile00011 to /u01/app/oracle/oradata/dave/FDA04.dbf
channel ORA_DISK_1: restoring datafile00012 to /u01/app/oracle/oradata/dave/ts01.dbf
channel ORA_DISK_1: restoring datafile00013 to /u01/app/oracle/oradata/dave/ts02.dbf
channel ORA_DISK_1: reading from backuppiece /u01/bak/dave_lev0_0io76nh7_1_1_20130416
channel ORA_DISK_1: piecehandle=/u01/bak/dave_lev0_0io76nh7_1_1_20130416 tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:35
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00002 to /u01/app/oracle/oradata/dave/sysaux01.dbf
channel ORA_DISK_1: restoring datafile00003 to /u01/app/oracle/oradata/dave/undotbs01.dbf
channel ORA_DISK_1: restoring datafile00004 to /u01/app/oracle/oradata/dave/users01.dbf
channel ORA_DISK_1: restoring datafile00008 to /u01/app/oracle/oradata/dave/FDA01.dbf
channel ORA_DISK_1: restoring datafile00009 to /u01/app/oracle/oradata/dave/FDA02.dbf
channel ORA_DISK_1: reading from backuppiece /u01/bak/dave_lev0_0jo76nh7_1_1_20130416
channel ORA_DISK_1: piecehandle=/u01/bak/dave_lev0_0jo76nh7_1_1_20130416 tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:25
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00005 to /u01/app/oracle/oradata/dave/example01.dbf
channel ORA_DISK_1: restoring datafile00006 to /u01/app/oracle/oradata/dave/mssm01.dbf
channel ORA_DISK_1: restoring datafile00007 to /u01/app/oracle/oradata/dave/assm01.dbf
channel ORA_DISK_1: restoring datafile 00014to /u01/app/oracle/oradata/dave/dave01.dbf
channel ORA_DISK_1: restoring datafile00015 to /u01/app/oracle/oradata/dave/anqing01.dbf
channel ORA_DISK_1: reading from backuppiece /u01/bak/dave_lev0_0ko76nim_1_1_20130416
channel ORA_DISK_1: piece handle=/u01/bak/dave_lev0_0ko76nim_1_1_20130416tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:25
Finished restore at 16-APR-13
RMAN> recover database;
Starting recover at 16-APR-13
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time:00:00:03
Finished recover at 16-APR-13
RMAN> alter database open;
database opened
RMAN>
成功恢复。
第二节中我们演示的备份集的位置发生改变。那么还有另一种情况,就是控制文件被重建了。 这时候也会清空RMAN 备份中的相关信息。
而重建控制文件又分两种情况:resetlogs 和noresetlogs。
Oracle 控制文件 说明
http://blog.csdn.net/tianlesoftware/article/details/4974440
使用使用resetlogs 重建控制文件后,RMAN恢复又会涉及到incarnation 问题,而Noresetlogs 就不会出现这种问题。
我们这里演示Noresetlogs 的方式重建控制文件并恢复的问题。
Nocatalog 下的RMAN 增量备份 shell脚本
http://blog.csdn.net/tianlesoftware/article/details/6164931
[oracle@dave bak]$ exportNLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
[oracle@dave bak]$ rman target /
Recovery Manager: Release 11.2.0.3.0 -Production on Tue Apr 16 05:59:00 2013
Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.
connected to target database: ANQING(DBID=743034417)
RMAN> list backup summary;
using target database control file insteadof recovery catalog
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ------------------------------ ------- ------- ---------- ---
25 B A A DISK 2013-04-16 04:26:25 1 1 NO ARC_BAK
26 B F A DISK 2013-04-16 04:26:30 1 1 NO BAK_CTLFILE
27 B 0 A DISK 2013-04-16 04:25:11 1 1 NO DAVE_LEV0
28 B F A DISK 2013-04-13 12:56:11 1 1 NO BAK_CTLFILE
29 B 0 A DISK 2013-04-16 04:25:58 1 1 NO DAVE_LEV0
30 B 0 A DISK 2013-04-16 04:25:11 1 1 NO DAVE_LEV0
我这里使用的还是之前的备份,所以我这里所有的备份集都是之前修改过多路径:/u01/bak.
SQL> oradebug setmypid
Statement processed.
SQL> alter database backup controlfileto trace;
Database altered.
SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/anqing/anqing/trace/anqing_ora_8932.trc
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 818401280 bytes
Fixed Size 2232800 bytes
Variable Size 482348576 bytes
Database Buffers 331350016 bytes
Redo Buffers 2469888 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE"ANQING" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1'/u01/app/oracle/oradata/dave/redo01.log' SIZE 50M BLOCKSIZE 512,
9 GROUP 2'/u01/app/oracle/oradata/dave/redo02.log' SIZE 50M BLOCKSIZE 512,
10 GROUP 3 '/u01/app/oracle/oradata/dave/redo03.log' SIZE 50M BLOCKSIZE 512
11 DATAFILE
12 '/u01/app/oracle/oradata/dave/system01.dbf',
13 '/u01/app/oracle/oradata/dave/sysaux01.dbf',
14 '/u01/app/oracle/oradata/dave/undotbs01.dbf',
15 '/u01/app/oracle/oradata/dave/users01.dbf',
16 '/u01/app/oracle/oradata/dave/example01.dbf',
17 '/u01/app/oracle/oradata/dave/mssm01.dbf ',
18 '/u01/app/oracle/oradata/dave/assm01.dbf',
19 '/u01/app/oracle/oradata/dave/FDA01.dbf',
20 '/u01/app/oracle/oradata/dave/FDA02.dbf',
21 '/u01/app/oracle/oradata/dave/FDA03.dbf',
22 '/u01/app/oracle/oradata/dave/FDA04.dbf',
23 '/u01/app/oracle/oradata/dave/ts01.dbf',
24 '/u01/app/oracle/oradata/dave/ts02.dbf',
25 '/u01/app/oracle/oradata/dave/dave01.dbf',
26 '/u01/app/oracle/oradata/dave/anqing01.dbf'
27 CHARACTER SET AL32UTF8
28 ;
Control file created.
SQL> RECOVER DATABASE
ORA-00283: recovery session canceled due toerrors
ORA-00264: no recovery required
SQL> ALTER DATABASE OPEN;
Database altered.
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE'/u01/app/oracle/oradata/dave/temp01.dbf'
2 SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
Tablespace altered.
具体说明参考:
Oracle控制文件 说明
http://blog.csdn.net/tianlesoftware/article/details/4974440
RMAN> list backupset summary;
using target database control file insteadof recovery catalog
specification does not match any backup inthe repository
--什么信息都没。
RMAN> catalog start with '/u01/bak';
searching for all files that match thepattern /u01/bak
List of Files Unknown to the Database
=====================================
File Name:/u01/bak/arch_0no76njh_1_1_20130416
File Name: /u01/bak/dave_lev0_0io76nh7_1_1_20130416
File Name:/u01/bak/dave_lev0_21o687pl_1_1_20130404
File Name:/u01/bak/dave_spfile_1mo65679_1_1_20130403
File Name:/u01/bak/arch_27o687s8_1_1_20130404
File Name:/u01/bak/ctl_file_2ao6vobb_1_1_20130413
File Name: /u01/bak/arch_26o687rp_1_1_20130404
File Name:/u01/bak/arch_1ho6566m_1_1_20130403
File Name:/u01/bak/dave_lev0_20o687pl_1_1_20130404
File Name:/u01/bak/arch_1io6566n_1_1_20130403
File Name:/u01/bak/dave_spfile_29o687sc_1_1_20130404
File Name: /u01/bak/ctl_file_1lo65676_1_1_20130403
File Name: /u01/bak/block_change_tracking.f
File Name:/u01/bak/ctl_file_0oo76njm_1_1_20130416
File Name:/u01/bak/ctl_file_28o687sa_1_1_20130404
File Name:/u01/bak/dave_lev0_0ko76nim_1_1_20130416
File Name: /u01/bak/dave_lev0_22o687qp_1_1_20130404
File Name:/u01/bak/dave_lev0_0jo76nh7_1_1_20130416
Do you really want to catalog the abovefiles (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/bak/arch_0no76njh_1_1_20130416
File Name:/u01/bak/dave_lev0_0io76nh7_1_1_20130416
File Name:/u01/bak/ctl_file_2ao6vobb_1_1_20130413
File Name:/u01/bak/ctl_file_0oo76njm_1_1_20130416
File Name:/u01/bak/dave_lev0_0ko76nim_1_1_20130416
File Name: /u01/bak/dave_lev0_0jo76nh7_1_1_20130416
List of Files Which Where Not Cataloged
=======================================
File Name:/u01/bak/dave_lev0_21o687pl_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_spfile_1mo65679_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/arch_27o687s8_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/arch_26o687rp_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/arch_1ho6566m_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_lev0_20o687pl_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/arch_1io6566n_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_spfile_29o687sc_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/ctl_file_1lo65676_1_1_20130403
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name: /u01/bak/block_change_tracking.f
RMAN-07529: Reason: catalog is not supported for this file type
File Name:/u01/bak/ctl_file_28o687sa_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
File Name:/u01/bak/dave_lev0_22o687qp_1_1_20130404
RMAN-07518: Reason: Foreign database file DBID: 854240218 Database Name: DAVE
RMAN>
--效验:
RMAN> list backupset summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ------------------------------ ------- ------- ---------- ---
1 B A A DISK 2013-04-16 04:26:25 1 1 NO ARC_BAK
2 B 0 A DISK 2013-04-16 04:25:11 1 1 NO DAVE_LEV0
3 B F A DISK 2013-04-13 12:56:11 1 1 NO BAK_CTLFILE
4 B F A DISK 2013-04-16 04:26:30 1 1 NO BAK_CTLFILE
5 B 0 A DISK 2013-04-16 04:25:58 1 1 NO DAVE_LEV0
6 B 0 A DISK 2013-04-16 04:25:11 1 1 NO DAVE_LEV0
RMAN> startup mount force;
Oracle instance started
database mounted
Total System Global Area 818401280 bytes
Fixed Size 2232800 bytes
Variable Size 482348576 bytes
Database Buffers 331350016 bytes
Redo Buffers 2469888 bytes
RMAN> restore database;
Starting restore at 2013-04-16 06:10:47
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00001 to /u01/app/oracle/oradata/dave/system01.dbf
channel ORA_DISK_1: restoring datafile00010 to /u01/app/oracle/oradata/dave/FDA03.dbf
channel ORA_DISK_1: restoring datafile00011 to /u01/app/oracle/oradata/dave/FDA04.dbf
channel ORA_DISK_1: restoring datafile00012 to /u01/app/oracle/oradata/dave/ts01.dbf
channel ORA_DISK_1: restoring datafile00013 to /u01/app/oracle/oradata/dave/ts02.dbf
channel ORA_DISK_1: reading from backuppiece /u01/bak/dave_lev0_0io76nh7_1_1_20130416
channel ORA_DISK_1: piecehandle=/u01/bak/dave_lev0_0io76nh7_1_1_20130416 tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:35
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00002 to /u01/app/oracle/oradata/dave/sysaux01.dbf
channel ORA_DISK_1: restoring datafile00003 to /u01/app/oracle/oradata/dave/undotbs01.dbf
channel ORA_DISK_1: restoring datafile00004 to /u01/app/oracle/oradata/dave/users01.dbf
channel ORA_DISK_1: restoring datafile00008 to /u01/app/oracle/oradata/dave/FDA01.dbf
channel ORA_DISK_1: restoring datafile00009 to /u01/app/oracle/oradata/dave/FDA02.dbf
channel ORA_DISK_1: reading from backuppiece /u01/bak/dave_lev0_0jo76nh7_1_1_20130416
channel ORA_DISK_1: piecehandle=/u01/bak/dave_lev0_0jo76nh7_1_1_20130416 tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00005 to /u01/app/oracle/oradata/dave/example01.dbf
channel ORA_DISK_1: restoring datafile00006 to /u01/app/oracle/oradata/dave/mssm01.dbf
channel ORA_DISK_1: restoring datafile00007 to /u01/app/oracle/oradata/dave/assm01.dbf
channel ORA_DISK_1: restoring datafile00014 to /u01/app/oracle/oradata/dave/dave01.dbf
channel ORA_DISK_1: restoring datafile00015 to /u01/app/oracle/oradata/dave/anqing01.dbf
channel ORA_DISK_1: reading from backuppiece /u01/bak/dave_lev0_0ko76nim_1_1_20130416
channel ORA_DISK_1: piecehandle=/u01/bak/dave_lev0_0ko76nim_1_1_20130416 tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:25
Finished restore at 2013-04-16 06:12:14
RMAN> recover database;
Starting recover at 2013-04-16 06:12:17
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 24is already on disk as file/u01/app/oracle/fast_recovery_area/ANQING/archivelog/2013_04_16/o1_mf_1_24_8prydhlc_.arc
archived log for thread 1 with sequence 25is already on disk as file /u01/app/oracle/fast_recovery_area/ANQING/archivelog/2013_04_16/o1_mf_1_25_8prxqnrq_.arc
archived log for thread 1 with sequence 26is already on disk as file/u01/app/oracle/fast_recovery_area/ANQING/archivelog/2013_04_16/o1_mf_1_26_8prydhsm_.arc
channel ORA_DISK_1: starting archived logrestore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=23
channel ORA_DISK_1: reading from backuppiece /u01/bak/arch_0no76njh_1_1_20130416
channel ORA_DISK_1: piece handle=/u01/bak/arch_0no76njh_1_1_20130416tag=ARC_BAK
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:01
archived log filename=/u01/app/oracle/fast_recovery_area/ANQING/archivelog/2013_04_16/o1_mf_1_23_8pryt3dw_.arcthread=1 sequence=23
channel default: deleting archived log(s)
archived log filename=/u01/app/oracle/fast_recovery_area/ANQING/archivelog/2013_04_16/o1_mf_1_23_8pryt3dw_.arcRECID=19 STAMP=812873540
archived log file name=/u01/app/oracle/fast_recovery_area/ANQING/archivelog/2013_04_16/o1_mf_1_24_8prydhlc_.arcthread=1 sequence=24
media recovery complete, elapsed time:00:00:03
Finished recover at 2013-04-16 06:12:23
RMAN> alter database open;
database opened
RMAN>
测试OK。
Forward from http://blog.csdn.net/tianlesoftware/article/details/8836092