database 如何查找和跟踪 Oracle 警报日志
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/171868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find and tail the Oracle alert log
提问by tardate
When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment.
当您第一次查看 Oracle 数据库时,第一个问题通常是“警报日志在哪里?”。Grid Control 可以告诉您,但它在环境中通常不可用。
I posted some bash and Perl scripts to find and tail the alert log on my blogsome time back, and I'm surprised to see that post still getting lots of hits.
一段时间前,我发布了一些 bash 和 Perl 脚本来查找和跟踪我博客上的警报日志,我很惊讶地看到该帖子仍然获得了大量点击。
The technique used is to lookup background_dump_dest from v$parameter. But I only tested this on Oracle Database 10g.
使用的技术是从 v$parameter 中查找 background_dump_dest。但我只在 Oracle 数据库 10g 上测试过。
Is there a better approach than this? And does anyone know if this still works in 11g?
还有比这更好的方法吗?有谁知道这在 11g 中是否仍然有效?
回答by cagcowboy
Am sure it will work in 11g, that parameter has been around for a long time.
我确信它可以在 11g 中工作,该参数已经存在很长时间了。
Seems like the correct way to find it to me.
对我来说似乎是找到它的正确方法。
If the background_dump_dest parameter isn't set, the alert.log will be put in $ORACLE_HOME/RDBMS/trace
如果没有设置 background_dump_dest 参数,alert.log 将放在 $ORACLE_HOME/RDBMS/trace 中
回答by pjf
Once you've got the log open, I would consider using File::Tailor File::Tail::Appto display it as it's being written, rather than sleeping and reading. File::Tail::App
is particularly clever, because it will detect the file being rotated and switch, and will remember where you were up to between invocations of your program.
打开日志后,我会考虑使用File::Tail或File::Tail::App在写入时显示它,而不是休眠和阅读。 File::Tail::App
它特别聪明,因为它会检测正在旋转和切换的文件,并且会记住您在程序调用之间的位置。
I'd also consider locking your cache file before using it. The race condition may not bother you, but having multiple people try to start your program at once could result in nasty fights over who gets to write to the cache file.
我还会考虑在使用之前锁定您的缓存文件。竞争条件可能不会打扰您,但是让多个人尝试同时启动您的程序可能会导致激烈的争吵,争夺谁可以写入缓存文件。
However both of these are nit-picks. My brief glance over your code doesn't reveal any glaring mistakes.
然而,这两个都是挑剔的。我对您的代码的简短浏览并没有发现任何明显的错误。