ablog

不器用で落着きのない技術者のメモ

DTrace で Oracle Database のサーバー・プロセスをトレースしてみた

2010-03-22 - 未来のいつか/hyoshiokの日記
第102回カーネル読書会 に行ってきて、DTrace を使ってみようと思ってもう 2 ケ月近くすぎた。
やっと使ってみた。


sqlplus でログインして、

$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sun May 16 04:59:23 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 

DTrace でトレースを開始して、

$ su -
# ps -ef|grep [o]racleorcl
  502   475   474   0   0:00.02 ??         0:00.03 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
# dtrace -p 475 -Fn 'pid$target:oracle:qer*Fetch*:entry pid$target:oracle:qer*Fetch*:return'
dtrace: description 'pid$target:oracle:qer*Fetch*:entry pid$target:oracle:qer*Fetch*:return' matched 269 probes

SQL を実行してみると、

SQL> select count(1) from all_users;

  COUNT(1)
----------
	27

SQL> 

お、なんか出た。

# ps -ef|grep [o]racleorcl
  502   475   474   0   0:00.02 ??         0:00.03 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
# dtrace -p 475 -Fn 'pid$target:oracle:qer*Fetch*:entry pid$target:oracle:qer*Fetch*:return'
dtrace: description 'pid$target:oracle:qer*Fetch*:entry pid$target:oracle:qer*Fetch*:return' matched 269 probes
CPU FUNCTION                                 
  0  -> qergsFetch                            
  0    -> qerhjFetch                          
  0      -> qerhjFetch                        
  0        -> qertbFetch                      
  0        <- qertbFetch                      
  0        -> qertbFetch                      
  0        <- qertbFetch                      
  0      <- qerhjFetch                        
  0      -> qertbFetch                        
  0      <- qertbFetch                        
  0    <- qerhjFetch                          
  0  <- qergsFetch                      

環境は以下の通り。

# sw_vers
ProductName:	Mac OS X
ProductVersion:	10.6.3
BuildVersion:	10D578
# uname -a
Darwin yoheia-no-macbook 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386
# su - oracle
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sun May 16 05:08:11 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE	10.2.0.4.0	Production
TNS for MacOS X Server: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production