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/
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
=====================================
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
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
=======================
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
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
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> }
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.
[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.