Mac De Oracle - Undocument command - oradebug Tweet
oradebugコマンドは、通常はサポートから依頼されて利用することが多いコマンド。
oradebugコマンドについては、以下のサイトが参考になるが、本番環境では問題が発生しテクニカルサポートからの指示がない限り、まず、使うことのないコマンドであり、ドキュメント化もされていないのも当然。oradebugについて細かいことを書くつもりは全くないのだが、、、
開発環境や評価環境でOracleのUndergroundな情報も見たい、知りたいという方は、これらのサイトを見て、ご自身の責任において遊んでみるのもいいかもしれない。
Underground Oracle FAQ'sは、Oracle7の頃からあるサイトだと記憶しているが、NLS絡み以外のことでは、かなりお世話になったサイト。
http://www.orafaq.com/faq/internals
http://www.orafaq.com/faq/how_does_one_use_the_oradebug_command
以下のサイトは、oradebugコマンド関連についても書かれているサイト。このサイトの存在は最近になって知った。
http://julian.dyke.users.btopenworld.com/Oracle/
http://julian.dyke.users.btopenworld.com/Oracle/Diagnostics/Dumps/ERRORSTACK.html
http://julian.dyke.users.btopenworld.com/Oracle/Diagnostics/Events/EventReference.html
ドキュメント化はされていないが、SQL*Plusで、oradebug help とタイプするとコマンド一覧がリストされる。
SYS> conn / as sysdba
SYS>
SYS> oradebug help
HELP [command] Describe one or all commands
SETMYPID Debug current process
SETOSPID <ospid> Set OS pid of process to debug
SETORAPID <orapid> ['force'] Set Oracle pid of process to debug
DUMP <dump_name> <lvl> [addr] Invoke named dump
DUMPSGA [bytes] Dump fixed SGA
DUMPLIST Print a list of available dumps
...以下略...
SYS>
以下の例では、セッションのステータスが 'ACTIVE'な 'SCOTT'ユーザのセッションに紐づくプロセスがハングしているようなので、ERRORSTACKをダンプしているところです。
この辺りの使い方は、こちらを見てくださいな。(似たようなサンプルは、おら!、オラ!、Oracle!でも取り上げられているので、そちらを見るのもいいかも。)
SYS> select
2 pid
3 from
4 v$process
5 where
6 addr in
7 (
8 select
9 paddr
10 from
11 v$session
12 where
13 username = 'SCOTT' and status='ACTIVE'
14 );
PID
----------
17
SYS> oradebug setorapid 17
Unix process pid: 876, image: oracle@G5Server.local (TNS V1-V3)
SYS> oradebug unlimit
文が処理されました。
SYS> oradebug dump errorstack 3
文が処理されました。
SYS>
SYS>
とまあこんな感じで、あるプロセスのダンプの取得が必要なことも多々あるわけです。
前述の例のように、対象プロセスが1つに特定されてたり、マニュアル操作で事足りる状況であれば、それはそれでよいのですが、大抵の場合、そのような操作を行わなければならない状況というものは、ある現象が起こったタイミングで行わなければならないということが殆どではないでしょうか?。
例えば、夜中の特定時間の特定タイミングに実行しなければならないとか、実は、複数のプロセスのダンプを取らないと行けないかもしれない。などなど。
そのような場合、上記の操作をスクリプト化して一時的に組み込んだり、必要なタイミングで起動する等で、夜中に付き合わなくても、あとは寝て待て! というロハスで省エネな時間を過ごせるわけです。(常にそうできるとは限りませんが。。。)
ということで、前述のクエリやoradebugコマンドをいちいちタイプするのは面倒なのでPL/SQLとSQLスクリプトを利用して一括して実行できるようにしてみることにする。
G5Server:˜ oracle$ cat make_oradebug_commands.sql
set feed off
set echo off
set serveroutput on format wrapped
spo oradebug_commands.sql
begin
for pid in (select pid from v$process where addr in
(select paddr from v$session where username = 'SCOTT')
)
loop
dbms_output.put_line('oradebug setorapid '||to_char(pid.pid));
dbms_output.put_line('oradebug unlimit');
dbms_output.put_line('oradebug dump errorstack 3');
end loop;
end;
/
spo off
set feed on
@@oradebug_commands.sql
G5Server:˜ oracle$
G5Server:˜ oracle$ sqlplus / as sysdba @make_oradebug_commands.sql
SQL*Plus: Release 10.1.0.3.0 - Production on 木 11月 23 20:46:14 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
に接続されました。
oradebug setorapid 17
oradebug unlimit
oradebug dump errorstack 3
Unix process pid: 876, image: oracle@G5Server.local (TNS V1-V3)
文が処理されました。
文が処理されました。
SYS> !cat oradebug_commands.sql
oradebug setorapid 17
oradebug unlimit
oradebug dump errorstack 3
SYS>
このspoolファイルにスクリプト部分のみを出力後、@又は、@@やstartコマンドで実行する方法は、oradebugコマンドの実行だけでなく、通常のSQLスクリプトなどへの応用可能だ。少々工夫する必要はあるが、shell scriptやWindowsのバッチファイルを動的に生成して実行するということも可能だ。応用範囲は広いのだ。
尚、shell scriptやwindowsのバッチファイルはhostコマンド又は、!(windowsでは$)で実行できる。
そう言えば、昨年の今頃は、Blue Note Tokyoで Marcus Millerのライブを見てたっけ。ということで、
聞いている曲:Marcus Miller - Silver Rain - Bruce Lee
| 固定リンク | 0


コメント