rman对于新手来说是一个难题,然而对我来说同样如此。因此在这里我把我使用rman过程中遇到的问题进行总结以及给出解决的方法。希望给那些同样和我一样的菜了一些宝贵的经验。
 
1、首先就是关于备份后的备份集存放位置的问题
 错误背景:对于全备份来说当在机器A上面进行备份后如果在机器B上进行恢复的时候。备份集存放在B机器什么目录下这个问题困扰了我这个菜了。现在我在这里肯定的告诉大家,放在哪个目录都行,只要恢复的时候oracle用户能读取的权限就可以。当然如果不是和原备份机器相同的目录而在恢复的时候又没有注册备份集的位置那么久会犯和我一样的错误。
解决方法:注册备份集(可以在恢复的时候让rman知道备份集在什么位置),具体做法为(其中/dsms2012为我上传到需要恢复的数据库机器存放备份集的位置):
RMAN> catalog start with '/dsms2012/';
released channel: ORA_DISK_1
searching for all files that match the pattern /dsms2012/
List of Files Unknown to the Database
=====================================
File Name: /dsms2012/arch_ECDSDB_30530_1.bk
File Name: /dsms2012/arch_ECDSDB_30531_1.bk
File Name: /dsms2012/ctl.bk
File Name: /dsms2012/pri_ECDSDB_30526_1.bk
File Name: /dsms2012/pri_ECDSDB_30527_1.bk
File Name: /dsms2012/pri_ECDSDB_30528_1.bk
File Name: /dsms2012/pri_ECDSDB_30529_1.bk
File Name: /dsms2012/spfile.bk
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /dsms2012/arch_ECDSDB_30530_1.bk
File Name: /dsms2012/arch_ECDSDB_30531_1.bk
File Name: /dsms2012/ctl.bk
File Name: /dsms2012/pri_ECDSDB_30526_1.bk
File Name: /dsms2012/pri_ECDSDB_30527_1.bk
File Name: /dsms2012/pri_ECDSDB_30528_1.bk
File Name: /dsms2012/pri_ECDSDB_30529_1.bk
File Name: /dsms2012/spfile.bk
 
 
2、关于原数据库和目标数据库的目录结构的问题
错误背景:作为菜了开始进行恢复的时候我不知道如果没有指定恢复路径,恢复会按备份的控制文件中记录的原数据库的存放路径进行恢复。所以当原数据库结构和目标数据库结构不一样的时候就会犯和我一样的错误。错误信息如下:MAN> RESTORE DATABASE;
Starting restore at 07-JAN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=2190 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/db/oracle/oradata/ecdsdb/rsystem_01_4g
restoring datafile 00002 to /home/db/oracle/oradata/ecdsdb/rundotbs1_01_10g
restoring datafile 00004 to /home/db/oracle/oradata/ecdsdb/ruser_01_512m
restoring datafile 00006 to /home/db/oracle/oradata/ecdsdb/rtbs_data1_01_16g
restoring datafile 00008 to /home/db/oracle/oradata/ecdsdb/rtbs_part_01_16g
channel ORA_DISK_1: reading from backup piece /home/orarch_ecdsdb2/20121218/pri_ECDSDB_30527_1.bk
ORA-19870: error reading backup piece /home/orarch_ecdsdb2/20121218/pri_ECDSDB_30527_1.bk
ORA-19504: failed to create file "/home/db/oracle/oradata/ecdsdb/rtbs_data1_01_16g"
ORA-27040: file create error, unable to create file
HPUX-ia64 Error: 2: No such file or directory
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /home/db/oracle/oradata/ecdsdb/rsysaux_01_4g
restoring datafile 00005 to /home/db/oracle/oradata/ecdsdb/rundotbs2_01_10g
restoring datafile 00007 to /home/db/oracle/oradata/ecdsdb/rtbs_data2_01_24g
restoring datafile 00009 to /home/db/oracle/oradata/ecdsdb/rtbs_idx1_01_16g
restoring datafile 00010 to /home/db/oracle/oradata/ecdsdb/rpatrol_data_01_256m
channel ORA_DISK_1: reading from backup piece /home/orarch_ecdsdb2/20121218/pri_ECDSDB_30526_1.bk
ORA-19870: error reading backup piece /home/orarch_ecdsdb2/20121218/pri_ECDSDB_30526_1.bk
ORA-19504: failed to create file "/home/db/oracle/oradata/ecdsdb/rtbs_data2_01_24g"
ORA-27040: file create error, unable to create file
HPUX-ia64 Error: 2: No such file or directory
failover to previous backup
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/07/2013 13:07:37
RMAN-06026: some targets not found - aborting restore
RMAN-06100: no channel to restore a backup or copy of datafile 10
RMAN-06100: no channel to restore a backup or copy of datafile 9
RMAN-06100: no channel to restore a backup or copy of datafile 8
RMAN-06100: no channel to restore a backup or copy of datafile 7
RMAN-06100: no channel to restore a backup or copy of datafile 6
RMAN-06100: no channel to restore a backup or copy of datafile 5
RMAN-06100: no channel to restore a backup or copy of datafile 4
RMAN-06100: no channel to restore a backup or copy of datafile 3
RMAN-06100: no channel to restore a backup or copy of datafile 2
RMAN-06100: no channel to restore a backup or copy of datafile 1
报如上错误,说明控制文件中记录了目标数据库的数据库文件路径和本地的/home/oracle/oradata/ecdsdb/不同,所以必须重新指向数据文件的位置如下操作。
解决方法:RMAN> run{
2> set newname for datafile 1 to '/home/oracle/oradata/ecdsdb/system_01_4g';
3>    set newname for datafile 2 to '/home/oracle/oradata/ecdsdb/undotbs1_01_10g';
4>    set newname for datafile 4 to '/home/oracle/oradata/ecdsdb/user_01_512m';
5>    set newname for datafile 6 to '/home/oracle/oradata/ecdsdb/tbs_data1_01_16g';
6>    set newname for datafile 8 to '/home/oracle/oradata/ecdsdb/tbs_part_01_16g';
7>    set newname for datafile 3 to '/home/doracle/oradata/ecdsdb/sysaux_01_4g';
8>    set newname for datafile 5 to '/home/oracle/oradata/ecdsdb/undotbs2_01_10g';
9>    set newname for datafile 7 to '/home/oracle/oradata/ecdsdb/tbs_data2_01_24g';
10>    set newname for datafile 9 to '/home/oracle/oradata/ecdsdb/tbs_idx1_01_16g';
11>    set newname for datafile 10 to '/home/oracle/oradata/ecdsdb/patrol_data_01_256m';
12> restore database;
13> }
 
3、关于空间不足的问题
   当我恢复的数据库的目录结构和原备份结构一样的时候。但恢复的过程中发现空间不足。这个时候我第一时间会想到清理磁盘释放空间,但发现这个办法着实不行。于是想到了另外一个办法。此处我恢复的目录为/home/db/oracle/oradata。而 我另外的目录/home/db/oradata的空间能满足恢复需求。于是我对目录/home/db/oracle/oradata做了一个连接。直接指向目录/home/db/oradata这样就把备份的东西直接备份到目录/home/db/oradata。
具体做法如下:ln  -s /home/db/oradata  /home/db/oracle/oradata
4、数据库版本的问题
错误背景:当使用rman进行数据库恢复的时候,我备份的数据库的版本低于我恢复的数据库的版本所以导致恢复之后出现数据库不能成功启动到open状态的错误;错误如下:
RMAN-03002: failure of alter db command at 01/17/2013 16:45:28
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-03114: not connected to ORACLE
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/17/2013 16:45:28
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
解决方法:startup upgrade启动就可以了。

[oracle@localhost bdump]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.2.0 - Production on ?????? 7?? 31 09:26:28 2006
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> STARTUP UPGRADE
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1259744 bytes
Variable Size 75499296 bytes
Database Buffers 88080384 bytes
Redo Buffers 2932736 bytes
Database mounted.
Database opened.
SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql
...

No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP RUL 2006-07-31 10:37:41
DBUA_TIMESTAMP RUL VALID 2006-07-31 10:37:41

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UPGRD_END 2006-07-31 10:37:41
.
Oracle Database 10.2 Upgrade Status Utility 07-31-2006 10:37:41
.
Component Status Version HH:MM:SS
Oracle Database Server VALID 10.2.0.2.0 00:14:58
JServer JAVA Virtual Machine VALID 10.2.0.2.0 00:03:58
Oracle XDK VALID 10.2.0.2.0 00:00:58
Oracle Database Java Packages VALID 10.2.0.2.0 00:01:03
Oracle Text VALID 10.2.0.2.0 00:00:27
Oracle XML Database VALID 10.2.0.2.0 00:01:42
Oracle Data Mining VALID 10.2.0.2.0 00:00:27
OLAP Analytic Workspace VALID 10.2.0.2.0 00:00:32
OLAP Catalog VALID 10.2.0.2.0 00:01:04
Oracle OLAP API VALID 10.2.0.2.0 00:01:06
Oracle interMedia VALID 10.2.0.2.0 00:08:36
Spatial VALID 10.2.0.2.0 00:00:58
Oracle Expression Filter VALID 10.2.0.2.0 00:00:21
Oracle Enterprise Manager VALID 10.2.0.2.0 00:01:04
Oracle Rule Manager VALID 10.2.0.2.0 00:00:20
.
Total Upgrade Time: 00:37:41
DOC>#######################################################################
DOC>#######################################################################
DOC>
DOC> The above PL/SQL lists the SERVER components in the upgraded
DOC> database, along with their current version and status.
DOC>
DOC> Please review the status and version columns and look for
DOC> any errors in the spool log file. If there are errors in the spool
DOC> file, or any components are not VALID or not the current version,
DOC> consult the Oracle Database Upgrade Guide for troubleshooting
DOC> recommendations.
DOC>
DOC> Next shutdown immediate, restart for normal operation, and then
DOC> run utlrp.sql to recompile any invalid application objects.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SQL> !oerr ora 39700
39700, 00000, "database must be opened with UPGRADE option"
// *Cause: A normal database open was attempted, but the database has not
// been upgraded to the current server version.
// *Action: Use the UPGRADE option when opening the database to run
// catupgrd.sql (for database upgrade), or to run catalog.sql
// and catproc.sql (after initial database creation).
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1259744 bytes
Variable Size 121636640 bytes
Database Buffers 41943040 bytes
Redo Buffers 2932736 bytes
Database mounted.
Database opened.