03pggb7o_1_1.bak 04pggb87_1_1.bak pfile.ora test
[oracle@bre2 ~]$ mkdir backup
[oracle@bre2 ~]$ mv *.bak backup
[oracle@bre2 ~]$ ls backup
03pggb7o_1_1.bak 04pggb87_1_1.bak
RMAN> catalog backuppiece '/home/oracle/backup/03pggb7o_1_1.bak';
Starting implicit crosscheck backup at 21-AUG-2014 10:32:10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 21-AUG-2014 10:32:10
Starting implicit crosscheck copy at 21-AUG-2014 10:32:10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 21-AUG-2014 10:32:11
searching for all files in the recovery area
cataloging files...
no files cataloged
cataloged backup piece
backup piece handle=/home/oracle/backup/03pggb7o_1_1.bak RECID=2 STAMP=856175531
RMAN> catalog backuppiece '/home/oracle/backup/04pggb87_1_1.bak';
cataloged backup piece
backup piece handle=/home/oracle/backup/04pggb87_1_1.bak RECID=3 STAMP=856175550 5.使用set newname将数据文件还原到不同目录
原来的数据文件目录在/u01/admin/oradata下面,我们将数据文件恢复到/bre1/oradata下面,%b的意思是只获取文件名,没有目录信息
[root@bre2 ~]# mkdir -p /bre1/oradata
[root@bre2 ~]# chown -R oracle:oinstall /bre1
[oracle@bre2 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Aug 21 10:36:10 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: BRE1 (DBID=2522432392, not open)
run{
allocate channel ch1 device type disk;
set newname for database to '/bre1/oradata/%b';
restore database;
release channel ch1;
6> }
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=396 device type=DISK
executing command: SET NEWNAME
Starting restore at 21-AUG-2014 10:38:03
channel ch1: starting datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
channel ch1: restoring datafile 00001 to /bre1/oradata/system01.dbf
channel ch1: restoring datafile 00002 to /bre1/oradata/sysaux01.dbf
channel ch1: restoring datafile 00003 to /bre1/oradata/undotbs01.dbf
channel ch1: restoring datafile 00004 to /bre1/oradata/users01.dbf
channel ch1: restoring datafile 00005 to /bre1/oradata/test.dbf
channel ch1: reading from backup piece /home/oracle/backup/03pggb7o_1_1.bak
channel ch1: piece handle=/home/oracle/backup/03pggb7o_1_1.bak tag=TAG20140821T100336
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:45
Finished restore at 21-AUG-2014 10:38:48
released channel: ch1
数据文件都在了:
[root@bre2 ~]# ls -l /bre1/oradata
total 1564468
-rw-r----- 1 oracle oinstall 629153792 Aug 21 10:38 sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Aug 21 10:38 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 21 10:38 test.dbf
-rw-r----- 1 oracle oinstall 209723392 Aug 21 10:38 undotbs01.dbf
-rw-r----- 1 oracle oinstall 6561792 Aug 21 10:38 users01.dbf
资料上说可以使用switch datafile all来直接修改控制文件中的文件目录,但是我试了一下貌似不行,还是需要在手工rename,下面是我手工修改控制文件中的数据文件目录,先看一下当前的数据文件目录
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/orada