您的位置:首页 > 其它

【翻译自mos文章】 在错误的从os级别remove掉 trace file 之后,怎么找到该trace file的内容?

2014-07-11 07:33 771 查看
在错误的从os级别remove掉 trace file 之后,怎么找到该trace file的内容?

参考原文:

How to Find the Content of Trace File Generated for an Oracle Process after Removing the Trace File by Mistake at OS Level (Doc ID 805083.1)

适用于:

Oracle Database - Enterprise Edition - Version 8.1.7.4 to 11.2.0.1.0 [Release 8.1.7 to 11.2]

Generic UNIX

Generic Linux

目标:

当错误的从从os级别remove(这个remove是指rm)掉 trace file 之后,oracle进程的trace file 是不会被重新创建的。

那怎么看到这些trace file的内容?

解决方案:

这种行为的解释 和解决方案在

Bug 8367394: A NEW TRACE FILE IS NOT BEING CREATED IF THE INITIAL ONE WAS REMOVED

给出了。--->注意:我看了一下该bug的workground,是restart instance。

在下面的例子中,请注意从11g开始,trace file的位置不在bdump 下,而是在{ADR_HOME}/trace/下。

当进程是alive的时候,进程不会在 trace file上执行close()函数。

进程依然持有 指向trace file 的 file descriptor。

trace file 的名字包括进程的pid,

因此,除非进程被重启,否则我们不能关闭 file descriptor,也不能创建一个用新文件名或者老文件名的新文件

这并不意味着,在紧急情况下,你不能访问该trace file。

当该trace file 被delete掉后,只要file descriptor依然open,你就可以获得该文件的内容,该内容依然被正常写。

通过如下方法经过file descriptor 来访问 file

ps -ef|grep v10204|grep dbw0

oracle 11283 1 0 16:23 ? 00:00:00 ora_dbw0_v10204

lsof -p 11283|grep dbw0

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME

oracle 11283 oracle 2 REG 3,1 767 20728692 /bdump/v10204_dbw0_11283.trc

从上面的结果中,我们可以看到fd 为2,如下也能验证fd 为2

ls -lA /proc/11283/fd | grep dbw0

l-wx------ 1 oracle dba-64 Mar 25 16:24 2 -> /bdump/v10204_dbw0_11283.trc

从os级别 remove掉trace file ,fd 依然存在,只是file 被delete掉了。

ls -lA /proc/11283/fd | grep dbw0

l-wx------ 1 oracle dba-64 Mar 25 16:24 2 -> /bdump/v10204_dbw0_11283.trc (deleted)

这个fd (file descriptor)在它被关闭 或者 进程被重启之前 是存在的。

你可以访问它的内容:

cat /proc/11283/fd/2 > /tmp/v10204_dbw0_11283.trc
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐