如果数据文件或日志文件的位置发生了改变,那么有多种方法可以解决这个问题。比如使用ALTER DATABASE RENAME DATAFILE的方法,或者SET NEWNAME。
但是如果备份集的位置改变,Oracle在10g以前并没有提供相应的解决方法。
这篇文章介绍9i如何通过Oracle的DBMS_BACKUP_RESTORE包来实现这个功能。
在进行备份之前,检查备份表空间的信息:
SQL> SELECT FILE_ID, TABLESPACE_NAME FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = 'USERS';
FILE_ID TABLESPACE_NAME
---------- ------------------------------
9 USERS
下面对表空间USERS进行备份:
$ rman target /
Recovery Manager: Release 9.2.0.4.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: MEMBER (DBID=1303377880)
RMAN> backup tablespace indx, info, users, tools;
Starting backup at 24-8月 -07
using target database controlfile instead of recovery catalog
configuration for DISK channel 2 is ignored
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=20 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00018 name=/data/oradata/member/info.dbf
input datafile fno=00009 name=/data/oradata/member/users01.dbf
input datafile fno=00006 name=/data/oradata/member/indx01.dbf
input datafile fno=00008 name=/data/oradata/member/tools01.dbf
channel ORA_DISK_1: starting piece 1 at 24-8月 -07
channel ORA_DISK_1: finished piece 1 at 24-8月 -07
piece handle=/data/backup/member/5siq6isk_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 24-8月 -07
可以看到备份的输出备份集在/data/backup/member目录下,如果将备份通过操作系统转移到/data/backup目录下,则Oracle恢复的时候无法找到备份集,在9i及以前版本,Oracle也没有提供相应的命令来重定位这个备份集。
在操作系统级的解决方案是,建立一个文件连接ln,指向新的位置。如果要从Oracle方面解决这个问题,就只能使用DBMS_BACKUP_RESTORE包。
$ mv /data/backup/member/5siq6isk_1_1 /data/backup/
IXDBA.NET社区论坛
$ rman target /
Recovery Manager: Release 9.2.0.4.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: MEMBER (DBID=1303377880)
RMAN> sql 'alter tablespace users offline';
using target database controlfile instead of recovery catalog
sql statement: alter tablespace users offline
RMAN> restore tablespace users;
Starting restore at 24-8月 -07
configuration for DISK channel 2 is ignored
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=11 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00009 to /data/oradata/member/users01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/24/2007 13:17:23
ORA-19505: failed to identify file "/data/backup/member/5siq6isk_1_1"
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
由于找不到相应的备份集,