查看数据库的数据文件路径存在异常,全都放在了空间很小的目录下这时在暂时不能停机的情况下要移动数据文件,可以通过RMAN来实现数据文件的offline和online
1.首先备份目标数据文件:
RMAN> backup as copy datafile 10 format ‘/data/orcl/oradata/foruse01.dbf’;
Starting backup at 11-JUN-21
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00010 name=/u01/app/oracle/product/11.2.0/db_1/dbs/foruse01.dbf
output file name=/data/orcl/oradata/foruse01.dbf tag=TAG20210511T165624 RECID=134 STAMP=1072285084
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:45
Finished backup at 11-JUN-21
2.然后将数据文件离线:
alter database datafile 10 offline;
3.通过rman切换:
RMAN> switch datafile 10 to copy;
datafile 10 switched to datafile copy “/data/orcl/oradata/foruse01.dbf”
4.recover数据文件:
RMAN> RECOVER datafile 10;
Starting recover at 11-JUN-21
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 11-JUN-21
5.在线移动过后的数据文件:
alter database datafile 10 online;
这样数据文件就在新的路径下了
注意:SYSAUX表空间数据文件,UNDO表空间数据文件,TEMP表空间的临时文件不能通过这种方式切换,会导致数据库宕机,影响业务生产