–backup datafile ‘users01.dbf’
RMAN> backup as copy datafile ‘/u01/app/oracle/oradata/PROD1/users01.dbf’;
Starting backup at 09-SEP-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf
output file name=/u01/app/oracle/oradata/PROD1/Disk4/PROD1/datafile/o1_mf_users_byz5gjhx_.dbf tag=TAG20150909T101336 RECID=1 STAMP=889956821
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 09-SEP-15
Starting Control File and SPFILE Autobackup at 09-SEP-15
piece handle=/u01/app/oracle/oradata/PROD1/Disk5/c-2110275382-20150909-00 comment=NONE
Finished Control File and SPFILE Autobackup at 09-SEP-15
RMAN> list copy;
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
——- —- – ————— ———- —————
1 4 A 09-SEP-15 436624 09-SEP-15
Name: /u01/app/oracle/oradata/PROD1/Disk4/PROD1/datafile/o1_mf_users_byz5gjhx_.dbf
Tag: TAG20150909T101336
—on OS level ,rm -rf users01.dbf
[oracle@trsen PROD1]$ rm -rf users01.dbf
–shutdown abort databas and try startup database,the database not open,as follow:
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 476004352 bytes
Fixed Size 2214496 bytes
Variable Size 327157152 bytes
Database Buffers 142606336 bytes
Redo Buffers 4026368 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 – see DBWR trace file=======>not found the datafile 4
ORA-01110: data file 4: ‘/u01/app/oracle/oradata/PROD1/users01.dbf’
–switch datafile copy to restore datafile
RMAN> switch datafile 4 to copy;
datafile 4 switched to datafile copy “/u01/app/oracle/oradata/PROD1/Disk4/PROD1/datafile/o1_mf_users_byz5gjhx_.dbf”
SQL> alter database open
alter database open
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery========>need media recovery at file 4
ORA-01110: data file 4:
‘/u01/app/oracle/oradata/PROD1/Disk4/PROD1/datafile/o1_mf_users_byz5gjhx_.dbf’
–recover datafile 4
RMAN> recover datafile 4;
Starting recover at 09-SEP-15
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 09-SEP-15
SQL> /
Database altered.
SQL> select file_name from dba_data_files;
FILE_NAME
——————————————————————————–
/u01/app/oracle/oradata/PROD1/system01.dbf
/u01/app/oracle/oradata/PROD1/sysaux01.dbf
/u01/app/oracle/oradata/PROD1/undotbs01.dbf
/u01/app/oracle/oradata/PROD1/Disk4/PROD1/datafile/o1_mf_users_byz5gjhx_.dbf====》数据库open起来后,users01.dbf被交换成了copy的文件,
/u01/app/oracle/oradata/PROD1/INDX01.dbf
/u01/app/oracle/oradata/PROD1/EXAMPLE01.dbf
/u01/app/oracle/oradata/PROD1/OLTP01.dbf
/u01/app/oracle/oradata/PROD1/BATCH01.dbf
/u01/app/oracle/oradata/PROD1/Disk6/rcat_ts.dbf
9 rows selected.
–利用此方式可以将其恢复到原先位置,上述也可以通过关闭数据库做rename动作
run {
set newname for datafile 4 to ‘/u01/app/oracle/oradata/PROD1/user01.dbf’;
restore datafile 4;
switch datafile 4;
recover datafile 4;
}