您的位置:首页 > 数据库 > Oracle

oracle11g 数据文件误删恢复(…

2016-01-29 10:27 495 查看
OS:

Oracle Linux Server release 5.7

 

DB:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 -
64bit Production

 

首先创建yoon数据库

SQL> create tablespace yoon datafile
'/u01/oracle/oradata/yoon/yoon01.dbf' size 50m;

Tablespace created.

 

SQL> create user yoon identified by yoon default tablespace
yoon;

User created.

 

SQL> grant dba to yoon;

Grant succeeded.

 

SQL> create table yoon.yoon as select * from scott.emp;

Table created.

 

在操作中误删除数据文件yoon01.dbf

rm -rf yoon01.dbf

select ts#,file#,name,bytes,status from v$datafile;

ps -ef | grep dbw  | grep -v grep

cd /proc/..../fd

 

一、在线恢复:

[oracle@b28-122 yoon]$ rm -rf yoon01.dbf

 

[oracle@b28-122 yoon]$ ps -ef |grep dbw |grep -v grep

oracle  
17417    
1  0 00:51
?       
00:00:00 ora_dbw0_yoon

 

[oracle@b28-122 yoon]$ cd /proc/17417/fd

 

[oracle@b28-122 fd]$ cp 267
/u01/oracle/oradata/yoon/newyoon01.dbf

 

SQL> alter database datafile 6 offline;

Database altered.

 

SQL> alter database rename file
'/u01/oracle/oradata/yoon/yoon01.dbf' to
'/u01/oracle/oradata/yoon/newyoon01.dbf';

Database altered.

 

SQL> recover datafile 6;

Media recovery complete.

 

SQL> alter database datafile 6 online;

Database altered.

 

二、离线恢复

rm -rf yoon01.dbf

ps -ef | grep dbw | grep -v grep

cp /proc/.../fd/...  
/u01/oracle/oradata/yoon/yoon01.dbf

shutdown immediate

startup

recover database;

alter database open;

 

[oracle@b28-122 yoon]$ rm -rf yoon01.dbf

 

[oracle@b28-122 yoon]$ ps -ef | grep dbw | grep -v grep

oracle  
18743    
1  0 01:03
?       
00:00:00 ora_dbw0_yoon

 

[oracle@b28-122 yoon]$ cd /proc/18743/fd

 

[oracle@b28-122 fd]$ cp 265
/u01/oracle/oradata/yoon/yoon01.dbf

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

SQL> startup

ORACLE instance started.

Total System Global Area 3340451840 bytes

Fixed
Size                 
2232960 bytes

Variable
Size           
2432699776 bytes

Database
Buffers         
889192448 bytes

Redo
Buffers              
16326656 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 6 - see DBWR trace
file

ORA-01110: data file 6: '/u01/oracle/oradata/yoon/yoon01.dbf'

 

SQL> recover database;

Media recovery complete.

 

SQL> alter database open;

Database altered.

 

SQL> select * from yoon.yoon;

    
EMPNO
ENAME                         
JOB                               
MGR
HIREDATE                 
SAL      
COMM    
DEPTNO

---------- ------------------------------
--------------------------- ---------- ------------------
---------- ---------- ----------

     
7369
SMITH                         
CLERK                            
7902
17-DEC-80                
800                   
20

     
7499
ALLEN                         
SALESMAN                         
7698
20-FEB-81               
1600   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: