使用RMAN在線移動(dòng)數(shù)據(jù)文件
查看數(shù)據(jù)庫的數(shù)據(jù)文件路徑存在異常,全都放在了空間很小的目錄下這時(shí)在暫時(shí)不能停機(jī)的情況下要移動(dòng)數(shù)據(jù)文件,可以通過RMAN來實(shí)現(xiàn)數(shù)據(jù)文件的offline和online
1.首先備份目標(biāo)數(shù)據(jù)文件:
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.然后將數(shù)據(jù)文件離線:
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數(shù)據(jù)文件:
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.在線移動(dòng)過后的數(shù)據(jù)文件:
alter database datafile 10 online;
這樣數(shù)據(jù)文件就在新的路徑下了
注意:SYSAUX表空間數(shù)據(jù)文件,UNDO表空間數(shù)據(jù)文件,TEMP表空間的臨時(shí)文件不能通過這種方式切換,會(huì)導(dǎo)致數(shù)據(jù)庫宕機(jī),影響業(yè)務(wù)生產(chǎn)
