Oratop工具——實時數據庫性能監控工具

Oratop工具——實時數據庫性能監控工具



在任何系統優化過程當中,「80/20原則」是咱們必定要關注的問題。簡單的說,就是咱們系統80%的性能問題、現象,都是有少數幾個甚至一個問題形成的。這就須要咱們面對複雜的系統性能問題的時候,要學會「撥開雲霧、蛇打七寸」。 html

 

落實在Oracle優化過程,一樣如此。從10g開始,咱們開始頻繁接受「Top-xxx」的概念,不管是從OEMOracle Enterprise Manager)仍是藉助AWR過後報告庫,解決主要矛盾,發掘主要Top Events就成了咱們平常工做不可缺乏的部分。 node

 

實際工做中,對Top的發掘和Oracle動態信息的收集,不少時候仍是有點力不從心和滯後之感強烈。Oracle官方的客戶服務網站MOS,常常有一些有用的小工具,提供給咱們使用。本篇中,咱們主要來介紹下Oratop工具的特色和使用。 linux

 

1Oratop工具簡述 面試

 

Oratop源自MOS的一篇文章和工具連接(oratop - utility for near real-time monitoring of databases, RAC and Single Instance [ID 1500864.1])。從名稱上看,Oratop最大特色是支持實時輕量級監控。在Oracle 12cEM Express以前,OEM仍是一個重體積的組件。相比之下,oratop徹底適合那些想使用數據庫實時監控功能,可是又不肯意啓動OEM的用戶須要。 sql

 

從功能上看,Oratop主要有三大特色: shell

 

ü  監控當前的數據庫活動; 數據庫

ü  監控數據庫性能; bash

ü  識別當前阻塞會話和瓶頸會話; 服務器

 

目前,Oratop是在MOS上免費下載,分別有32位和64位兩個版本。

 

2、軟件安裝初啓動

 

從網站上下載軟件以後,是一個命名爲oratop.v13.2.1_X8664的可執行程序,注意要區分32位版和64位版。

 

首先,判斷適合的Linux版本,而且建立程序目錄。Oratop是一個典型的「綠色」軟件,不須要安裝,只須要給一個運行目錄便可。

 

--64位操做系統

[root@localhost ~]# uname -a

Linux localhost.localdomain 2.6.32-279.el6.x86_64 #1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

 

 

[root@localhost ~]# mkdir /oratop

[root@localhost ~]# cd /oratop

[root@localhost /]# cd oratop/

[root@localhost oratop]# ls -l

total 0

[root@localhost oratop]#

 

 

進行目錄的權限轉換和程序拷貝。爲了方便執行,咱們最好還要進行一下重命名工做。

 

 

[root@localhost /]# chown -R oracle:oinstall /oratop

[root@localhost /]# su - oracle

[oracle@localhost ~]$ cd /oratop/

[oracle@localhost oratop]$ ls -l

total 92

-rw-r--r--. 1 oracle oinstall 93640 May 17 13:39 oratop.v13.2.1_X8664

 

[root@localhost oratop]# ls -l

total 92

-rw-r--r--. 1 root root 93640 May 17 13:39 oratop.v13.2.1_X8664

 

[oracle@localhost oratop]$ mv oratop.v13.2.1_X8664 oratop

[oracle@localhost oratop]$ ls -l

total 92

-rw-r--r--. 1 oracle oinstall 93640 May 17 13:39 oratop

 

 

注意:使用oratop在環境變量上須要一些額外的配置內容。主要是對於變量LD_LIBRARY_PATH的配置。咱們通常都不會去配置這目錄,可是oratop要求必須進行配置。

 

配置方法是修改根目錄上的.bash_profile文件。

 

 

[oracle@localhost ~]$ vi .bash_profile

 

 

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export ORACLE_SID=isis2db

 

export PATH=$PATH:$ORACLE_HOME/bin

 

(篇幅緣由,掠過部份內容……

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

".bash_profile" 36L, 901C written                            

[oracle@localhost ~]$

 

 

[oracle@localhost ~]$ env | grep LIB

LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib

 

 

下面咱們來試着執行如下命令。

 

 

[oracle@localhost oratop]$ ./oratop -i 10 / as sysdba

 

oratop: Release 13.2.1 Production on Fri May 17 13:43:34 2013

 

Copyright (c) 2011, Oracle.  All rights reserved.

 

Processing ...(等待片刻……

 

 

參數-i表示數據刷新間隔,也就是多長實際更新一下頁面數據信息。/ as sysdba表示登陸本機鏈接。注意,這也就意味着咱們能夠遠程使用oratop鏈接到其餘服務器上面去。更進一步說,經過遠程鏈接的方法,能夠鏈接到任何版本操做系統上的Oracle服務器的。

 

出現字符界面顯示。

 

 

 

oratop 1:  131 isis 13:44:24 up  0.0h,  1 ins,   3G mt,  41 sn,  3 us,   0% db

ID %CU HLD MBPS IORL %FR PGAU ASC ASI ASW ASP   AAS USN  TPS UCPS SSRT DBC DBW

 1  12   0   71   0m  18 161M   1   0   0   0   0.1  41    0   24   3m  94   6

                                                                             

EVENT     (Cumulative)      AVG: TOT WAITS  TIME(s)  AVG_MS PCT  WAIT_CLASS  

DB CPU                                       112868          75              

SQL*Net message from dblink       16794060    14852     0.9  10  Network     

SQL*Net more data from clien        193150     8260    42.8   5  Network     

log file parallel write            1025524     7308     7.1   5  System I/O  

enq: TX - row lock contentio          1289     7248  5622.9   5  Application 

                                                                             

ID   SID  SPID USR PROG  PGA OPN SQLID/BLOCKER  E/T STATUS STE WAIT_EVENT  W/T

 

 

3、初識Oratop

 

從字符界面上看,oratop結果集合分爲四個部分,分別爲:Header SectionDatabase SectionDB Events SectionProcesses Section

 

 

 

Header Section中,包括了鏈接數據庫的整體信息,包括運行多長時間、實例個數(for RAC)、內存大小和數據庫佔據CPU時間的比例。

 

Database Section中,包括了各個實例(for RAC)下,每一個實例的基本參數和複雜信息。如每一個實例活動會話個數、每秒的事務數量和內存使用狀況等。

 

DB Events Section是從Wait Event角度進行評估。評估排在頭幾位的等待事件信息,默認狀況下,這個度量是累計的,也就是從啓動數據庫到當前時間。咱們能夠切換到當前時間模式下。

 

Processes Section是記錄下處在BlockContention狀態的鏈接會話信息。當數據庫出現有會話被阻塞的狀況,就會記錄在這個Section裏面。

 

4、豐富的幫助系統

 

Oratop結果顯示中,大量使用的簡寫和縮寫,這在必定程度上阻礙咱們閱讀結果。爲此,Oratop開發人員設計了完備功能的幫助體系。

 

在使用-h參數,或者運行過程當中按下鍵盤h,就能夠切換到幫助界面。

 

使用h按鍵

 

 

oratop: Release 13.2.1

------------------------------------------------------------------------------

Dynamic Keys

        d : Toggle Top 5 Wait Events between Real-Time and Cumulative

        f : Toggle between short & long format (for header & Process sections)

        i : Interval Delay time (requires value in seconds)

 

Nomenclature:

        [M] : Signify 1 minute averaged value, else, Real Time

        [F] : denote a Forground (FG) value, else, Background (BG)

------------------------------------------------------------------------------

Acronym Help Menu:

 

HEADER Section    .. [1]

DATABASE Section  .. [2]

DB EVENTS Section .. [3]

PROCESSES Section .. [4]

Quit Help         .. (Q|q)

 

Enter selection Number:

 

 

動態按鍵(Dynamic Keys)實際上就是在運行過程當中,能夠動態實時點擊,查看不一樣維度結果的案件。

 

筆者比較喜歡d按鍵,這樣能夠從累計Event信息到實時Event信息,把握最新的數據庫等待時間狀態。

 

 

 

(d) –使用了d動態按鍵

oratop 1:  376 NBST 14:31:22 up  5.1d,  1 ins,   2G mt, 135 sn,  7 us,   4% db

ID %CU HLD MBPS IORL %FR PGAU ASC ASI ASW ASP   AAS USN  TPS UCPS SSRT DBC DBW

 1   2   0    0   0m  17 394M   1   0   0   0   0.0 135    4   71 297u  85  15

                                                                              

EVENT     (Real-Time)       AVG: TOT WAITS  TIME(s)  AVG_MS PCT  WAIT_CLASS  

DB CPU                                         1867         100              

                                                                              

ID   SID  SPID USR PROG  PGA OPN SQLID/BLOCKER  E/T STATUS STE WAIT_EVENT  W/T

 

 

另外一部分幫助就是顯示對四個section的解釋,解釋的很是詳細,值得讀者學習。篇幅緣由,這裏只顯示一份結果。

 

 

Section 1- HEADER (Global information)

   "oratop"  : program name

         : instance_id to which oratop is connected to

        : oratop's SID

     : DB_UNIQUE_NAME

    [M]: Time of most recent stats (hh24:mi:ss)

         : Database Uptime

         : Total number of instance(s)

         : Total DB memory cluster wide (SGA+PGA)

      [F]: User sessions (idle & active)

      [F]: Number of distinct users (idle & active)

   <%db>     : %database busy, 0% indicate idle db

 

 

5、複雜應用

 

Oratop的本質和優點在於輕量型和實時。一個很小的程序,能夠在自身消耗較小的狀況下發現問題。

 

Block and ContentioProcess Section部分重點問題。阻塞是數據庫內部資源徵用的一種結果,及時發現BlockingContention是很是重要的。

 

下面片斷是筆者模擬的一個兩個會話同時修改一行數據,以後一個會話被阻塞時,oratop監控到的狀況。

 

 

鎖定等待

                                                                            

ID   SID  SPID USR PROG  PGA OPN SQLID/BLOCKER  E/T STATUS STE WAIT_EVENT  W/T

 1   187 25971 SYS DEDI 908k DEL 1:193:25968    20s ACTIVE WAI enq: TX -   20s

 

 

在信息中,等待Session信息、SQL信息和等待事件信息都是咱們進行進一步調優的依據。

 

另外,咱們能夠在一臺Linux上安裝oratop,監控鏈接另外一臺遠程數據庫服務器,好比AIX系統。

 

首先,咱們須要創建本地鏈接名。

 

 

[oracle@localhost oratop]$ netca

 

Oracle Net Services Configuration:

Default local naming configuration complete.

    Created net service name: nbstest

Oracle Net Services configuration successful. The exit code is 0

[oracle@localhost oratop]$ tnsping nbstest

 

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 17-MAY-2013 14:06:38

 

Copyright (c) 1997, 2011, Oracle.  All rights reserved.

 

Used parameter files:

 

 

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.15.66)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = nbstest)))

OK (0 msec)

 

 

監控時候,就是用對應的用戶名密碼和鏈接名進行鏈接。

 

 

 

[oracle@localhost oratop]$ ./oratop -i 10 sys/sys@nbstest as sysdba

 

oratop: Release 13.2.1 Production on Fri May 17 14:07:39 2013

 

Copyright (c) 2011, Oracle.  All rights reserved.

 

 

6、形色參數

 

最後咱們介紹一下oratop可使用的參數。在示例中,咱們見到了-i參數。

 

-i參數表示監控間隔。後面通常跟着一個數字,表示每隔幾秒鐘進行一次數據收集。這個參數要進行選擇的,若是太大,不少關鍵數據不能收集查看。若是設置太少,oratop自身也會形成性能瓶頸。

 

-b批量運行模式。實時數據若是須要輸入到一個結果集合文件,供下一步處理使用,可使用b模式參數。當設置b參數以後,oratop會持續運行,或者在事先設計好的次數後結束。

 

-n設置最大迭代操做次數。

 

-d一改默認是累計事件的統計狀況,採用實時統計。

 

 

 

[oracle@localhost oratop]$ ./oratop -i 5 -b -d / as sysdba

 

oratop: Release 13.2.1 Production on Fri May 17 14:59:32 2013

 

Copyright (c) 2011, Oracle.  All rights reserved.

 

 

Processing ...

 

oratop: Release 13.2.1 Production on Fri May 17 14:59:32 2013

 

 

ID   SID  SPID USR PROG  PGA OPN SQLID/BLOCKER  E/T STATUS STE WAIT_EVENT  W/T

 

oratop: Release 13.2.1 Production on Fri May 17 15:00:17 2013

 

oratop 1:  202 isis 15:00:09 up  0.0h,  1 ins,   3G mt,  67 sn,  3 us,   3% db

ID %CU HLD MBPS IORL %FR PGAU ASC ASI ASW ASP   AAS USN  TPS UCPS SSRT DBC DBW

 1   0   0    0   0m  17 183M   1   0   0   0   0.0  67    0    6 286u  60  40

 

EVENT     (Real-Time)       AVG: TOT WAITS  TIME(s)  AVG_MS PCT  WAIT_CLASS  

DB CPU                                         1944         100              

(有省略…..

oratop: Release 13.2.1 Production on Fri May 17 15:00:27 2013

 

 

7、結論

 

Oratop是一個很是出色的輕量型監控工具,條件運行的話能夠嘗試一下。

 



oratop - Utility for Near Real-time Monitoring of Databases, RAC and Single Instance (文檔 ID 1500864.1)


文檔詳細信息

 
經過電子郵件發送此文檔的連接在新窗口中打開文檔可打印頁
   
  類型:
  狀態:
  上次主更新:
  上次更新:
  語言:
   
  SCRIPT
  PUBLISHED
  2017-4-19
  2017-4-19
  English日本語???


In this Document

  Purpose
  Requirements
  Configuring
  Instructions
   
  Quick Start Guide
  Script
  Sample Output
  References


APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.3 to 11.2.0.4 [Release 11.2]
Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.1.0.2 [Release 12.1]
IBM AIX on POWER Systems (64-bit)
HP-UX PA-RISC (64-bit)
HP-UX Itanium
Linux x86-64
Linux x86
Oracle Solaris on x86-64 (64-bit)
Oracle Solaris on SPARC (64-bit)

PURPOSE

oratop is a utility similar to the unix OS utility top which gives a overview of database performance and can be used in combination with top to get a more complete overview of system performance 

REQUIREMENTS

Supported Platforms

Linux x86

Linux x86-64

Solaris SPARC-64

Solaris x86-64

AIX (PPC)

HP-UX PARISC*

HP-UX IA

* 11gR2 only

NOTE: oratop on any platform can be used to monitor databases on other platforms.

To monitor databases on other platforms simply define an alias in tnsnames.ora of the Oracle client and connect to the databases remotely as you would with sqlplus

  


Supported Oracle Releases

11gR2 (11.2.0.3, 11.2.0.4)

12cR1 (12.1.0.1, 12.1.0.2)

 

CONFIGURING

oratop is now distributed and integrated with Trace File Analyzer Collector (TFA) along with all the other tools that are a part of the Support Tools Bundle.

So rather than downloading oratop separately the preferred method for obtaining oratop is to download the latest version of TFA.  This integration means 

that anytime TFA is upgraded (PSUs, download from MOS, etc) the latest version of oratop and the other Support Tools of the bundle will also be obtained.

If your Grid Infrastructure version is 11.2.0.4 or 12.1.0.2 then TFA will automatcially be installed.  In either case we recommend that the TFA installation be

upgraded to the latest version available from TFA Collector - Tool for Enhanced Diagnostic Gathering (Doc ID 1513912.1) in order to obtain the Support Tools 

Bundle which was first bundled with TFA version 12.1.2.3.0, as well as various other new features, bug fixes and optimizations.

Download the oratop executable for:

11gR2 on Linux x86-64 here.

11gR2 on SUSE10 Linux x86-64 here.

12c on Linux x86-64 for use with 12c clients here.

11gR2 on Linux x86-32 here.

12c on Linux x86-32 for use with 12c clients here.

11gR2 for Solaris SPARC here.

12c for Solaris SPARC here.

11gR2 for Solaris x86 here.

12c for Solaris x86 here.

11gR2 for AIX here.

12c for AIX here.

11gR2 for HP-UX PARISC here.

11gR2 for HP-UX IA here.

12c for HP-UX IA here.

 

Please download and review the oratop Users Guide for specific instructions on how to configure and run oratop.  A Quick Start Guide is provided in the Instructions section of this Note.

INSTRUCTIONS

 

Quick Start Guide

Note:   For detailed instructions on how to run oratop please download and review the latest oratop Users Guide.

Running oratop from within TFA Collector
 

Use the tfactl CLI to set the database context for oratop, ie., the target database that oratop should connect to, eg.,

$ $TFA_HOME/bin/tfactl db orcl       <== set the target database context in TFA for oratop to use

$ $TFA_HOME/bin/tfactl oratop        <== oratop will connect to the orcl database, no need to worry about any of the oratop pre-reqs, TFA takes care of all that

  

OR

Use the tfactl shell to set the database context for oratop, ie., the target database that oratop should connect to, eg.,

$ $TFA_HOME/bin/tfactl              <== invoke the tfactl shell prompt

tfactl> db orcl                     <== set the target database context in TFA for oratop to use 
Set db to orcl
orcl tfactl> oratop

To run oratop in "batch mode" for a spoecific number os snapshots

$ $TFA_HOME/bin/tfactl

tfactl> db orcl
Set db to orcl
orcl tfactl> oratop -bn10         <== this example would run 10 snapshots at the default 5 second interval unless the interval had been changed eg. oratop -i 10 -bn10

Once oratop is invoked and running within the TFA framework its operation is exactly the same as if run standalone with the exception that the database must be running on the node from which the "tfactl oratop" command is executed.  If the database is running remotely on one or more nodes of a RAC cluster, log in one of those nodes and run the "tfactl oratop" command on there after setting the database context.  In other words when oratop is run from within TFA there is no remote database access, a bequeath connection is used instead.  

Another thing to be aware of is that when oratop is run from within the TFA framework in batch mode as in the above example the ouput is automatically redirected to the oratop specific directory in the TFA repository location $TFA_REPOSITORY/supptools/oratop for automatic collection by TFA Collector.  In standalone mode you would need to use the redirection symbol ">" and specify the path and file name for re-direction and TFA would not necessarily know where to collect the resultant file unless it is redirected to one of the know diagnostic directories.


Running oratop standalone

  1. Log in to the system as the Oracle RDBMS software installation owner
  2. Stage the oratop executable on the server on which the tool will be executed.  On a RAC system it is only necessary to stage the executable on one node as it is RAC aware.
  3. Change the name of the executable, eg.
  4. $ mv oratop* oratop
     
  5. Validate the permissions for oratop are 755 (-rwxr-xr-x). If the permissions are not currently set to 755, set the permissions on oratop as follows: 
    $ chmod 755 oratop
  6. Configure the execution environment as follows (if not already set accordingly)
  7. $ export TERM=xterm  #or vt100
    $ export ORACLE_HOME=<11.2 database home>
    $ export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    $ export PATH=$ORACLE_HOME/bin:$PATH
    $ export ORACLE_SID=  #only needed if connecting to a local database
  8. Invoke the tool to monitor a local database as follows (interval can be any interval in seconds):
    $ ./oratop -i 10 / as sysdba
  9. Non-dba privileged user requires specific grants to use the tool.  See User Guide for grants required.
  10. Databases can be monitored remotely using a tns alias as described in the oratop Users Guide.
  11. $ ./oratop -i 10 username/password@tns_alias
    $ ./oratop -i 10 system/manager@tns_alias
     
  12. To exit the program simply press the keyboard key "q".  To abort, CTRL-C.
 
 
 
Troubleshooting:
 
If you receive an error similar to 
 
./oratop: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
 
that is an indication that libclntsh.so.11.1 was not found in the path defined in LD_LIBRARY_PATH similar to 
 
$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib  (ie., the location of libclntsh.so.11.1)

CAUTION

This sample code is provided for educational purposes only, and is not supported by Oracle Support. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

SCRIPT

The tool is a compiled c program.

SAMPLE OUTPUT


Sample Workload

Sample workload

REFERENCES

NOTE:1594347.1  - RAC and DB Support Tools Bundle





oratop User Guide


Abstract

oratop can be used to monitor Oracle databases (release 11.2 onwards) on any platform but the executable must run on Linux with an Oracle compatible client.  To monitor databases on other platforms simply define an alias in tnsnames.ora of the Linux client and connect to the databases remotely as you would with sqlplus.

INTRODUCTION

The Oracle program named oratop allows users with select privilege to a set of Oracle’s views to monitor 11.2 or higher version of oracle database activities.  It runs dynamically in near real time and provides a live window to a running database.  It is Single instance/ RAC/ ASM aware utility. (see sample snapshot shown in Figure 1 below) Key motivations include:

?         Monitoring current database activities,

?         Database performance,

?         Identifying contentions and bottleneck

clip_image002

Figure 1. oratop text-based user interface (default mode) 

 

ENHANCEMENTS

? SQL Monitoring

? Database Service

? Multitenant Database  (12c oracle  CDB/PDB)

? Active Data Guard

SECTIONS  

The 「oratop」 displays relevant database activity information presented in four sections.

? Section 1 - HEADER: Global database information

? Section 2 - DATABASS: Database instance Activity

? Section 3 - DB EVENTS: AWR like 「Top 5 Timed Events「

? Section 4 – PROCESS/SQL: Processes/SQL information

Specific detail of the various sections data can be obtained using the interactive help (see

Runtime usage Sections Detail below)

CLIENT

Connection method is largely similar to sqlplus.  If it works for sqlplus, then it should work the same for oratop.

Shell environment settings

$ export ORACLE_HOME=

$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib

$ export PATH=$ORACLE_HOME/bin:$PATH

Bequeath[1]

$ export ORACLE_SID=

Remote server[2]

Options:

?        TNS:  

$ export TNS_ADMIN

-   connect with a TNS alias name as defined intnsnames.ora, or

-   set TWO_TASKto the tns alias and connect without alias name

?        EZConnect

I.  COMMAND LINE MODE

Command line synopsis can be obtained by invoking the utility with 「-h」 option as shown in Figure 2.

clip_image004

Figure 2. Command line help

Logon

Invocation:

$ oratop [Options] [Logon] Example,

Using Easy Connect (EZConnect) ?    Non-default port oratop system/manager@dbhost:4800/db1.domain.com ?    Default port (1521):

oratop system/manager@dbhost/db1.domain.com

Options

d :  Real-Time Top 5 Wait Events, section 3.

Specifies Wait Events display mode.

Default:  Cumulative

To override the default value

? Command line:  -d ? Runtime:  d

k : 「FILE#:BLOCK#」 for objects being waited on, process section 4.

Specifies 「FILE#:BLOCK#」 display mode.

Default:  EVENT/LATCH

To override the default value

? Command line:  -k ? Runtime:  k

m : 「MODULE/ACTION」, process section 4. Specifies 「MODULE/ACTION」 display mode.

Default:  USERNAME/PROGRAM

To override the default value

? Command line:  -m ? Runtime:  m

s :  SQL mode of section 4. Specifies SQL display.

Default: Process mode

To override the default value

? Command line:  -s ? Runtime:  s

c :  Database Service centric mode.

Displays information based on the database service specified in the connect string.

Default: Connection mode

To override the default value ? Command line:  -c ? Runtime:  N/A

f :   Long format, (132 columns) 

Specifies long format for header & process section.

Default: short (80 columns)

To override the default value

? Command line:  -f ? Runtime:  f

p :  Process mode of section 4. process display. Default: Process mode

To override the default value

? Command line:  -p

? Runtime:  p

b :  Batch mode operation.

Runs in sequential frames.  It is useful for sending output to a file. In this mode, oratop will run continuously interrupted only by the user (CTRL-C) or until the iterations limit is reached if it is set with the '-n' command-line option. Default: Text-based user interface

To override the default value ? Command line:  -b ? Runtime:  N/A

n :  Maximum Number of iterations.   (requires a number)

Specifies the maximum number of iterations, or frames, oratop should produce before ending.

Default: infinite

To override the default value ? Command line:  -n ? Runtime:  N/A

t:  Displays tablespace information.

Default: N/A

? Command line:  N/A ? Runtime:  t

a:  Displays  ASM diskgroup information.  (no op for non-ASM)

Default: N/A

? Command line:  N/A ? Runtime:  a

x:  Displays SQL execution plan table.  Requires input of the active SQL sql_id value.

Default: N/A

? Command line:  N/A ? Runtime:  x

i :   Interval delay time. ( requires value in seconds)

Specifies the delay between update refresh.  A short interval delay (<10s) is not guaranteed  for the specified delay.  This is particularly true for a loaded system. 

Default: 5 seconds.

To override the default value

? Command line:  -i < number in seconds> ? Runtime:  i

v :  oratop version number.

Displays version number

Default: N/A

? Command line:  -v ? Runtime:  N/A

h :  Help.

Displays usage or output information.

Default: N/A

? Command line:  -h[elp]

? Runtime:  h

II.  INTERACTIVE MODE

Runtime interactive and detail options can be seen after starting the utility followed by pressing the keyboard key ‘h’.  (See Figure 3)

clip_image006
Figure 3. Runtime Options using help

1.  Interactive Toggle keys

      1.1.       [ d ]  - Section 3 「DB EVENTS」 Cumulative( C)/ Real-Time (R/T) modes

See header starting with 「EVENT (c)」 in Figure 4 below.

clip_image008

Figure 4. Runtime toggle Option ‘d’ (Cumulative/ Real-Time)       1.2.       [ k ]  - Section 4 Process 「EVENT/*LATCH 「 and 「FILE#:BLK#」 columns
Figure 5 below shows column toggling in section 4 when keyboard key 「k」 is pressed.

clip_image010
Figure 5. Runtime switch Option ‘k’ (process,EVENT/[3]LATCH 「 & 「FILE#:BLK#)  

Usefulness

The 「FILE#:BLOCK#」 values are significant when there is a long wait on an object.  It is possible to identify the reason for a bottleneck (e.g. concurrency, user_io, etc.) by correlating with the wait class and the wait event in the detailed (long) format.


      1.3.        [ m   - Section 4 Process Module and Action columns

 

Figure 6 below shows section 4 column changes.

Detailed format

?         USERNAME」, 」PROGRAMand「MODULE」, 」ACTION」column toggle

.

Default standard format

?         「USR」, 」PROG」 and 「MOD」, 」ACTN」. (default short  format)

clip_image012

Figure 6. Runtime switch Option ‘m’ (process,USR」, 「PROGandMOD」, ACT)  

      1.4.        Section 4 modes

? [ p ] - Process mode (default) ? [ S ]  - SQL mode

 

key press ‘p’ for process, ‘s’ for SQL switch (Section 4)

clip_image014

Figure 7. Runtime switch Options ‘p’ (process) and ‘s’ (SQL)

Notes.

1.     The SQL appearing in the SQL mode are for those with executions > 0.

2.     Buffer gets to disk reads Hit ratio (BH%) is calculated from:

100*(buffer_gets/(buffer_gets_disk_reads))

      1.5.         f   - Short (standard)/ long (detailed) format
 
  clip_image016


Changes back and forth, the format between the default standard short format and the detailed long format.

Figure 8. Runtime toggle Option ‘f’ (format)


      1.6.         t   - Tablespace information Context

clip_image018

Figure 9. Runtime Tablespace information Option ‘t’

Where,

clip_image019

        Column                                                 Description[4]

TABLESPACE_NAME

Name of the tablespace

SIZE

Tablespace total size (maxbytes)

USED

Tablespace used size

USE%

Tablespace used percentage (red if > 90%)

STATUS

Tablespace status: ONLINE, OFFLINE, READ ONLY (red if OFFLINE)

BIGFILE

Bigfile tablespace (YES) or a smallfile tablespace (NO)

NDBF

Number of smallfile db datafiles for the tablespace

LOGGING

Default logging attribute: LOGGING, NOLOGGING

       CONTENTS                                           Tablespace contents: UNDO, PERMANENT, TEMPORARY

       EXTENT_MANAGEMENT                    Extents  are (DICTIONARY) managed or locally managed (LOCAL)

       SEGMENT_SPACE_MANAGEMENT    Tablespace is managed using free lists (MANUAL) or bitmaps (AUTO)

RETENTIONUndo tablespace retention: GUARANTEE, NOGUARANTEE, NOT APPLY ENCRYPTED         Tablespace is encrypted (YES) or not (NO)

clip_image020

    Table 1. Tablespace information header description (shaded for the default format)       1.7.         a   - ASM disk group information Context

clip_image022

Figure 10. Runtime ASM diskgroup information Option ‘a’

Where,

clip_image023

        Column                                                 Description[5]

INST_ID

Instance identification number

DISKGROUP_NAME

Name of the disk group (DG)

SIZE

Total capacity of the disk group

FREE

Unused capacity of the disk group

%USED

Disk group  used percentage (red if > 90%)

HOTU

Number of used bytes in the hot region

COLD

Number of used bytes in the cold region 

STATE

State of the disk group relative to the instance. (red if not  CONNECTED )

TYPE

Redundancy type for the disk group: EXTERN , NORMAL , HIGH

OFFLINE_DISKS

Number of disks in the disk group that are currently offline (red > 0)

ALLOCATION_UNIT_SIZE

Size of the allocation unit  (ALLOCATION_UNIT_SIZE )

VOTING_FILES    Indicates whether the disk contains voting files (Y) or not (N)  (red if ‘Y’) ASM_COMP     Minimum S/W version required for ASM instance to mount this DG DB_COMP        Minimum S/W version required for a DB instance to use files in this DG

clip_image024

    Table 2. ASM disk group information header description (shaded for the default format)       1.8.         x   - SQL Execution Plan table context

Basic SQL execution plan table option for active SQL with SQL_ID.

Pressing the keyboard key ‘x’ will prompt the user to input the SQL_ID value. (see

Figure 11)

clip_image026

Figure 11. Runtime SQL Plan table Option ‘x’ (SQL mode)


      1.9.        [ i   - Delay interval input option

Pressing the keyboard key 「i」 at run time prompts the user to input the desired interval  in seconds. (see Figure 12)

clip_image028

Figure 12. Runtime refresh interval Option ‘i

2.  Data Description

The run time help menu is driven by the preselected option(s).

The following sections will show help for section 4 of the SQL mode only.  Help for all the other sections follow in the the same manner.

2.1. Help SQL mode (Default, short format)

keyboard key 「s」 was pressed to select SQL mode for section 4 prior to pressing the help menu key 「h」.

Figure 13 below shows description of section 4 columns while in SQL mode and default format.

clip_image030

Figure 13. Runtime Data Description (Section 4 SQL mode short format)

2.2.  Help SQL mode (Detailed, long format)

Here, the keyboard keys 「s」 and 「f」 were pressed to select SQL mode for section 4 in the detailed format  prior to pressing the help menu key 「h」.

Figure 14 below shows detail of section 4 in SQL mode and detailed format.

 

clip_image032

Figure 14. Runtime Data Description (Section 4 SQL mode detailed format)

SNIPPETS

1.  [ Auto Toggle ] – Section 4 EVENT/LATCH column

EVENT/*LATCHcolumn auto toggle across refreshes.  The auto toggle is activated whenever there is a wait on a latch and potential process hang or spin is detected.  It provide a useful information if such hang or spin last for a long duration.

clip_image034

Figure 15. Auto toggle between Event and latch name (process mode)

2.  Data Guard

Significant data guard indicators are highlighted in yellow as shown Figure 16 below.   In particular, the value for the apply rate (ar) is highly desired.

clip_image036

Figure 16. Snapshot from monitoring a standby database

3.  Database Service

Figure 17 below shows an example of oratop started with the 「-c」 option connecting via the user defined service named 「sro」.  Service centric values are highlighted in light brown. Values not highlighted are database/ instance overall values.

Note. when in service mode, the database name in the header section will be replaced by the service name and highlighted in red.

 

clip_image038

Figure 17. Snapshot from monitoring database via Service

4.  12c Multitenant Database

4.1. Connection to CDB[6] root 

Relevant indicators to the Multitenant database are highlighted in yellow.  At CDB root, the header (section 1) will show the number of tenants housed in this Multitenant database.  For example, Figure 18 shows 3 pdbs (not including seed database).  

The 「CID」 column in the SQL mode stands for Container_ID.

clip_image040

Figure 18. Snapshot from a Multitenant Database connecting to root

4.2. Connection to a PDB[7](pluggable database)

Indicators to a tenant database are highlighted in a yellow for the next two subjects. 

4.2.3.  Connection without the 「-c」 command line option

Figure 19 shows a non-service based connection  (not using  「-c」 flag) to a tenant having database name 「pdb1」 with container id (cid) 3 (which is the 1st pdb).  Columns with values being dimmed are not pdb specific, they are generic root level (CDB) unless they are enabled in the database.

clip_image042

Figure 19. Snapshot from a tenant Database (no 「-c」)

4.2.4.  Connection with the 「-c」 command line option

Figure 20 shows shows relevant stats when connecting via service and using the「-c」 flag to the same tenant 「pdb1」. 

Highlighted values in red color shows significant differences with the previously shown Figure 19.

clip_image044

Figure 20. Snapshot from a tenant Database (service with 「-c」)

5.  Batch Mode

Figure 21 below shows a snapshot from a batch run with output redirected to standard system file.

clip_image046

Figure 21. Single iteration batch/SQL mode

Note.

In RAC environment, while section 2 of oratop (Database section) is restricted to the top 5 instances in the text-based user interface, all of the available instances will be listed in the batch mode. 

Miscellaneous

? RED

Values flagged and highlighted in red color are merely a warning or to emphasize importance.

        ?     Exiting

To quit the program, user may press any of the following keyboard keys:

?     Character "q" or "Q", or Esc key

?     Ctrl+c  (to abort)

In all cases, proper OCI session cleanup and logout is performed.

        ?    Unprivileged user

To allow the non-privileged user to use oratop, the system administrator with DBA privileges may issue the following grants:

grant select on to ;

v$active_services v$instance v$latchname v$parameter V$PDBS (12c) v$recovery_file_dest v$sqlcommand v$system_event

[g]v$servicemetric

[g]v$session

[g]v$sql

[g]v$sysmetric

GV$ASM_DISKGROUP

GV$DIAG_INFO

GV$PGASTAT

GV$PROCESS

GV$OSSTAT

GV$RECOVERY_PROGRESS

GV$SESSION_WAIT_CLASS

GV$SESSTAT

GV$SERVICE_EVENT

GV$SERVICE_STATS

GV$SGA

GV$SORT_SEGMENT

GV$SQLAREA

GV$SQL_PLAN

GV$SYSTEM_EVENT

GV$SYSSTAT dba_data_files dba_free_space dba_tablespaces dba_temp_files dba_undo_extents sys.ts$

Table 3. internal views to be granted to the unprivileged user Note.  Typical error for a non-granted user may receive upon connection is,

ERROR CODE = 942

ORA-00942: table or view does not exist

TECHNICAL DETAILS

The 「oratop」 program is written in C program, using OCI API.  It is not intrusive to a database server, and it leaves small footprints on the server, namely the sqls used by the program.  It employs Unix 「termio, 「ioctl」 libraries, and VT100 escape characters to achieve cursor control, font colors, program exit control and terminal (xterm) resizing capability.  

Overhead

On the client side, the oratop program is a very light process that uses minimal CPU and Memory.  For the server process, its resources are server dependent.

Remark.

oratop’s specific queries are intentionally filtered out from the SQL section to reduce noise.  Information regarding these queries can be found on the server using AWR.

The intention of using this utility is to get a quick glance at the database.  The oratop SQL statements will show up in the top SQL section of AWR due to the high execution rate when running for a long duration and a short interval. Like any other SQL, oratop SQL performance will be impacted on over loaded systems.  

Limitations

        ?      The program is not portable; it runs on Linux platforms only

?         The program is compatible with oracle client version11.2 and 12cR1

?         Requires server to have been started with the following parameter statistics_level=TYPICAL[8]

Caveats

The program may exhibit anomalies at run time, most of which are expected since an event may occur while the program is in the middle of executing/ fetching operations. 

Blank Screen

On a busy server, the following operations may leave the terminal blank for a short period:

?       A program initialization

?       A terminal resizing (shrink/expand the terminal)

?       An instance joining/leaving the cluster

?       Quitting interactive keys menus

?       Upon exiting the program

Sluggish response to keyboard key press

Pressing a keyboard key to interact with the program may appear to have slow response on a busy server.  Key press response time depends on the interval/execution state.

Abnormal termination

Like any SQL session, the program may fail due to a server error, and the particular error will be displayed.

Abnormal exit

In some situation (corner cases) the program may leave the terminal (xterm) SHELL environment in an undesirable setting.  To restore the terminal to its original settings, he user may issue the Linux command 「reset」.

CONCLUSION

The oratop utility provides dba user a quick overview of a running database status and activity.  It aggregates useful diagnostics such as overall database performance degradation, bottleneck, identifies potential blocker(s), and helps to detect memory leak from processes.  The utility also reports badly performing SQL operations as well.

Furthermore, it helps in tuning some aspects of the database like user concurrency.

Modifications:

Version 14.1.2 – May 2014, bug fix for batch mode. (SR 3-89597485410)

Version 14.1.1 – Apr 2014, Fix few minor bugs,

Version 14.1.0 – Mar 2014, New release with enhancement for sql, data guard, Multitenant database, Version 13.3.4 – Aug 2013, display oratop version/uptime as xterm title, also added a new key press ‘g」 toggle, Version 13.2.4 – Jul 2013, Top waits change for cpu stats by stats name and waits by sum. Version 13.2.3 – Jun 2013, All instances in section 2 will be listed implicitly in batch mode.

Version 13.2.2 – Jun 2013, Introduced new switches, IOPS/IORL, MOD,ACTN/USR,PROG.

Version 13.2.0 – May 2013, Long format and Top 5 dynamic wait events.

Version 13.1.0 – Mar 2013, sqlplus connection like and the doc were updated from June 2011.

Version 12.1.0 – Dec 2012, added help key 「h」. Versions 1-12  – Mar 2010, created.



[1] Connecting 「 / as sysdba「 is allowed only for bequeath connections.

[2] The remote database requires setting the 「REMOTE_LOGIN_PASSWORDFILE」 paired with the availability of an Oracle password file

[3] The asterisk  (*) prefixing the latch name is used to distinguish it from the wait event name.

[4] Oracle? Database Reference, 11g Release 2 (11.2) E40402-10 [dba: _tablespaces, _data_files, _free_space,  _undo_extents]

[5] Oracle? Database Reference, 11g Release 2 (11.2) E40402-10  [GV$ASM_DISKGROUP]

[6]  Also referred to as Consolidated database.

[7]Also referred to as Tenant or a container

[8] Statistics_level cannot be set to 「BASIC」 since it will disable  the required timed_statistics




About Me

...............................................................................................................................

● 本文整理自網絡

● 本文在itpub(http://blog.itpub.net/26736162)、博客園(http://www.cnblogs.com/lhrbest)和我的微信公衆號(xiaomaimiaolhr)上有同步更新

● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/

● 本文博客園地址:http://www.cnblogs.com/lhrbest

● 本文pdf版及小麥苗雲盤地址:http://blog.itpub.net/26736162/viewspace-1624453/

● 數據庫筆試面試題庫及解答:http://blog.itpub.net/26736162/viewspace-2134706/

● QQ羣:230161599     微信羣:私聊

● 聯繫我請加QQ好友(646634621),註明添加原因

● 於 2017-07-01 09:00 ~ 2017-07-31 22:00 在魔都完成

● 文章內容來源於小麥苗的學習筆記,部分整理自網絡,如有侵權或不當之處還請諒解

● 版權全部,歡迎分享本文,轉載請保留出處

...............................................................................................................................

拿起手機使用微信客戶端掃描下邊的左邊圖片來關注小麥苗的微信公衆號:xiaomaimiaolhr,掃描右邊的二維碼加入小麥苗的QQ羣,學習最實用的數據庫技術。


DBA筆試面試講解
歡迎與我聯繫
相關文章
相關標籤/搜索