Oracle常用的小工具

尛樣兒發表於2010-05-02

1.dbfsize工具:
[oracle@rhel1 oradata]$ dbfsize redo01.log
Database file: redo01.log
Database file type: file system
Database file size: 20480 512 byte blocks

#顯示檔案系統塊或Oracle塊的大小,redo01.log的塊為512byte,一共有20480個塊。

2.oerr工具:
[oracle@rhel1 dev]$ oerr ora 1555
01555, 00000, "snapshot too old: rollback segment number %s with name \"%s\" too small"
// *Cause: rollback records needed by a reader for consistent read are
//         overwritten by other writers
// *Action: If in Automatic Undo Management mode, increase undo_retention
//          setting. Otherwise, use larger rollback segments

#顯示錯誤號的Cause,Action資訊,使用起來非常方便,不過僅在Linux和Unix上有此工具。

3.oradebug工具:
[oracle@rhel1 dev]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sun May 2 23:23:09 2010

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


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

SQL> oradebug
SQL> oradebug help
HELP           [command]                 Describe one or all commands
SETMYPID                                 Debug current process
SETOSPID                          Set OS pid of process to debug
SETORAPID      ['force']        Set Oracle pid of process to debug
SHORT_STACK                              Dump abridged OS stack
DUMP           [addr]  Invoke named dump
DUMPSGA        [bytes]                   Dump fixed SGA
DUMPLIST                                 Print a list of available dumps
EVENT                              Set trace event in process
SESSION_EVENT                      Set trace event in session
DUMPVAR       

[level]  Print/dump a fixed PGA/SGA/UGA variable


DUMPTYPE      
  Print/dump an address with type info

SETVAR        

  Modify a fixed PGA/SGA/UGA variable


PEEK           [level]      Print/Dump memory
POKE                 Modify memory
WAKEUP                           Wake up Oracle process
SUSPEND                                  Suspend execution
RESUME                                   Resume execution
FLUSH                                    Flush pending writes to trace file
CLOSE_TRACE                              Close trace file
TRACEFILE_NAME                           Get name of trace file
LKDEBUG                                  Invoke global enqueue service debugger
NSDBX                                    Invoke CGS name-service debugger
-G                Parallel oradebug command prefix
-R                Parallel oradebug prefix (return output
SETINST              Set instance list in double quotes
SGATOFILE               Dump SGA to file; dirname in double quotes
DMPCOWSGA      Dump & map SGA as COW; dirname in double quotes
MAPCOWSGA               Map SGA as COW; dirname in double quotes
HANGANALYZE    [level] [syslevel]        Analyze system hang
FFBEGIN                                  Flash Freeze the Instance
FFDEREGISTER                             FF deregister instance from cluster
FFTERMINST                               Call exit and terminate instance
FFRESUMEINST                             Resume the flash frozen instance
FFSTATUS                                 Flash freeze status of instance
SKDSTTPCS                Helps translate PCs to names
WATCH         
  Watch a region of memory

DELETE         watchpoint     Delete a watchpoint
SHOW           watchpoints        Show  watchpoints
CORE                                     Dump core without crashing process
IPC                                      Dump ipc information
UNLIMIT                                  Unlimit the size of the trace file
PROCSTAT                                 Dump process statistics
CALL           [-t count] [arg1]...[argn]  Invoke function with arguments
SQL>
SQL> oradebug setmypid
Statement processed.
SQL> alter session set events '10046 trace name context forever ,level 12';

Session altered.

SQL> oradebug eventdump session;
10046 trace name CONTEXT level 12, forever
SQL> oradebug tracefile_name
/u01/app/oracle/admin/ractest/udump/ractest1_ora_12387.trc
SQL> !vi /u01/app/oracle/admin/ractest/udump/ractest1_ora_12387.trc

#oradebug可以顯示已經開啟了的events事件,可以顯示當前使用者、其他使用者的events事件,可以顯示跟蹤檔案的名字等,功能很強大,以上的例子是在會話中開啟了一個10046 event,然後透過oradebug得到跟蹤檔案的路徑和名稱。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23135684/viewspace-661759/,如需轉載,請註明出處,否則將追究法律責任。

相關文章