oracle datafile copy,ORACLE 11G 利用copy做datafile恢复

–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;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值