标题: Monitor Oracle Resource Consumption in UNIX
ljjk5
元帅
Rank: 1


荣誉会员奖章
UID 46706
精华 1
积分 99426
帖子 49691
威望 554
金币 48489
热心 505
阅读权限 100
注册 2007-2-25
状态 离线
Monitor Oracle Resource Consumption in UNIX

=======This article is intended to provide DBAs an overview of the resourcesconsumed by Oracle, and the tools commonly used to monitor the resourceconsumption.SCOPE & APPLICATION===================Database performance is bounded by the system resources. Sometimes,poor database performance can be caused by faulty configuration of theinstance and database. Sometimes, it can be caused by abnormal resourceconsumption by an Oracle transaction, user, or process. It is essentialfor DBAs to proactively monitor the resource consumption, and take anycorrective actions before potential serious impacts.Memory, CPU, and I/O are the three most common resources consumed byOracle. We will discuss these resources, and list some of the commonlyused tools that monitor them. These resources can be monitored at bothOracle Server and Operating System levels. DBAs should acquire any detailedinformation about the OS tools from the System Administrators or OS vendors.OVERVIEW========Oracle Instance---------------An Oracle Instance is a set of System Global Area and background processes.It is started during �startup nomount�. The characteristics of an instanceare: - Its name is defined by environmental variable ORACLE_SID.  - It is started based on the configurations defined in init.ora file.  - It has its own set of SGA and background processes.  - It can only belong to one database at one time.  - Multiple instances can access the same database in OPS configuration.There can be multiple oracle instances from the same $ORACLE_HOME. Theyare only limited by the OS resources, such as disk, memory, kernel parameters,etc. Each time an instance is started, the OS is being asked to give somekey resources according to the parameters specified in init.orafor that instance. Each Oracle instance has two main areas of memory structures,System Global Area (SGA) and Program Global Area (PGA) for background processes.SYSTEM RESOURCES================Memory------There are several memory structures used by Oracle, SGA, PGA, UGA, andsort area.1) Shared Memory & SemaphoresOracle uses shared memory for efficiency. The OS does not haveto load up the same address page(s) into the memory each time a processneeds to reference it. Instead the process can just reference the one memorylocation, read/write to it, and then leave. Therefore, the data is notmoved from one processs memory address space to another. In order to controlmemory integrity so that only one process is accessing that memory address,semaphores are used.Semaphores have only two values, set or unset. When a process goes toreference a memory location, it first checks to see if the semaphore allocatedfor that memory location is set. If so, it waits until that semaphore locationis free. Once available, it will first set the semaphore so to not allowother processes to interrupt or corrupt the current processes read/write.The size of the SGA is made up by shared pool, database buffer cache,redo log buffer, large pool, and java pool. A commonly used formula tocalculate the size of the SGA is:((db_block_buffers * block size) + (shared_pool_size +large_pool_size + java_pool_size + log_buffers) + 1MBSee more detailed information in How to determineSGA Size (7.x, 8.0, 8i, 9i).For optimal database performance, SGA should fit into real memory, andavoid swapping. The size of the SGA is also bounded by OS kernel parameters,such as SHMMAX in Unix. To learn more about shared memory, see Sharedmemory requirement on Unix.Since the SGA can be accessed by all processes that have been allocated,this is used to allow multiprocessing and access between processes withinthe SGA.A few of the common semaphores and shared memory segments that Oracleuses are: - SEMMNI => Max number of semaphores sets/identifiers  - SEMMNS => Max number of semaphores in system  - SHMMNI => Number of shared segments identifiers to be pre-allocated  - SHMMAX => Max shared segment size For more information, see Unix Semaphores and SharedMemory Explained.Also see the corresponding Oracle Installation Guide for your release of Oracle,that indicate minimum values for semaphore and shared memory. 2) Private MemoryPGA is a memory region containing data and control informationfor a single server or background process. The size of PGA depends on thedatabase configuration, and what the process does. In a dedicated serverconfiguration, where one server process interacts with one user process,PGA contains stack space and UGA. UGA is made up by user session data,cursor state, and sort area.  In a multithreaded server configuration,where one shared server is shared by multiple user processes, UGA is partof the shared pool.The PGA exists as:- Nonshared memory area to which a process can write - One PGA is allocated for each server or background process - Once the user has connected, a user can never run out of PGA space.Otherwise the connection will not happen and may result in an ora-4030 error.Oracle parameters that affect the sizes of PGA are: - open_links  - db_files  - sort_area_retained_size  - sort_area_sizeTo calculate the current PGA size: SESSION PGA MEMORY => Statistic containing the current PGA size for a session SESSION PGA MEMORY MAX => Statistic containing the peak PGA size for a sessionPGA = dedicated server processes - UGA = Client machine processTo view a listing of the UGA and PGA memory for every session, see TFTSISTING MEMORY USED BY ALL SESSIONSNote: On the RS/6000, each shadow process stores its PGA in a shared memory segment.The size of the stack space in each PGA created on behalf of Oraclebackground processes (such as DBWR and LGWR), is affected by some additionalparameters.CPU---CPU consumption varies with the activities of the processes. Duringthe peak workload, the DBAs and the SAs may see CPU utilization go up to90%. In general the DBAs should balance the workload to avoid overloadingthe system.I/O---The amount of I/O occurrence also depends on the activities of the processes. While memory I/O may be necessary, disk I/O should be minimized. To avoiddisk I/O contention, files should be distributed across devices. Some ofthe background processes can be I/O intensive, such as DBWn, LGWn, ARCn,and CKPT. In some situations, DBAs may find multiple DBWn/ARCn, or DBWR/ARC0/LWGRI/O slaves beneficial.MONITORING AT THE SERVER LEVEL==============================V$ dynamic performance views capture the cumulative statistics of resourceconsumptions, at both system or session levels. STATSPACK  and Utlbstat/utlestatreports summarize the statistics from these v$ views for a defined periodof time for the database and tkprof utility reports statistics at querylevel. Init.ora parameter TIMED_STATISTICS should set to be true.The descriptions of v$ views are in Oracle 7/8/8i/9i Server Reference manual.To learn more about analyzing STATSPACK  or utlbstat/utlestat reports,see  StatsPack FAQ  and SystemwideTuning using UTLESTAT Reports in Oracle7/8To learn more about interpreting tkprof output, see Note :TkprofInterpretation.Examples--------The following examples shows the output from all different tools availablein Oracle to get this information:- STATSPACK and bstat/estat reportsStatistic                    Total         Per Transact           Per Logon         Per Second ---------------------------- ------------- ---------------------- ----------------- ------------------ CPU used by this session     2278466       222.59                 1974.41           203.6 CPU used when call started   2239857       218.82                 1940.95           200.15 CR blocks created            2938          .29                    2.55              .26 session pga memory           7138227       34521                  991               191 session pga memory max       40327524      745091                 98305             756 session uga memory           326143        96312                  57843             654 session uga memory max       2483564       185735                 12386             700 - tkprof .prf output fileOVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call             count        cpu      elapsed       disk       query      current        rows ------------ ---------  --------- ------------ ---------- ----------- ------------  ---------- Parse                3       0.04         0.05          0           0            0           0 Execute              4       0.00         0.05          0           0            0           0 Fetch                2       0.00         0.06          2          17           68           1 ------------ ---------  --------- ------------ ---------- ----------- ------------  ---------- total                9       0.04         0.16          2          17           68           1 - Scripts outputREM Monitor memory usage SQL> select sid, name, value       2  from v$statname n, v$sesstat s       3  where n.statistic# = s.statistic#       4  and n.name like %memory%       5  order by sid;      SID NAME                              VALUE --------- --------------------------------- ----------         1  session uga memory               18252         1  session uga memory max           18252         1  session pga memory max           59568         1  sorts (memory)                   0         1  session pga memory               59568       . . REM monitor CPU usage SQL> select sid, name, value        2  from v$statname n, v$sesstat s        3  where n.statistic# = s.statistic#        4  and n.name like %cpu%        5  order by sid;      SID NAME                           VALUE --------- ------------------------------ ----------          1 recursive cpu usage           0          1 parse time cpu                0          1 OS Wait-cpu (latency) time    0        . . REM  monitor I/O SQL> select file#, phyrds, phywrts       2  from v$filestat;         FILE#         PHYRDS          PHYWRTS ------------ -------------- ----------------            1           3239              141            2             80              246            3              9              163            4              6                3            5              5                3            . . MONITORING AT THE OPERATING SYSTEM LEVEL=========================================OS Semaphores-------------Each Oracle instance needs to have a set amount of semaphores. The totalamount of semaphores required is derived from the processes parameterinside that Oracle instance init.ora file. As more instances and/or databasesare added the OS kernel parameter SEMMNS will need to be adjusted accordingly.For more information, see SemaphoreCalculations- Estimating semaphore sets/semaphores for an Instance.Ulimits--------Refer to the install guide for the basic kernel parameters that need

to be set. When increasing the amount of instances & databases on this

Unix server, one will need to increase the kernel parameters accordingly.

To check the Unix oracle user id limits:

% ulimit -Sa

(This is the output you may expect to see)

time(seconds)          unlimited

file(blocks)           unlimited

data(kbytes)           unlimited

stack(kbytes)          unlimited

memory(kbytes)         unlimited

coredump(blocks)       2097151

nofiles(descriptors)   unlimited

Monitoring Tools

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

Commonly used tools are vmstat, iostat, pstat, size, ipcs, ps, sar, and other OS

specific tools.  View the manual page to obtain the usage and column

descriptions.

Here are a few specific Unix supplied tools to help monitor different OS activities:

1) Memory: To see how much memory is currently being used, vmstat (virtual memory

statistics) focuses mainly on CPU and memory.

    OS                 Command

    ~~~~~~~~~~         ~~~~~~~~~

    Sun Solaris:       vmstat

    HP:                vmstat -n

    IBM:               /bin/vmstat

    Compaq:            /sbin/hwmgr

    Linux:             xosview

  For specific examples of diagnosing memory on various platforms:

   HPUX --> see

Diagnosing Oracle memory on HP using GLANCE

   AIX --> see

Diagnosing Oracle Memory on AIX using SVMON

  SUN -->see Diagnosing

Oracle memory on Sun Solaris using PMAP

2) I/O: You should regulary monitor disk I?O statistics by using utilities such as

"sar -d" or "iostat". Average service times of 50ms or lessare reason for

concern if it continues over a long time. One of the goals should be minimizing disk I/O by balancing the load on the disks.

To watch over disk space usage, at the Unix prompt issue the command:  df -k

Look at where the datafiles and ORACLE_HOME are mounted. Pay attention to how much

space is available. General rule of thumb is to never allow

these mount points get to 90% full (i.e. 10% available).

3) CPU utilization:

    OS                 Command

    ~~~~~~~~~~         ~~~~~~~~~

    Sun Solaris:       sar -u

    IBM:               ps av (or) iostat 3 20

    Digital:           /usr/sbin/pset_info

    Linux:             xosview

In addition of monitoring the CPU usage you should monitor the runqueue to determine

if processes are waiting for an available processor. You can

use "sar -q" to monitor the runqueue.

4) To see how much CPU time is being used by each processor on a multiprocessor machine:

    OS                 Command

    ~~~~~~~~~~         ~~~~~~~~~

    Sun Solaris:       /usr/bin/mpstat

    HP:                /usr/sbin/sar -M 5 5

    IBM:               vmstat -> Under cpu, if "us" is a very high number you have a cpu intensive process

5) To see the number of CPUs there are in the machine, and their status:

    OS                 Command

    ~~~~~~~~~~         ~~~~~~~~~

    Sun Solaris:       /usr/sbin/mpstat

    HP:                /usr/sbin/sar -M 2 2

    IBM:               /usr/sbin/bindprocessor -q

    Digital:           /usr/sbin/psrinfo -v

    Linux:             xosview

6) To see the amount of swap space is on the machine and the usage:

    OS                 Command

    ~~~~~~~~~~         ~~~~~~~~~

    Sun Solaris:       /etc/swap -l and /etc/swap -s

    HP:                /etc/swapinfo -m ( must be root Unix id)

    IBM:               lsps -a

    Digital:           /usr/sbin/swapon -s

    Linux:             free -t

7) To see the current usage of shared memory & semephores:  "ipcs -b"

网友 ljjk5 签名 - 网友社区 ===
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-7 22:53
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP