oratop工具--实时数据库性能监控工具

0    477    1

Tags:

👉 本文共约20423个字,系统预计阅读时间或需77分钟。

简介

oratop是Oracle提供的一款轻量级实时监控工具,oratop的最大特点是支持实时轻量级监控。在Oracle 12c的EM Express之前,OEM还是一个重体积的组件。相比之下,oratop完全适合那些想使用数据库实时监控功能,但是又不愿意启动OEM的用户需要。从功能上看,oratop主要的特点有:监控当前的数据库活动;监控数据库性能;识别当前阻塞会话和瓶颈会话。oratop是一个典型的“绿色”软件,不需要安装,只需要给一个运行目录即可。需要注意的是,oratop需要以oracle用户运行,且需要配置环境变量,主要是配置LD_LIBRARY_PATH路径。oratop的运行命令如下所示:

参数-i表示数据刷新间隔,也就是多长实际更新一下页面数据信息。“/ as sysdba”表示登录本机连接,也可以远程使用oratop连接到其它服务器上去。运行命令后,等待一会就会出现字符界面显示:

从字符界面上看,oratop结果集合分为四个部分,分别为:Header Section、Database Section、DB Events Section和Processes Section。

① 在Header Section中,包括了连接数据库的总体信息,包括运行多长时间、实例个数(RAC)、内存大小和数据库占据CPU时间的比例。

② 在Database Section中,包括了各个实例(RAC)下,每个实例的基本参数和复杂信息。如每个实例活动会话个数、每秒的事务数量和内存使用情况等。

③ 在DB Events Section是从Wait Event角度进行评估。评估排在头几位的等待事件信息,默认情况下,这个度量是累计的,也就是从启动数据库到当前时间,可以切换到当前时间模式下。

④ 在Processes Section是记录下处在Block和Contention状态的连接会话信息。当数据库出现有会话被阻塞的情况,就会记录在这个Section里面。

MOS文档“oratop - Utility for Near Real-time Monitoring of Databases, RAC and Single Instance (文档 ID 1500864.1)”对oratop有详细的说明。

在任何系统优化过程中,“80/20原则”是我们一定要关注的问题。简单的说,就是我们系统80%的性能问题、现象,都是有少数几个甚至一个问题造成的。这就需要我们面对复杂的系统性能问题的时候,要学会“拨开云雾、蛇打七寸”。

落实在Oracle优化过程,同样如此。从10g开始,我们开始频繁接受“Top-xxx”的概念,无论是从OEM(Oracle Enterprise Manager)还是借助AWR事后报告库,解决主要矛盾,发掘主要Top Events就成了我们日常工作不可缺少的部分。

实际工作中,对Top的发掘和Oracle动态信息的收集,很多时候还是有点力不从心和滞后之感强烈。Oracle官方的客户服务网站MOS,经常有一些有用的小工具,提供给我们使用。本篇中,我们主要来介绍下Oratop工具的特点和使用。

Oratop源自MOS的一篇文章和工具链接(oratop - utility for near real-time monitoring of databases, RAC and Single Instance [ID 1500864.1])。从名称上看,Oratop最大特点是支持实时轻量级监控。在Oracle 12c的EM Express之前,OEM还是一个重体积的组件。相比之下,oratop完全适合那些想使用数据库实时监控功能,但是又不愿意启动OEM的用户需要。

从功能上看,Oratop主要有三大特点:

ü 监控当前的数据库活动;

ü 监控数据库性能;

ü 识别当前阻塞会话和瓶颈会话;

目前,Oratop是在MOS上免费下载,分别有32位和64位两个版本。

安装

从网站上下载软件之后,是一个命名为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

解释

从字符界面上看,oratop结果集合分为四个部分,分别为:Header Section、Database Section、DB Events Section和Processes Section。

Header Section中,包括了连接数据库的总体信息,包括运行多长时间、实例个数(for RAC)、内存大小和数据库占据CPU时间的比例。

Database Section中,包括了各个实例(for RAC)下,每个实例的基本参数和复杂信息。如每个实例活动会话个数、每秒的事务数量和内存使用情况等。

DB Events Section是从Wait Event角度进行评估。评估排在头几位的等待事件信息,默认情况下,这个度量是累计的,也就是从启动数据库到当前时间。我们可以切换到当前时间模式下。

Processes Section是记录下处在Block和Contention状态的连接会话信息。当数据库出现有会话被阻塞的情况,就会记录在这个Section里面。

丰富的帮助系统

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

复杂应用

Oratop的本质和优势在于轻量型和实时。一个很小的程序,可以在自身消耗较小的情况下发现问题。

Block and Contentio是Process Section部分重点问题。阻塞是数据库内部资源征用的一种结果,及时发现Blocking和Contention是非常重要的。

下面片段是笔者模拟的一个两个会话同时修改一行数据,之后一个会话被阻塞时,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.

参数

最后我们介绍一下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)

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.

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 Guideimg.

  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.

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

](http://images2017.cnblogs.com/blog/646850/201707/646850-20170726171256015-1441263247.gif)**Figure 1**. oratop text-based user interface (default mode)

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
验证码:
获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复