从操作系统rm数据文件后,利用句柄与rman恢复的过程。(已验证)

简介:

以下操作代码的流程是配的,但是相应的文件名,啥的   必须改动。

故障现象

数据文件被误删除

具体情况

接到反馈说,数据文件data20120512.dbf被误删除,需要恢复

数据库提示

ERROR at line 1:
ORA-01116: error in opening database file 16
ORA-01110: data file 16:
‘/u01/app/oracle/product/11.2.0/oradata/ebridge/data20120512.dbf
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

数据库还没有被关闭

解决过程

恢复的原理是,在Linux操作系统中,如果文件从操作系统级别被rm掉,之前打开该文件的进程仍然持有相应的文件句柄,所指向的文件仍然可以读写,并且该文件的文件描述符可以从/proc目录中获得。但是要注意的是,此时如果关闭数据库,则此句柄会消失.

检查dbwr的进程PID
[root@jingyong ~]# ps -ef|grep dbw0|grep -v grep
oracle 2236 1 0 06:40 ? 00:00:01 ora_dbw0_jingyong

dbwr会打开所有数据文件的句柄。在proc目录中可以查到,目录名是进程PID,fd表示文件描述符
[root@jingyong ~]# cd /proc/2236/fd

[root@jingyong fd]# ls -l
total 0
lr-x—— 1 oracle oinstall 64 May 31 08:15 0 -> /dev/null
l-wx—— 1 oracle oinstall 64 May 31 08:15 1 -> /dev/null
l-wx—— 1 oracle oinstall 64 May 31 08:15 10 -> /u01/app/oracle/diag/rdbms/jingyong/jingyong/trace/jingyong_ora_2213.trc
l-wx—— 1 oracle oinstall 64 May 31 08:15 11 -> /u01/app/oracle/diag/rdbms/jingyong/jingyong/trace/jingyong_ora_2213.trm
lr-x—— 1 oracle oinstall 64 May 31 08:15 12 -> /u01/app/oracle/product/11.2.0/db/rdbms/mesg/oraus.msb
lr-x—— 1 oracle oinstall 64 May 31 08:15 13 -> /dev/zero
lr-x—— 1 oracle oinstall 64 May 31 08:15 14 -> /proc/2236/fd
lr-x—— 1 oracle oinstall 64 May 31 08:15 15 -> /dev/zero
lrwx—— 1 oracle oinstall 64 May 31 08:15 16 -> /u01/app/oracle/product/11.2.0/db/dbs/hc_jingyong.dat
lrwx—— 1 oracle oinstall 64 May 31 08:15 17 -> /u01/app/oracle/product/11.2.0/db/dbs/lkJINGYONG
lrwx—— 1 oracle oinstall 64 May 31 08:15 18 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/control01.ctl
lrwx—— 1 oracle oinstall 64 May 31 08:15 19 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/control02.ctl
l-wx—— 1 oracle oinstall 64 May 31 08:15 2 -> /dev/null
lrwx—— 1 oracle oinstall 64 May 31 08:15 20 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/system01.dbf
lrwx—— 1 oracle oinstall 64 May 31 08:15 21 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/sysaux01.dbf
lrwx—— 1 oracle oinstall 64 May 31 08:15 22 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/undotbs01.dbf
lrwx—— 1 oracle oinstall 64 May 31 08:15 23 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/users01.dbf (deleted)
lrwx—— 1 oracle oinstall 64 May 31 08:15 24 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/example01.dbf
lrwx—— 1 oracle oinstall 64 May 31 08:15 25 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/jy01.dbf
lrwx—— 1 oracle oinstall 64 May 31 08:15 26 -> /u01/app/oracle/product/11.2.0/oradata/jingyong/temp01.dbf
lr-x—— 1 oracle oinstall 64 May 31 08:15 27 -> /u01/app/oracle/product/11.2.0/db/rdbms/mesg/oraus.msb
l-wx—— 1 oracle oinstall 64 May 31 08:15 3 -> /u01/app/oracle/product/11.2.0/db/rdbms/log/jingyong_ora_2213.trc
lr-x—— 1 oracle oinstall 64 May 31 08:15 4 -> /dev/null
lr-x—— 1 oracle oinstall 64 May 31 08:15 5 -> /dev/null
lr-x—— 1 oracle oinstall 64 May 31 08:15 6 -> /dev/null
lrwx—— 1 oracle oinstall 64 May 31 08:15 7 -> /u01/app/oracle/product/11.2.0/db/dbs/hc_jingyong.dat

注意其中”/u01/app/oracle/product/11.2.0/oradata/jingyong/users01.dbf (deleted)”字样,表示该文件已经被删除,
直接cp该句柄文件名回原位置

注意(这一步先略过,执行下一步,如果下一步报错如 : cp: cannot create symbolic link `/u01/app/oracle/dradata/orcl/demo01.dbf': No such file or directory,再放过来执行这一步)      ————————  :   [root@jingyong ]#  mkdir -p  /u01/app/oracle/product/11.2.0/oradata/jingyong/users01.dbf 

[root@jingyong fd]# cp -R 23  /u01/app/oracle/product/11.2.0/oradata/jingyong/users01.dbf

进行数据文件恢复
[oracle@jingyong ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 31 08:24:35 2013

Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database datafile 4 offline;

Database altered.

SQL> recover datafile 4;
Media recovery complete.
SQL> alter database datafile 4 online;

Database altered.

 

文章可以转载,必须以链接形式标明出处。


本文转自 张冲andy 博客园博客,原文链接:http://www.cnblogs.com/andy6/p/5744376.html    ,如需转载请自行联系原作者
相关文章
|
Python
python如何使用os模块进行文件和目录操作?
python如何使用os模块进行文件和目录操作?
544 1
|
存储 Linux Python
Python分享之路径与文件 (os.path包, glob包)
Python分享之路径与文件 (os.path包, glob包)
215 0
|
Unix Go
Golang 语言的标准库 os 包怎么操作目录和文件?
Golang 语言的标准库 os 包怎么操作目录和文件?
314 0
|
Linux Shell Go
《Linux操作系统编程》 第五章 文件和文件系统: 了解文件和文件系统的概念和特性,掌握Linux文件系统的基本操作
《Linux操作系统编程》 第五章 文件和文件系统: 了解文件和文件系统的概念和特性,掌握Linux文件系统的基本操作
292 0
|
Python
文件元数据获取方法对比:`os.path` 与 `os.stat`
本文对比了Python中两种获取文件元数据的方法:`os.path`和`os.stat`。通过示例代码展示了如何获取文件大小和修改时间,并从性能、功能性和代码可读性三方面进行了详细对比。最终给出了根据具体需求选择合适方法的最佳实践建议。
363 2
|
存储 Java iOS开发
MacOS环境-手写操作系统-43-dir命令的实现 和 文件写入
MacOS环境-手写操作系统-43-dir命令的实现 和 文件写入
246 0
|
缓存 Linux Windows
初识Linux操作系统(根目录下的重要文件)(命令提示符的含义)
Linux系统基于"一切皆文件"的理念,重要文件分布在如/root(root用户目录)、/home(普通用户目录)、/etc(应用配置)、/dev(设备文件)、/boot(内核及启动文件)、/proc(动态系统信息)、/lib64(库文件)、/opt(软件存放)、/tmp(临时文件)。"[root@localhost ~]#"代表管理员在root目录,"$"代表普通用户。创建新用户用`useradd`命令。调节终端字体大小:Ctrl+Shift++增大,Ctrl+减号缩小。绝对路径从根目录开始,相对路径从当前目录开始。
|
Unix 关系型数据库 API
Python OS 文件/目录方法
Python OS 文件/目录方法
|
Ubuntu Linux iOS开发
LabVIEW在不同操作系统上使VI、可执行文件或安装程序
LabVIEW在不同操作系统上使VI、可执行文件或安装程序
961 3
|
Python
在Python中,利用`os模块`的`path.exists()`函数可判断文件是否存
【5月更文挑战第12天】在Python中,利用`os模块`的`path.exists()`函数可判断文件是否存在,该函数对路径进行检查,存在则返回True,不存在则返回False。示例代码展示了如何检查'example.txt'文件是否存在并相应打印消息。此外,`os.path.isfile()`用于确认路径是否为文件,仅当是文件时返回True,否则返回False,同样配以示例说明其用法。
1468 2

热门文章

最新文章

推荐镜像

更多