事实上,RMAN备份的时候,如果是使用control file 来作catalog,那么一定要把control file和spfile恢复到另外的机器上面。
否则,会出现类似如下的错误:
原来的实例:
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 6 15:54:41 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1370687811)
RMAN> backup tablespace users;
Starting backup at 06-APR-14
using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=41 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbfchannel ORA_DISK_1: starting piece 1 at 06-APR-14channel ORA_DISK_1: finished piece 1 at 06-APR-14piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_nnndf_TAG20140406T155529_9n223km6_.bkp tag=TAG20140406T155529 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 06-APR-14RMAN> quit
Recovery Manager complete.[oracle@localhost ~]$
然后,如果我另外再安装一套oracle,会发生什么状况呢?
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 6 16:00:00 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1371965186, not open)
RMAN> list backup;
using target database control file instead of recovery catalog
specification does not match any backup in the repositoryRMAN> restore tablespace users from '/u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_nnndf_TAG20140406T155529_9n223km6_.bkp';
Starting restore at 06-APR-14
allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISKRMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of restore command at 04/06/2014 16:00:38RMAN-06509: only SPFILE or control file can be restored from AUTOBACKUPRMAN>
一开始,我对上述的RMAN-06509非常不理解,后来参考了如下的网站,明白了错误所在。
http://www.doc88.com/p-900857827054.html
由于RMAN要依赖于catalog,当catalog是controle file的形式的时候,需要先把control file和spfile拿到新的数据库实例的对应的目录下,那样才可以继续进行restore/recover的活动。
***********************************************
接着我又进行了试验,看看把control file 挪过来回如何:
旧实例上:
RMAN> backup current controlfile;
Starting backup at 06-APR-14
using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=33 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setchannel ORA_DISK_1: starting piece 1 at 06-APR-14channel ORA_DISK_1: finished piece 1 at 06-APR-14piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_ncnnf_TAG20140406T213831_9n2p6rw4_.bkp tag=TAG20140406T213831 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 06-APR-14RMAN>
在旧实例上:
RMAN> backup current controlfile;
Starting backup at 06-APR-14
using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=33 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setchannel ORA_DISK_1: starting piece 1 at 06-APR-14channel ORA_DISK_1: finished piece 1 at 06-APR-14piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_ncnnf_TAG20140406T213831_9n2p6rw4_.bkp tag=TAG20140406T213831 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 06-APR-14RMAN>
[oracle@localhost ~]$ cd /u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/
[oracle@localhost 2014_04_06]$ cp o1_mf_ncnnf_TAG20140406T213831_9n2p6rw4_.bkp /u02/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/
然后,启动新实例
SQL> startup nomount;
ORACLE instance started.Total System Global Area 814227456 bytes
Fixed Size 2257640 bytesVariable Size 528485656 bytesDatabase Buffers 281018368 bytesRedo Buffers 2465792 bytesSQL>
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 6 21:45:09 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (not mounted)
RMAN>
开始恢复control file,进而得到备份集的信息:
RMAN> restore controlfile from '/u02/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_ncnnf_TAG20140406T213831_9n2p6rw4_.bkp';
Starting restore at 06-APR-14
using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISKchannel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/u02/app/oracle/oradata/orcl/control01.ctloutput file name=/u02/app/oracle/fast_recovery_area/orcl/control02.ctlFinished restore at 06-APR-14RMAN> list backup;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of list command at 04/06/2014 21:46:06ORA-01507: database not mountedRMAN> quit
********************************************************
SQL> alter database mount;
Database altered.
SQL>
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 6 21:46:42 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1370687811, not open)
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
=================== BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------1 Full 1.43M DISK 00:00:00 06-APR-14 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20140406T155529 Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_nnndf_TAG20140406T155529_9n223km6_.bkp List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 988907 06-APR-14 /u01/app/oracle/oradata/orcl/users01.dbfRMAN>
这些个信息里面记的都是旧实例所拥有的位置信息。
再试验看:
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
=================== BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------1 Full 1.43M DISK 00:00:00 06-APR-14 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20140406T155529 Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_nnndf_TAG20140406T155529_9n223km6_.bkp List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 988907 06-APR-14 /u01/app/oracle/oradata/orcl/users01.dbfRMAN> restore tablespace users from '/u01/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_nnndf_TAG20140406T155529_9n223km6_.bkp';
Starting restore at 06-APR-14
Starting implicit crosscheck backup at 06-APR-14allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=18 device type=DISKCrosschecked 1 objectsFinished implicit crosscheck backup at 06-APR-14Starting implicit crosscheck copy at 06-APR-14
using channel ORA_DISK_1Finished implicit crosscheck copy at 06-APR-14searching for all files in the recovery area
cataloging files...cataloging doneList of Cataloged Files
=======================File Name: /u02/app/oracle/fast_recovery_area/ORCL/backupset/2014_04_06/o1_mf_ncnnf_TAG20140406T213831_9n2p6rw4_.bkpFile Name: /u02/app/oracle/fast_recovery_area/ORCL/archivelog/2014_04_06/o1_mf_1_3_9n22917q_.arcusing channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of restore command at 04/06/2014 21:56:09RMAN-06509: only SPFILE or control file can be restored from AUTOBACKUPRMAN>
因为新旧实例不同,所以会出问题。