8.启动数据库到mount状态并注册备份集
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
注册备份集,因为控制文件中的保留的备份信息是原库的,我们这里需要重新注册新库路径下的备份集
RMAN> catalog start with '/u02/ftp/';
Starting implicit crosscheck backup at 29-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 29 objects
Finished implicit crosscheck backup at 29-JUN-12
Starting implicit crosscheck copy at 29-JUN-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 29-JUN-12
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /u02/ftp/
List of Files Unknown to the Database
=====================================
File Name: /u02/ftp/full_backup_20120628_35
File Name: /u02/ftp/full_backup_20120628_37
File Name: /u02/ftp/full_backup_20120628_34
File Name: /u02/ftp/arc_backup_20120628_38
File Name: /u02/ftp/arc_backup_20120628_40
File Name: /u02/ftp/full_backup_20120628_36
File Name: /u02/ftp/full_backup_20120628_31
File Name: /u02/ftp/full_backup_20120628_33
File Name: /u02/ftp/arc_backup_20120628_39
File Name: /u02/ftp/full_backup_20120628_32
File Name: /u02/ftp/full_backup_20120628_30
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u02/ftp/full_backup_20120628_35
File Name: /u02/ftp/full_backup_20120628_37
File Name: /u02/ftp/full_backup_20120628_34
File Name: /u02/ftp/arc_backup_20120628_38
File Name: /u02/ftp/arc_backup_20120628_40
File Name: /u02/ftp/full_backup_20120628_36
File Name: /u02/ftp/full_backup_20120628_31
File Name: /u02/ftp/full_backup_20120628_33
File Name: /u02/ftp/arc_backup_20120628_39
File Name: /u02/ftp/full_backup_20120628_32
File Name: /u02/ftp/full_backup_20120628_30
9.列出当前的所有数据文件
SQL> column name format a60;
SQL> select file# as "file/grp#", name from v$datafile;
file/grp# NAME
---------- ------------------------------------------------------------
1 /u01/app/Oracle/oradata/oracl/system01.dbf';
2 /u01/app/oracle/oradata/oracl/undotbs01.dbf';
3 /u01/app/oracle/oradata/oracl/sysaux01.dbf';
4 /u01/app/oracle/oradata/oracl/users01.dbf';
5 /u01/app/oracle/oradata/oracl/hxl01.dbf';
6 /u01/app/oracle/oradata/oracl/hxl02.dbf';
7 /u01/app/oracle/oradata/oracl/hxl03.dbf';
8 /u01/app/oracle/oradata/oracl/hxl04.dbf';
9 /u01/app/oracle/oradata/oracl/hxl05.dbf';
10 /u02/app/oracle/oradata/oracl/hxl06.dbf';
11 /u02/app/oracle/oradata/oracl/hxl07.dbf';
file/grp# NAME
---------- ------------------------------------------------------------
12 /u02/app/oracle/oradata/oracl/hxl08.dbf';
13 /u02/app/oracle/oradata/oracl/hxl09.dbf';
14 /u02/app/oracle/oradata/oracl/hxl10.dbf';
可以看到,当前控制文件中记录的数据文件的路径是原来的路径,我们在做恢复的时候需要指向新的路径.
10.恢复数据库
RMAN> run{
set newname for datafile 1 to '/u02/mydb/oradata/oracl/system01.dbf';
set newname for datafile 2 to '/u02/mydb/oradata/oracl/undotbs01.dbf';
set newname for datafile 3 to '/u02/mydb/oradata/oracl/sysaux01.dbf';
set newname for datafile 4 to '/u02/mydb/oradata/oracl/users01.dbf';
set newname for datafile 5 to '/u02/mydb/oradata/oracl/hxl01.dbf';
set newname for datafile 6 to '/u02/mydb/oradata/oracl/hxl02.dbf';
set newname for datafile 7 to '/u02/mydb/oradata/oracl/hxl03.dbf';
set newname for datafile 8 to '/u02/mydb/oradata/oracl/hxl04.dbf';
set newname for datafile 9 to '/u02/mydb/oradata/oracl/hxl05.dbf';
set newname for datafile 10 to '/u02/mydb/oradata/oracl/hxl06.dbf';
set newname for datafile 11 to '/u02/mydb/oradata/oracl/hxl07.dbf';
set newname for datafile 12 to '/u02/mydb/oradata/oracl/hxl08.dbf';
set newname for datafile 13 to '/u02/mydb/oradata/oracl/hxl09.dbf';
set newname for datafile 14 to '/u02/mydb/oradata/oracl/hxl10.dbf';
restore database;
switch datafile all;
recover database;
}
11.打开数据库
alter database open resetlogs;
-- The End --