背景描述:
某客户某数据库需要迁移,需要搭建从rac-rac的dg,进行数据库切换/强制打开
由于该数据库数据量达到30T,但nfs挂载盘仅有1T,所以需要分多次进行copy
在主库将数据文件从asm拷贝至nfs磁盘中,然后再将数据文件从nfs磁盘拷贝至目标库asm磁盘中
但是在将数据文件从nfs磁盘拷贝至目标库asm磁盘中却发生了报错:
RMAN-20201: datafile not found in the recovery catalog
RMAN-06010: error while looking up datafile: /tmp/aaa.dbf
测试环境模拟该问题产生:
create tablespace aa datafile ‘/tmp/tmp/aaa.dbf’ size 10M autoextend on;
Rman copy数据文件从/tmp/tmp/至/tmp/目录中
RMAN> copy datafile ‘/tmp/tmp/aaa.dbf’ to ‘/tmp/aaa.dbf’;
Starting backup at 24-APR-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=307 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/tmp/tmp/aaa.dbf
output filename=/tmp/aaa.dbf tag=TAG20200424T140413 recid=3 stamp=1038578653
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 24-APR-20
再次拷贝,尝试将数据文件由/tmp/拷贝至/app/oracle/oradata/orcl/目录,果然报错了:
RMAN> copy datafile ‘/tmp/aaa.dbf’ to ‘/app/oracle/oradata/orcl/aaa.dbf’;
Starting backup at 24-APR-20
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 04/24/2020 14:04:40
RMAN-20201: datafile not found in the recovery catalog
RMAN-06010: error while looking up datafile: /tmp/aaa.dbf
这是什么原因呢?这是由于控制文件中记录的数据文件信息为/tmp/tmp/aaa.dbf,所以数据库只对/tmp/tmp/aaa.dbf文件
有读写控制权限,无法将/tmp/aaa.dbf拷贝至别的目录
验证如下:
对aaa.dbf数据文件进行rename,使得控制文件中记录的位置为/tmp/aaa.dbf
SQL> select file_id,file_name from dba_data_files;
FILE_ID FILE_NAME
4 /app/oracle/oradata/orcl/users01.dbf
3 /app/oracle/oradata/orcl/sysaux01.dbf
2 /app/oracle/oradata/orcl/undotbs01.dbf
1 /app/oracle/oradata/orcl/system01.dbf
5 /tmp/tmp/aaa.dbf
SQL> alter database datafile 5 offline;
Database altered.
SQL> alter database rename file ‘/tmp/tmp/aaa.dbf’ to ‘/tmp/aaa.dbf’;
Database altered.
再次拷贝/tmp/aaa.dbf至/app/oracle/oradata/orcl/目录,正常
RMAN> copy datafile ‘/tmp/aaa.dbf’ to ‘/app/oracle/oradata/orcl/aaa.dbf’;
Starting backup at 24-APR-20
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/tmp/aaa.dbf
output filename=/app/oracle/oradata/orcl/aaa.dbf tag=TAG20200424T140618 recid=4 stamp=1038578779
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 24-APR-20